LSTM-Crypto-Price-Prediction
Predicting price trends in cryptomarkets using an lstm-RNN for the use of a trading bot
System Structure
저장소별 전략/실행 조건 확인 필요
거래소 API 기반 자동 주문 실행
Editor Summary저장소 설명과 공개 메타데이터 기준으로 Python 기반 구현, 암호화폐 거래 봇, 거래소 API/프레임워크, 백테스트 성격의 프로젝트로 파악했습니다. 확인 근거는 README, 저장소 토픽, 저장소 설명, GitHub 지표, 파이프라인 필드이며, 주요 데이터는 Binance, 가격/거래량 데이터입니다. 전략/실행 조건은 저장소별 문서와 코드 확인이 필요하며, 실행 방식은 "거래소 API 기반 자동 주문 실행"라고 보수적으로 기록했습니다. GitHub 지표는 별 361개, 포크 57개입니다.
| Repository | SC4RECOIN/LSTM-Crypto-Price-Prediction |
|---|---|
| Creator | SC4RECOIN |
| Stars / Forks | ★ 361 / 57 |
| License | MIT |
| Last Updated | 2021-08-10 |
| Snapshot Date | 2026-07-08 (README below is a copy from this date) |
This is third-party open-source code. QuantField does not guarantee its behavior or safety. Review the code before installing or running it.
README
LSTM Crypto Price Prediction 🎯
The goal of this project is predicting the price trend of Bitcoin using an lstm-RNN. Technical analysis is applied to historical BTC data in attempt to extract price action for automated trading. The output of the network will indicate and upward or downward trend regarding the next period and will be used to trade Bitcoin throught the Binance API.
requirements
- python-binance
- Keras (RNN)
- Scikit (polynomial interpolation)
- numpy
- scipy (savgol filter)
- plotly and matplotlib (if designated graphing flag is set)
Label
The price of Bitcoin tends to be very volatile and sporadic making it difficult to find underlying trends and predict price reversals. In order to smooth the historical price data without introducing latency, a Savitzky-Golay filter is applied. The purpose of this filter is to smooth the data without greatly distorting the signal. This is done by fitting sub-sets of adjacent data points with a low-degree polynomial by the method of linear least squares. This filter looks forward into the data so it can only be used to generate labels on historic data. The first-order derivative is then taken to find the slope of the filtered data to indicate upwards and downwards movements about the zero axis. This can be seen in the following figure:
Features
The following features will be used for the lstm-RNN
- MACD histogram
- Stochastic RSI
- Detrended Price Oscillator
- Coppock Curve
- Interpolation of price
An approximation of the next price is performed using ridge regression from Scikit-learn. Through polynomial interpolation, the price can be treated as a continuous function and the next value in a series can be approximated. Instead of taking the next predicted value in the set, the slope of the last value is found to indicate onward price direction. This approximated value will be fed into the network along with the other features to predict the output label.

Results
The results so far are somewhat promising. The validation accuracy of the network is just above 70% almost 80% after adding a couple more indicators and ensuring an equal amount of training labels. This can be helpful in market analysis but cannot be used for automated trading due to false positives and network error. Adding features and have better training data should improve the model.
Update: trading test
Data from the Binance exchange was pulled from April 17 - May 12 as the model was trained prior to this and has not seen this data. The data within this period has a good balance of price action and should be a good simulation for the trading bot. This was done by applying the saved model to the data and tracking fake trades in a wallet.
fee = 0.001 # Binance trading fee
for idx, buy in enumerate(action):
if holding:
if not buy:
holding = False
wallet = btc * prices[idx] * (1 - fee)
print('$ {0:.2f}'.format(wallet))
else:
if buy:
holding = True
btc = wallet / prices[idx] * (1 - fee)
print('\nWallet: {0:.2f}%'.format((wallet/100-1)*100))
print('Holding: {0:.2f}%'.format((prices[-1]/prices[0]-1)*100))
The results are as