Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
SPY constant volatility w/ dynamic leverage (Quantapolis)

Hi Quantopians,

Here's the second bare-bones strategy example, this time about ex-ante volatility targeting. In a way it's a simple version of this and demonstrates the immediate benefits of volatility scaling in both rough and calm waters - which is why it's frequently used for position sizing in more complex trading strategies.

We're also rolling out the public beta for in-wiki voting on quantapolis.com. It's pretty wild - you can check it out on the "Algorithms" page. (You'll need to create an account for now until we figure out an efficient way to combat bot spamming)

The previous bare-bones example in the series can be found here:
Value Example (long-short)

5 responses

Also, here's a simple mod of the strategy with a trend-filter for graceful scale-out and an allocation to bonds if the equity leverage drops below 1.0. It's an easy way to smoothen returns when markets are in turmoil.

Nice algo results, Origin!

Unfortunately, I don't fully understand what you are doing. If you could add more comments, I'm sure several of us beginners could learn how to do more advanced algos.

BTW, I created a wiki account on your site with the intention to help vote on algos like this one. :)

Tristan

Hi Tristan, glad you like it.

The algo here really is a code template. It shows a building block of some of the algorithms shared by Quantopian pros in the past. I use the inverse of the 21-day standard deviation for position sizing - intuitively, the more SPY jumps around, the fewer shares I hold. Other approaches, such as Average-True-Range (ATR) do a similar job. The trend filter then prevents the algorithm from increasing its position in SPY should the market be below the 200-day moving average.

I'll add more comments to future examples so they're easier to follow.

Thanks for the explanation, it really helps!

I tried various backtests with different inputs into your algorithm and this is the best improvement I got. (Depending on your scoring metric, it may not be better, with higher volatility and drawdown)

Is it a good idea to optimize inputs like this, or is it just curve-fitting the backtest?