Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Algo wont let go of position

Hi all,

In my journey of learning, I have been slowly building on a single Algo. I am currently experience an issue that I cannot wrap my head around. The algo performs ok, filter for penny stocks, but in July 2017 I catch the up spike of PRPO. This is no a bad thing but as I am using SMAs I essentially hold onto the stock and watch it loose value as it dilutes. My PRPO position should sell immediately after the spike as it is no longer in my pipeline_results. But it doesn't. What I am missing?

2 responses

Hello Michael,

Seems like your algorithm won't let go of PRPO position, because of following line in code:

and stock not in context.stocks_sold:  

I removed that part of the code and PRPO position will get sold on 2017-07-06 for unit price of $15.40 and then it won't be in list of stocks in 2017-07-07.

Hi Mikko,

ah, I looked back and it seams that it tried a sell order, but was not filled, and I close all open orders 10 min before market close. So it was added to context.stocks_sold. I guess I will have to also amend within my canOpenOrders function.

Thanks!