시스템자가 보고크립토Pythonalgorithmic-tradingalgotradingbitcoinbotbtc

LSTM-Crypto-Price-Prediction

Predicting price trends in cryptomarkets using an lstm-RNN for the use of a trading bot

시스템 구조

활용 데이터
Binance가격/거래량 데이터
규칙 / 전략

저장소별 전략/실행 조건 확인 필요

실행

거래소 API 기반 자동 주문 실행

에디터 요약

저장소 설명과 공개 메타데이터 기준으로 Python 기반 구현, 암호화폐 거래 봇, 거래소 API/프레임워크, 백테스트 성격의 프로젝트로 파악했습니다. 확인 근거는 README, 저장소 토픽, 저장소 설명, GitHub 지표, 파이프라인 필드이며, 주요 데이터는 Binance, 가격/거래량 데이터입니다. 전략/실행 조건은 저장소별 문서와 코드 확인이 필요하며, 실행 방식은 "거래소 API 기반 자동 주문 실행"라고 보수적으로 기록했습니다. GitHub 지표는 별 361개, 포크 57개입니다.

저장소SC4RECOIN/LSTM-Crypto-Price-Prediction
제작자SC4RECOIN
스타 / 포크★ 361 / 57
라이선스MIT
최근 업데이트2021-08-10
스냅샷 시점2026-07-08 (아래 README는 이 시점의 사본입니다)

아래는 제3자가 작성·공개한 오픈소스 코드입니다. QuantField는 해당 코드의 동작과 안전성을 보증하지 않으며, 설치·실행 전 코드를 직접 검토하시기 바랍니다.

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:

alt text

Features

The following features will be used for the lstm-RNN

  • MACD histogram
  • Stochastic RSI
  • Detrended Price Oscillator
  • Coppock Curve
  • Interpolation of price

alt text

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.

alt text

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