Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
tags:
|
| 3 |
+
- time-series
|
| 4 |
+
- forecasting
|
| 5 |
+
- cryptocurrency
|
| 6 |
+
- lstm
|
| 7 |
+
- finance
|
| 8 |
+
library_name: pytorch
|
| 9 |
+
license: mit
|
| 10 |
+
datasets:
|
| 11 |
+
- coingecko_daily
|
| 12 |
+
metrics:
|
| 13 |
+
- rmse
|
| 14 |
+
- mape
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# CryptoPriceForecaster: Deep LSTM for Short-Term Price Trend Prediction
|
| 18 |
+
|
| 19 |
+
## 📑 Overview
|
| 20 |
+
|
| 21 |
+
**CryptoPriceForecaster** is a deep **Long Short-Term Memory (LSTM)** neural network optimized for predicting the closing price trend (i.e., the price change magnitude) of a major cryptocurrency (e.g., BTC/USD) over a short-term horizon (e.g., next 24 hours). It is trained on historical data including price, volume, and derived technical indicators.
|
| 22 |
+
|
| 23 |
+
## 🤖 Model Architecture
|
| 24 |
+
|
| 25 |
+
This is a custom deep learning model implemented in PyTorch/TensorFlow.
|
| 26 |
+
|
| 27 |
+
* **Type:** Recurrent Neural Network (RNN) - LSTM variant.
|
| 28 |
+
* **Input Features:** 10 features (e.g., Open, High, Low, Close, Volume, 7-day EMA, RSI, MACD Histogram, etc.).
|
| 29 |
+
* **Sequence Length:** 30 time steps (i.e., the model looks at the last 30 daily data points).
|
| 30 |
+
* **Layers:** 3 stacked LSTM layers.
|
| 31 |
+
* `Hidden Size`: 128 units per layer.
|
| 32 |
+
* `Dropout`: 0.2 applied between layers.
|
| 33 |
+
* **Output:** A single dense layer predicting the scaled *normalized* closing price. The predicted value needs to be inverse-transformed to get the actual price.
|
| 34 |
+
|
| 35 |
+
## 🎯 Intended Use
|
| 36 |
+
|
| 37 |
+
This model is designed for:
|
| 38 |
+
1. **Short-Term Trading Strategy:** Generating daily signals for predicting price movement direction.
|
| 39 |
+
2. **Research:** Studying the non-linear dependencies between technical indicators and price volatility.
|
| 40 |
+
3. **Educational Purposes:** Demonstrating the use of RNNs for financial time-series forecasting.
|
| 41 |
+
|
| 42 |
+
## ⚠️ Limitations
|
| 43 |
+
|
| 44 |
+
* **Prediction vs. Reality:** This model predicts price based on historical and technical data; it does *not* account for Black Swan events, regulatory changes, or breaking news. **It is not financial advice.**
|
| 45 |
+
* **Generalization:** Trained primarily on BTC/USD daily data, its performance on altcoins or intraday data may be significantly lower.
|
| 46 |
+
* **Stationarity:** Requires pre-processed, potentially stationary, input data (e.g., log returns) for optimal performance.
|
| 47 |
+
|
| 48 |
+
## 💻 Example Code
|
| 49 |
+
|
| 50 |
+
Assuming the input data is a 3D numpy array `X_test` (batch_size, sequence_length, features):
|
| 51 |
+
|
| 52 |
+
```python
|
| 53 |
+
import torch
|
| 54 |
+
import numpy as np
|
| 55 |
+
from CryptoPriceForecaster_Model import LSTMForecaster # Custom model class
|
| 56 |
+
|
| 57 |
+
# Load the model weights and config
|
| 58 |
+
config = json.load(open("config.json"))
|
| 59 |
+
model = LSTMForecaster(**config)
|
| 60 |
+
model.load_state_dict(torch.load("pytorch_model.bin"))
|
| 61 |
+
model.eval()
|
| 62 |
+
|
| 63 |
+
# Example input: 1 sample, 30 sequence length, 10 features
|
| 64 |
+
X_test_sample = np.random.rand(1, 30, 10).astype(np.float32)
|
| 65 |
+
input_tensor = torch.from_numpy(X_test_sample)
|
| 66 |
+
|
| 67 |
+
with torch.no_grad():
|
| 68 |
+
scaled_prediction = model(input_tensor)
|
| 69 |
+
|
| 70 |
+
# The output must be inverse-transformed using the original scaler (MinMaxScaler)
|
| 71 |
+
# For demonstration:
|
| 72 |
+
print(f"Scaled Predicted Price Change: {scaled_prediction.item():.4f}")
|