Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
moving average 3 - 2

one transaction per time

2 responses

@Cody,

Try this:

Thank you for sharing. Your code is very neat and tidy.
For my moving average 3-3 version, I changed order_target to order_target_percent in order to use up all the capital, which is similar to yours.

I have a few questions for you. Why the inconsistency of the if condition, that it used "order_target_percent" for STOCK in the first statement but "order_target" for another? Also, I found the positions is fluctuating between 1 and 0.99. Is that because every time it just sold out 1 unit of STOCK ( but it also sold 100 % of bond)?

I couldn't understand very well about the meaning of "leverage = context.account.leverage" and "positions = len(context.portfolio.positions)". Could you please explain how to interpret them or maybe point me to some resources to learn.

Anyway, thank you so much for sharing!