Projects

Trend following

EMA cross with a put hedge

One of my earlier experiments on QuantConnect, and the first time I tried to hedge a strategy from inside it. It follows trends in the most liquid US stocks and buys protection on the index when volatility is high.

  • QuantConnect
  • Python
  • Options hedging
View on GitHub

Universe and entries

Each day it takes the 100 most liquid US stocks trading above ten dollars and keeps the ones whose 50-day exponential moving average sits above their 200-day. Up to ten of them are held at 10% each, and a name is sold when it drops out of that list.

The hedge

Alongside the stocks it holds SPY at 9% of the book. When the VIX sits in the top half of its 150-day range, it buys SPY puts about 1% out of the money with around 25 days to expiry, and closes them two days before they expire.

Risk and execution

Each position is cut at a 10% unrealised loss, and orders are worked with a VWAP execution model rather than sent at market.

What it taught me

As I built it, the puts cost more than they protected. Protection bought when volatility is already high is expensive by construction, and my conclusion at the time was that a stop loss or a selling signal would do the job more cheaply.

The bigger lesson came later, with Elder's Triple Screen. A hedge written inside one strategy only protects that strategy. Hedging now sits at the portfolio level, in the risk overlay in Argus.