I'm very happy with your last Quantopian job. If you're available I'd like to hire you for 4 more versions of the work you just did. Here are the details:
For all versions the three securities to buy are SPY, TLT and GLD...cash goes to SHY as usual.
-This time, instead of going long a security when it's above its 200 day MA, instead you go short its inverse ETF equivalent. E.g., when you get the signal to go long SPY, instead of going long SPY, you go short SH.
-Here are the equivalents: SPY = SH; GLD = DGZ; TLT = TBF
-When not using capital, put it in SHY.
-Same as version 1 but with a position sizing logic based on average true range. Here's how it works...
- Take each of SPY, TLT & GLD and calculate its average true range (ATR) over the past 2 weeks (10 trading days). Average true range means calculate the % move up or down for each of the past 10 days for each security, make all numbers positive, and then calculate the average across the 10 days for each security. It's just the average amount each security has moved up and down.
- Once you have the ATR of each calculated, take the lowest ATR of the three, and calculate the $ amount that's = to 1/3 of the entire portfolio (sum of all cash + equity).
- Now adjust the $ amounts for the other 2, so that their ATR is equal to the one with the lowest ATR. E.g., if SPY has an ATR of 1%, TLT 2% and GLD 5% and 30k is the whole portfolio...1/3 of portfolio is 10k, so take the lowest ATR which is SPY. So SPY would be 10k. TLT has twice the ATR of SPY, so it would get 1/2 10k = 5k, and GLD has 5x the ATR of SPY so it would get 1/5 of 10k = 2k.
- Now apply the 200 day MA eligibility rule and for those that are above their 200 day MAs, but in the above proportions to know how much to buy. E.g., if GLD and TLT are in buy mode, then buy 2k of GLD and 5k of SPY, and put the remaining left over into SHY (30k-7k = 23k left over in SHY). If there's only SPY over its 200 MA then buy 10k of SPY and put 20k into SHY.
- Same as version 2 but adding code so that I can easily change leverage by changing a variable in the code.
- Completely different from the above other ones. In this one, the idea is to long a high dividend stock, and then hedge out its volatility with other inversely correlated stocks, so at the end you end up with a net dividend.
- The case for doing this to buy these securities: MORL, HYG, MBB, TYTE
- I was experimenting and found that if you long MORL, long TYTE, short HYG and short MBB, most of the volatility is hedged away. But I was using a clunk program to calculate this so I'd like to validate it in Quantopian.
- So this is very simple: Buy and hold the above short/long securities in equal proportions, 1/4 of capital goes to each, re-balance each 2 weeks.