Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
MA Crossover to Adjust Leverage

Hello, I'm new to the website and could use some help trying to code something!!

I want to adjust my leverage depending on the crossover over Moving Averages of SPY.

IF short.mavg_days < long_mavg_days THEN
long_leverage = 1.0
short_leverage = -0.5

IF short.mavg_days > long_mavg_days THEN
long_leverage = 0.5
short_leverage = -1.0

Thanks guys!