The idea is to predict a new price every hour, and then act on this prediction by placing a trade. In order to train the model, I used a dataset with the hourly price of Bitcoin from 2013 to 2022 included. I settled for an hour thinking that 1 minute seemed too close to matter and 1 day would be taking too much of a chance.
I used historical Kline (candlestick) data. Each complete candlestick has: Open, High, Low and Close prices while open candles only have an Open and latest price. The model was trained on the Open and High prices.
How it works
At the start of each new 1h candle, the prediction model will be given the current Open price of the new open candle, and will be tasked to predict the likely “High” price of this candle. Here is an example of a prediction made on 22/12/2022 at 12:28 GMT
22/12/2022 12:28:49 Buying BTCUSDT. Current price is 16823.97, predicted High is 16961.639. Working…
Immediately after making the prediction, the algorithm will proceed to Buy BTC using the Binance API.
For the next hour, the algorithm will check every second if the current price of Bitcoin is equal to or higher than the prediction. If it is, the Algorithm will immediately close the order.
However, if after one hour the predicted price is not reached, the algorithm will automatically sell the Bitcoin it bought because the model and the prediction will have lost their efficiency.
Weak spots
I haven’t extensively tested the algorithm yet, so the performance of this trading strategy is still unknown, however here are some things that will probably affect its performance:
It tends to always predict a higher “high” compared to the open price, meaning that the algorithm seems to think that even red candles will have a wick (check the candle anatomy above if you don’t know that this means). The algorithm is quite simple and not very customizable, it could do with a stop loss / take profit and other improvements, but this just a proof of concept. It’s largely untested, and just because it uses machine leering to predict the price, it doesn’t mean it’s accurate.
I will continue to test this out in the next week or so and report back with results. If you’re interested in playing around with it, I’ve open sourced it here: https://github.com/CyberPunkMetalHead/cryptocurrency-machine-learning-prediction-algo-trading
By default, the bot will only place test orders so there’s no risk to just letting it run and seeing how it performs. For live trading (which I don’t recommend) see the GitHub repo or this article for step-by-step instructions. Finally, this is just a simple proof of concept and the code can definitely be improved, I will probably make more improvements to the repo in the following days, but if you want to contribute on GitHub, feel free to submit a pull request.
I will report back in a week or so!
submitted by /u/CyberPunkMetalHead
[link] [comments]