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

Hi Everyone,

I'm trying to get an algorithm together to work out an idea. Here's what I'm trying to do.

1) At market open, add the open price to all the stocks in the universe to be referenced later.

2) After a predetermined amount of time, compare the current price of every stock against the open price, and sort the list based the % of change. Then, purchase 'X' number of shares of the top 'Y' stocks, based on their change in price. Example, if I have $5000 in my portfolio, and I want to invest 25% of my funds, I would buy $250 worth of the top 5 stocks.

4) Liquidate portfolio at market close, assuming there is anything left after stop loss checks, etc.

Any help would be appreciated. I'm trying to learn Python in my spare time, after having not programmed for about 15 years, in my spare time, and it's a slow process.

Thanks,

Josh