Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Trouble closing out all position with 1Million

Hey how is it going,

I have an algo that buys with a stock with 50% leverage and closes all positions when it satisfies a specific condition.
I have used order_target or order_target_percentage in handle_data to close all positions when this condition is met.

When I run the algo with 1,000 dollars it has no problem closing all positions. Same for 50,000 dollars
However, when I increase the amount of dollars for the algo, the results are dramatically different.
For example, I when I start with 1Million dollars the algo can not close all positions, rather it goes to a negative value.

My issue is how can I make sure that the algo closes all the positions?
If anyone has any suggestions, feel free to let me know!
Thanks in advance for your help!