Hi everyone. I have been working on developing a simple trading algorithm for Robinhood. Unlike many here I am neither a coding or trading genius but have been working to write some basic code:
- To trade some stocks by buying low and selling high.
- To deal with day trading rules, I have put a buffer of $25,000 that just sits there and allows me to make day trades without penalty.
- I have put in commissions, stock slippage code found here from others.
- To diversify the risk and manage leverage I want to spread the remaining money so that I only put 3% into any one stock. Currently I have 5 stocks listed instead of 33 but have been struggling to get the script to work with just one stock right now. I realize that at this price level 3% is a very small number of stocks but it is realistic to the trading funds I have right now.
I was expecting the algorithm to check the opening price of the first stock and then each minute check the current price of the first stock and if it did not have the stock in the portfolio and it met the buy logic, it would buy stock up to the 3% funds limit with the logic provided and then sell it with the logic provided, which right now is just buy it when it is $0.05 lower than the opening price and sell it when it goes above the opening price by $0.01 and then repeat - buy / sell / buy / sell as the criteria was met.
For May 15, I was expecting it to buy 1 share of BAC at the price of $24.01 (opening price - $0.05) and sell 1 share when it went above $24.07 (opening price + $0.01) and keep looping through the day (though it would be nice to know how to have it do this only once and then stop for the day too). Instead the logs show that it keeps selling the stock but never buying it while the transaction tab show that there were none.
In a perfect world, while it was doing this for the first stock, it would be doing the same thing for other stocks selected as well.
If there is anyone who would be willing to take a look at the code to see what I am doing wrong, I would appreciate it! And would be happy to make a final version, that incorporated any changes provided, available here to help any others who like me are new to this.