Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Beginner (15 and 30-day cross MA model)

Hey friends,

I am just starting to do some algorithms. This is the first one I have produced. Could you guys give me some advice on where the code could be improved? I think I am borrowing a lot of money, and I am not sure if it is reading my averages.

Thanks,

Quantdog

1 response

Averages are all good but each time the 15 sma goes above the 30 sma its buying 500 more stock than when you sell.

To avoid the leverage problem you could use something along the lines of order_amount = cash % price
or just use order_target_percent instead of order_target