File size: 3,473 Bytes
51e1403
 
 
6569de8
 
 
 
 
 
 
 
 
51e1403
 
6569de8
51e1403
6569de8
51e1403
6569de8
51e1403
6569de8
51e1403
6569de8
 
 
 
 
 
 
 
51e1403
6569de8
51e1403
6569de8
51e1403
6569de8
 
 
 
 
 
 
 
51e1403
6569de8
51e1403
6569de8
51e1403
6569de8
 
 
 
51e1403
6569de8
51e1403
6569de8
51e1403
6569de8
 
 
 
51e1403
6569de8
51e1403
6569de8
51e1403
6569de8
 
 
 
 
 
51e1403
6569de8
51e1403
6569de8
51e1403
6569de8
 
 
51e1403
6569de8
51e1403
6569de8
51e1403
6569de8
51e1403
6569de8
51e1403
6569de8
 
 
 
 
 
 
 
51e1403
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
---
license: mit
language:
  - en
tags:
  - bitcoin
  - lstm
  - time-series
  - price-prediction
  - tensorflow
  - keras
  - finance
---

# 🧠 Bitcoin Price Forecasting using LSTM Neural Network

A deep learning model based on Long Short-Term Memory (LSTM) networks to predict the next-day closing price of Bitcoin (BTC-USD) using historical data from Yahoo Finance.

---

## 🔍 Model Overview

| Feature            | Description                                                                 |
|--------------------|-----------------------------------------------------------------------------|
| 📦 Model Type      | LSTM (Long Short-Term Memory), a variant of Recurrent Neural Networks (RNN) |
| 🧠 Frameworks Used | TensorFlow (Keras API), Scikit-learn, NumPy, Pandas, yfinance                |
| 📈 Input           | Past 60 days of Bitcoin closing prices                                       |
| 🎯 Output          | Predicted closing price for the next day                                     |
| 📊 Evaluation      | Root Mean Squared Error (RMSE)                                               |
| 🧪 Goal            | Short-term (1-day ahead) BTC price forecasting                               |

---

## 🔧 What the Model Does

- Downloads historical BTC-USD data from Yahoo Finance
- Normalizes the data between 0 and 1 using MinMaxScaler
- Splits into 80% training and 20% test sets
- Creates time-sequenced inputs with a 60-day sliding window
- Trains a 2-layer LSTM model with dropout to prevent overfitting
- Evaluates the model using RMSE
- Plots predicted vs actual prices
- Makes a next-day prediction using the last 60 days of data

---

## 💡 Use Cases

- Educational: Learning time series forecasting and LSTM models
- Research: Benchmarking for financial forecasting models
- Visualization: Analyze model performance on real BTC data
- Academic Support: Useful for papers or prototypes on AI-based financial systems

---

## ⚠️ Limitations

- Uses only the closing price (no volume, indicators, or sentiment data)
- Performs only single-step (1-day ahead) forecasting
- Does not account for sudden market news or shocks
- Not designed for high-frequency or live trading systems

---

## 🚀 Potential Improvements

- Include additional features: volume, RSI, MACD, etc.
- Integrate external signals: news, social media sentiment, macro data
- Add attention or transformer-based layers
- Extend to multi-step forecasting (3-day, 5-day, etc.)
- Deploy as REST API or interactive dashboard
- Connect to Binance or other exchanges for live predictions

---

## 📁 Files

- `lstm_bitcoin_predictor.py`: Full code to train, evaluate, and predict using LSTM
- `data.csv`: (optional) Cached historical BTC-USD data
- `model.h5`: Saved trained model

---

## 📜 License

This project is licensed under the MIT License.

---

## ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️ Disclaimer⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️

> **This model is intended for educational and research purposes only.**
>
> It is **not** designed for financial or investment decision-making.  
> No guarantees are made about the accuracy of the forecasts.  
> The authors accept no responsibility for any financial losses incurred from the use of this model.  
> **Use at your own risk.**