Forecasting cryptocurrency prices using neural networks
Used libraries:
● aiohttp: for collecting historical data from the Binance API
● PyTorch and PyTorch Lightning: for building and training the model
● pandas, numpy: for working with time series, preparing and analyzing data
● seaborn, matplotlib: for data visualization
● DeepSpeed: for optimizing training on large datasets
Main tasks:
● Data collection and normalization, preparation of time series for cryptocurrencies
● Building and training the optimized DeepAR model
● Forecasting data using the created model
● Visualizing results to assess model quality
Implementation process:
1. Data preparation:
The function get_klines_for_train retrieves historical price change data at time intervals and calculates technical indicators such as RSI, EMA, and others. After that, the data is saved to a CSV file for further use. The currency pair JUP/USDT was chosen for model training with a 1-hour interval, and for testing — the pairs BTC/USDT, SOL/USDT, and XRP/USDT. Although the amount of data was limited, it was sufficient for effective training. In the main module, data is loaded from the CSV file, and the dataset is normalized using a specially implemented MinMax method.
2. Creating and training the DeepAR model:
The model is based on a customized version of DeepAREnhanced, which is an optimized variant of the classic DeepAR. To improve accuracy on large time series, a special version of ScaledNormalLoss was introduced, which enhances the loss function. Training was conducted using DeepSpeed to accelerate the process and EarlyStopping to avoid overfitting.
3. Forecasting and visualization:
After training, the model was used to forecast prices on the test dataset. The forecasting results were compared with actual values using the plot_comparison() function, which visually demonstrates the model's accuracy and its effectiveness in predicting future trends.
Tags:
#python #pytorch #binance #binance.com #datascience #cryptocurrency #криптовалюты #ai
● aiohttp: for collecting historical data from the Binance API
● PyTorch and PyTorch Lightning: for building and training the model
● pandas, numpy: for working with time series, preparing and analyzing data
● seaborn, matplotlib: for data visualization
● DeepSpeed: for optimizing training on large datasets
Main tasks:
● Data collection and normalization, preparation of time series for cryptocurrencies
● Building and training the optimized DeepAR model
● Forecasting data using the created model
● Visualizing results to assess model quality
Implementation process:
1. Data preparation:
The function get_klines_for_train retrieves historical price change data at time intervals and calculates technical indicators such as RSI, EMA, and others. After that, the data is saved to a CSV file for further use. The currency pair JUP/USDT was chosen for model training with a 1-hour interval, and for testing — the pairs BTC/USDT, SOL/USDT, and XRP/USDT. Although the amount of data was limited, it was sufficient for effective training. In the main module, data is loaded from the CSV file, and the dataset is normalized using a specially implemented MinMax method.
2. Creating and training the DeepAR model:
The model is based on a customized version of DeepAREnhanced, which is an optimized variant of the classic DeepAR. To improve accuracy on large time series, a special version of ScaledNormalLoss was introduced, which enhances the loss function. Training was conducted using DeepSpeed to accelerate the process and EarlyStopping to avoid overfitting.
3. Forecasting and visualization:
After training, the model was used to forecast prices on the test dataset. The forecasting results were compared with actual values using the plot_comparison() function, which visually demonstrates the model's accuracy and its effectiveness in predicting future trends.
Tags:
#python #pytorch #binance #binance.com #datascience #cryptocurrency #криптовалюты #ai