Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Seeking Help to Finish the Algorithm

Hi Quantopians,

I am new to this platform and so far I am loving it. I am currently an intern and one of my bosses has asked me to make a model on Excel for a certain stock behavior. It's pretty simple.
1. At the end of the day, I look at the top 5 gainers of the top 500 stocks and buy them all at 20% of the portfolio.
2. Following day, if the stock goes up 1% then sell it off, if it doesn't reach 1% then sell 5minutes before closing bell.
3. Buy top 5 stocks at the end of the day and repeat.
I've been doing it manually for a couple of weeks but after having worked on my python whole summer I thought it would be neat if I could build an algorithm that would do the work for me. I have gotten to a certain extent but I can't seem to be able to complete it.

The algorithm seems to be working in terms of buying the 5 stocks at the end of the day and selling whatever stock didn't get sold throughout the day. My only issue is triggering the sell when the stock price actually goes up 1% during the following day. If I bought $FB on day 1 at $100 and on day 2 it reaches $101 it should trigger a sell and not wait at the end of the day to sell it. Could anyone help me with finishing the code?

Thank you!