--- tags: - time-series - forecasting - cryptocurrency - lstm - finance library_name: pytorch license: mit datasets: - coingecko_daily metrics: - rmse - mape --- # CryptoPriceForecaster: Deep LSTM for Short-Term Price Trend Prediction ## 📑 Overview **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. ## 🤖 Model Architecture This is a custom deep learning model implemented in PyTorch/TensorFlow. * **Type:** Recurrent Neural Network (RNN) - LSTM variant. * **Input Features:** 10 features (e.g., Open, High, Low, Close, Volume, 7-day EMA, RSI, MACD Histogram, etc.). * **Sequence Length:** 30 time steps (i.e., the model looks at the last 30 daily data points). * **Layers:** 3 stacked LSTM layers. * `Hidden Size`: 128 units per layer. * `Dropout`: 0.2 applied between layers. * **Output:** A single dense layer predicting the scaled *normalized* closing price. The predicted value needs to be inverse-transformed to get the actual price. ## 🎯 Intended Use This model is designed for: 1. **Short-Term Trading Strategy:** Generating daily signals for predicting price movement direction. 2. **Research:** Studying the non-linear dependencies between technical indicators and price volatility. 3. **Educational Purposes:** Demonstrating the use of RNNs for financial time-series forecasting. ## ⚠️ Limitations * **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.** * **Generalization:** Trained primarily on BTC/USD daily data, its performance on altcoins or intraday data may be significantly lower. * **Stationarity:** Requires pre-processed, potentially stationary, input data (e.g., log returns) for optimal performance. ## 💻 Example Code Assuming the input data is a 3D numpy array `X_test` (batch_size, sequence_length, features): ```python import torch import numpy as np from CryptoPriceForecaster_Model import LSTMForecaster # Custom model class # Load the model weights and config config = json.load(open("config.json")) model = LSTMForecaster(**config) model.load_state_dict(torch.load("pytorch_model.bin")) model.eval() # Example input: 1 sample, 30 sequence length, 10 features X_test_sample = np.random.rand(1, 30, 10).astype(np.float32) input_tensor = torch.from_numpy(X_test_sample) with torch.no_grad(): scaled_prediction = model(input_tensor) # The output must be inverse-transformed using the original scaler (MinMaxScaler) # For demonstration: print(f"Scaled Predicted Price Change: {scaled_prediction.item():.4f}")