Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Why does my leverage go above 1 here?

What is causing the leverage to go above 1?

2 responses
order_value(context.aapl,10000)  

This will order $10,000 worth of AAPL every time the condition is met, this builds up so if the condition is met two times, you'll hold $20,000 etc...

If you want to keep leverage at 1, use:

order_target_percent(context.aapl, 1)  

This should do the job, I removed the Handle Date method because it just stacked orders.