This repository contains a full pipeline for collecting, preprocessing, training, and forecasting cryptocurrency data using a transformer-based model called LiteFormer. The project integrates with the Polygon API to fetch historical crypto data, applies technical analysis indicators using the ta library, and builds a deep learning model with PyTorch to predict future close prices.
- Overview
- Features
- Installation
- Usage
- Code Structure
- Directory Structure
- Configuration
- Contributing
- License
- Contact
The project implements a complete workflow for cryptocurrency forecasting:
-
Data Collection:
Fetches data from the Polygon API for given tickers and timeframes, saving raw data into CSV files. -
Data Preprocessing:
Computes technical indicators such as RSI, MACD, ATR, Bollinger Bands, and ADX, and prepares the data for modeling. -
Model Training:
Uses a transformer-based model (LiteFormer) with positional encoding for time series forecasting. Training includes features like gradient accumulation, learning rate scheduling, and early stopping. -
Prediction & Evaluation:
Generates predictions for the next time steps, computes error metrics (MAE, RMSE), and categorizes predictions. -
Result Sharing:
Optionally uploads the combined predictions CSV file to Oshi for easy sharing.
- Multi-Ticker Data Collection: Fetch historical data for multiple cryptocurrencies.
- Technical Indicator Calculation: Leverages the
talibrary for RSI, MACD, ATR, Bollinger Bands, and ADX. - Transformer-Based Forecasting: Implements a custom transformer (LiteFormer) model using PyTorch.
- Custom Dataset & DataLoader: Prepares time-series windows from the data for model training.
- Training & Validation Pipeline: Uses gradient accumulation and adaptive learning rate scheduling.
- Prediction & Metrics: Evaluates model performance and saves predictions with additional classification (direction, percentage change).
- File Upload: Supports uploading results to Oshi for public access.
- Clone the repository:
git clone https://github.com/yourusername/crypto-forecasting.git cd crypto-forecasting