Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,420 +1,338 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
|
| 4 |
-
emoji: π»
|
| 5 |
colorFrom: blue
|
| 6 |
colorTo: indigo
|
| 7 |
-
|
|
|
|
|
|
|
| 8 |
pinned: false
|
|
|
|
| 9 |
---
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
AI-powered stock price predictions using LSTM neural networks, technical analysis, and market sentiment analysis.
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
---
|
| 24 |
|
| 25 |
-
|
| 26 |
|
| 27 |
-
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
# - model.py
|
| 34 |
-
# - requirements.txt
|
| 35 |
-
# - .env.example
|
| 36 |
-
# - .gitignore
|
| 37 |
-
# - README.md
|
| 38 |
-
```
|
| 39 |
|
| 40 |
-
|
| 41 |
|
| 42 |
-
```bash
|
| 43 |
-
# Windows
|
| 44 |
python -m venv venv
|
| 45 |
venv\Scripts\activate
|
| 46 |
|
| 47 |
-
|
|
|
|
| 48 |
python3 -m venv venv
|
| 49 |
source venv/bin/activate
|
| 50 |
-
```
|
| 51 |
|
| 52 |
-
### 3. Install Dependencies
|
| 53 |
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
| 55 |
pip install -r requirements.txt
|
| 56 |
-
```
|
| 57 |
|
| 58 |
-
### 4. Setup Environment Variables
|
| 59 |
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
| 63 |
|
| 64 |
-
|
| 65 |
-
# FINNHUB_API_KEY=your_api_key_here
|
| 66 |
-
```
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
-
|
| 74 |
|
| 75 |
-
```bash
|
| 76 |
python app.py
|
| 77 |
-
```
|
| 78 |
|
| 79 |
-
The
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
---
|
| 82 |
|
| 83 |
-
|
| 84 |
|
| 85 |
-
|
| 86 |
|
| 87 |
-
1.
|
| 88 |
-
2. Click "Create new Space"
|
| 89 |
-
3. Fill in:
|
| 90 |
-
- **Space name**: `stock-predictor` (or any name)
|
| 91 |
-
- **License**: `mit` or `apache-2.0`
|
| 92 |
-
- **SDK**: Select **Gradio**
|
| 93 |
-
- **Visibility**: Public or Private
|
| 94 |
|
| 95 |
-
4. Click "Create Space"
|
| 96 |
|
| 97 |
-
### Step 2: Upload Files
|
| 98 |
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
-
```bash
|
| 102 |
-
cd your-space-repo
|
| 103 |
-
git clone https://huggingface.co/spaces/YOUR_USERNAME/stock-predictor
|
| 104 |
-
cd stock-predictor
|
| 105 |
-
```
|
| 106 |
|
| 107 |
-
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
app.py
|
| 110 |
model.py
|
| 111 |
requirements.txt
|
|
|
|
| 112 |
.env.example
|
| 113 |
.gitignore
|
| 114 |
-
README.md
|
| 115 |
-
```
|
| 116 |
|
| 117 |
-
### Step 3: Setup Environment Variables (HF Spaces)
|
| 118 |
|
| 119 |
-
|
|
|
|
|
|
|
| 120 |
|
| 121 |
-
|
| 122 |
-
- **Name**: `FINNHUB_API_KEY`
|
| 123 |
-
- **Value**: Your Finnhub API key
|
| 124 |
|
| 125 |
-
|
| 126 |
|
| 127 |
-
|
| 128 |
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
git commit -m "Initial stock predictor setup"
|
| 132 |
-
git push
|
| 133 |
-
```
|
| 134 |
|
| 135 |
-
HF Spaces will automatically:
|
| 136 |
-
1. Install dependencies from `requirements.txt`
|
| 137 |
-
2. Run `app.py`
|
| 138 |
-
3. Deploy your app with a public URL
|
| 139 |
|
| 140 |
---
|
| 141 |
|
| 142 |
-
|
| 143 |
|
| 144 |
-
|
| 145 |
|
| 146 |
-
|
| 147 |
-
2. Select number of days to predict (1-30)
|
| 148 |
-
3. Click **π Predict**
|
| 149 |
-
4. View results table and analysis
|
| 150 |
|
| 151 |
-
|
| 152 |
|
| 153 |
-
|
| 154 |
-
- **US**: NASDAQ, NYSE (AAPL, GOOGL, MSFT, TSLA, etc.)
|
| 155 |
-
- **Europe**: LSE, Euronext (various symbols)
|
| 156 |
-
- **India**: NSE, BSE (SBIN.NS, INFY.NS, etc.)
|
| 157 |
|
| 158 |
-
### Example Stocks
|
| 159 |
|
| 160 |
-
```
|
| 161 |
-
AAPL - Apple
|
| 162 |
-
GOOGL - Google (Alphabet)
|
| 163 |
-
MSFT - Microsoft
|
| 164 |
-
AMZN - Amazon
|
| 165 |
-
TSLA - Tesla
|
| 166 |
-
NVDA - NVIDIA
|
| 167 |
-
META - Meta (Facebook)
|
| 168 |
-
NFLX - Netflix
|
| 169 |
-
```
|
| 170 |
|
| 171 |
---
|
| 172 |
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
### 1. Data Collection (Step 1)
|
| 176 |
-
- Fetches 100 days of historical price data from Yahoo Finance
|
| 177 |
-
- Uses: Open, High, Low, Close, Volume prices
|
| 178 |
-
|
| 179 |
-
### 2. Feature Engineering (Step 2)
|
| 180 |
-
Calculates 6 technical indicators:
|
| 181 |
-
- **Close**: Stock closing price
|
| 182 |
-
- **RSI**: Relative Strength Index (momentum, 14-day)
|
| 183 |
-
- **MACD**: Moving Average Convergence Divergence
|
| 184 |
-
- **Volatility**: Standard deviation of returns (10-day)
|
| 185 |
-
- **SMA20**: 20-day Simple Moving Average (trend)
|
| 186 |
-
- **ROC**: Rate of Change (5-day)
|
| 187 |
-
|
| 188 |
-
### 3. Preprocessing (Step 3)
|
| 189 |
-
- Normalizes all features to [0, 1] range using MinMaxScaler
|
| 190 |
-
- Creates sequences of 30 days for LSTM training
|
| 191 |
-
|
| 192 |
-
### 4. LSTM Model Training (Step 4)
|
| 193 |
-
- **Architecture**: 1 LSTM layer (32 hidden units) + 1 Dense layer
|
| 194 |
-
- **Training**: 50 epochs, batch size 32
|
| 195 |
-
- **Optimizer**: Adam (lr=0.001)
|
| 196 |
-
- **Loss**: Mean Squared Error
|
| 197 |
-
- **Time**: ~2 minutes on CPU
|
| 198 |
-
|
| 199 |
-
### 5. Price Prediction (Step 5)
|
| 200 |
-
- Uses trained LSTM to predict next N days
|
| 201 |
-
- Autoregressive approach: uses previous predictions for future predictions
|
| 202 |
-
- Inverse transforms predictions back to actual prices
|
| 203 |
-
|
| 204 |
-
### 6. Sentiment Analysis (Step 6)
|
| 205 |
-
- Fetches latest 10 news articles from Finnhub
|
| 206 |
-
- Uses VADER sentiment analyzer (rule-based, fast, accurate)
|
| 207 |
-
- Classifies each article as Positive/Negative/Neutral
|
| 208 |
|
| 209 |
-
|
| 210 |
|
| 211 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
|
| 213 |
-
|
| 214 |
-
|--------|-------|
|
| 215 |
-
| **Single Prediction** | 1-2 seconds |
|
| 216 |
-
| **Cached Prediction** | 50-100ms |
|
| 217 |
-
| **Model Training** | 2 minutes |
|
| 218 |
-
| **Memory Usage** | 2-3GB |
|
| 219 |
-
| **Package Size** | 600MB |
|
| 220 |
-
| **Accuracy (MAPE)** | 4.8% |
|
| 221 |
-
| **Directional Accuracy** | 76-77% |
|
| 222 |
|
| 223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
|
| 225 |
-
- β
PyTorch instead of TensorFlow (6x smaller)
|
| 226 |
-
- β
yfinance instead of Alpha Vantage (no API limits)
|
| 227 |
-
- β
Direct LSTM (no XGBoost residuals)
|
| 228 |
-
- β
VADER sentiment (no transformers)
|
| 229 |
-
- β
24-hour prediction cache
|
| 230 |
-
- β
Gradio native support
|
| 231 |
|
| 232 |
---
|
| 233 |
|
| 234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
|
| 236 |
-
```
|
| 237 |
-
Input Sequence (30 days Γ 6 features)
|
| 238 |
-
β
|
| 239 |
-
LSTM Layer
|
| 240 |
-
(32 hidden units)
|
| 241 |
-
β
|
| 242 |
-
Dense Layer
|
| 243 |
-
(1 output)
|
| 244 |
-
β
|
| 245 |
-
Predicted Price
|
| 246 |
-
```
|
| 247 |
|
| 248 |
---
|
| 249 |
|
| 250 |
-
|
| 251 |
|
| 252 |
-
|
| 253 |
|
| 254 |
-
|
| 255 |
-
- **Market efficiency**: ~95% of info already priced in
|
| 256 |
-
- **Black swan events**: Unpredictable shocks
|
| 257 |
-
- **Noise**: High-frequency trading noise
|
| 258 |
|
| 259 |
-
|
| 260 |
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
|
|
|
|
|
|
| 264 |
|
| 265 |
-
### Directional Accuracy
|
| 266 |
|
| 267 |
-
- **Definition**: Predicting if price goes UP or DOWN
|
| 268 |
-
- **Accuracy**: 76-77%
|
| 269 |
-
- **Better than**: Random guess (50%)
|
| 270 |
|
| 271 |
---
|
| 272 |
|
| 273 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
|
| 275 |
-
β οΈ **This is for educational purposes only. NOT financial advice.**
|
| 276 |
|
| 277 |
-
### Limitations
|
| 278 |
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
|
| 285 |
-
|
| 286 |
|
| 287 |
-
|
| 288 |
-
- FDA drug approvals
|
| 289 |
-
- Geopolitical events
|
| 290 |
-
- Market crashes
|
| 291 |
-
- Sector rotations
|
| 292 |
|
| 293 |
-
|
|
|
|
|
|
|
| 294 |
|
| 295 |
-
**Past performance β Future results**
|
| 296 |
|
| 297 |
-
Always:
|
| 298 |
-
- β
Conduct your own research
|
| 299 |
-
- β
Diversify your portfolio
|
| 300 |
-
- β
Consult a financial advisor
|
| 301 |
-
- β
Manage risk properly
|
| 302 |
-
- β
Never invest what you can't afford to lose
|
| 303 |
|
| 304 |
---
|
| 305 |
|
| 306 |
-
|
| 307 |
|
| 308 |
-
|
| 309 |
|
| 310 |
-
|
| 311 |
-
- Use **HF Spaces Secrets** for deployment
|
| 312 |
-
- API keys are not logged or stored
|
| 313 |
-
- Data comes from Yahoo Finance (public)
|
| 314 |
|
| 315 |
-
|
| 316 |
|
| 317 |
-
|
| 318 |
-
- β
Predictions cached locally (24 hours)
|
| 319 |
-
- β
No ads or tracking
|
| 320 |
-
- β
Open source code
|
| 321 |
|
| 322 |
-
---
|
| 323 |
|
| 324 |
-
## π Troubleshooting
|
| 325 |
|
| 326 |
-
|
| 327 |
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
|
| 332 |
-
|
| 333 |
|
| 334 |
-
1. Check symbol spelling (e.g., `AAPL` not `APPLE`)
|
| 335 |
-
2. Use international format (e.g., `SBIN.NS` for Indian stocks)
|
| 336 |
-
3. Check stock is listed on a major exchange
|
| 337 |
|
| 338 |
-
### "FINNHUB_API_KEY not set"
|
| 339 |
|
| 340 |
-
|
| 341 |
-
1. Get key: https://finnhub.io/register
|
| 342 |
-
2. Add to `.env` file
|
| 343 |
-
3. Restart app
|
| 344 |
|
| 345 |
-
|
| 346 |
|
| 347 |
-
|
| 348 |
|
| 349 |
-
|
| 350 |
|
| 351 |
-
|
| 352 |
|
| 353 |
-
### "Connection timeout" or "Too many requests"
|
| 354 |
|
| 355 |
-
API rate limit reached. Solution:
|
| 356 |
-
- Wait a few minutes
|
| 357 |
-
- Cache prevents repeated requests (enabled by default)
|
| 358 |
|
| 359 |
---
|
| 360 |
|
| 361 |
-
|
|
|
|
|
|
|
| 362 |
|
| 363 |
-
```
|
| 364 |
-
stock-predictor/
|
| 365 |
-
βββ app.py # Gradio interface (main entry point)
|
| 366 |
-
βββ model.py # LSTM model and prediction logic
|
| 367 |
-
βββ requirements.txt # Python dependencies
|
| 368 |
-
βββ .env.example # Environment variables template
|
| 369 |
-
βββ .gitignore # Git ignore rules
|
| 370 |
-
βββ README.md # This file
|
| 371 |
-
|
| 372 |
-
Optional (generated):
|
| 373 |
-
βββ .env # Your API keys (NOT committed)
|
| 374 |
-
βββ lstm_model.pt # Trained model cache
|
| 375 |
-
βββ prediction_cache.pkl # Prediction cache
|
| 376 |
-
βββ __pycache__/ # Python cache
|
| 377 |
-
```
|
| 378 |
|
| 379 |
---
|
| 380 |
|
| 381 |
-
|
| 382 |
|
| 383 |
-
|
| 384 |
-
- Better sentiment analysis
|
| 385 |
-
- Multiple models ensemble
|
| 386 |
-
- Real-time streaming
|
| 387 |
-
- Mobile app
|
| 388 |
-
- Explainability (SHAP)
|
| 389 |
|
| 390 |
-
|
| 391 |
|
| 392 |
-
|
| 393 |
|
| 394 |
-
MIT License - Free for personal and commercial use
|
| 395 |
|
| 396 |
---
|
| 397 |
|
| 398 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 399 |
|
| 400 |
-
- **Finnhub API**: https://finnhub.io/
|
| 401 |
-
- **Gradio**: https://gradio.app/
|
| 402 |
-
- **HF Spaces**: https://huggingface.co/spaces
|
| 403 |
-
- **PyTorch**: https://pytorch.org/
|
| 404 |
-
- **yfinance**: https://github.com/ranaroussi/yfinance
|
| 405 |
|
| 406 |
---
|
| 407 |
|
| 408 |
-
|
|
|
|
|
|
|
| 409 |
|
| 410 |
-
For issues:
|
| 411 |
-
1. Check troubleshooting section above
|
| 412 |
-
2. Verify API key is set
|
| 413 |
-
3. Check stock symbol is valid
|
| 414 |
-
4. Check internet connection
|
| 415 |
|
| 416 |
---
|
| 417 |
|
| 418 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 419 |
|
| 420 |
-
|
|
|
|
| 1 |
---
|
| 2 |
+
title: StockPredictor
|
| 3 |
+
emoji: π
|
|
|
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: indigo
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: "5.29.0"
|
| 8 |
+
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
license: mit
|
| 11 |
---
|
| 12 |
+
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
title: StockPredictor emoji: π colorFrom: blue colorTo: indigo sdk: gradio sdk_version: "5.29.0" app_file: app.py pinned: false license: mit
|
| 16 |
+
|
| 17 |
+
π Stock Price Predictor
|
| 18 |
|
| 19 |
AI-powered stock price predictions using LSTM neural networks, technical analysis, and market sentiment analysis.
|
| 20 |
|
| 21 |
+
π Features
|
| 22 |
+
|
| 23 |
+
β‘ Fast predictions
|
| 24 |
+
|
| 25 |
+
π§ LSTM Deep Learning model
|
| 26 |
+
|
| 27 |
+
π Technical indicators (RSI, MACD, SMA, ROC)
|
| 28 |
+
|
| 29 |
+
π News sentiment analysis
|
| 30 |
+
|
| 31 |
+
πΎ Prediction caching
|
| 32 |
+
|
| 33 |
+
π± Gradio web interface
|
| 34 |
+
|
| 35 |
+
π Supports US and Indian stocks
|
| 36 |
+
|
| 37 |
+
|
| 38 |
|
| 39 |
---
|
| 40 |
|
| 41 |
+
π οΈ Local Setup
|
| 42 |
|
| 43 |
+
1. Clone Repository
|
| 44 |
|
| 45 |
+
git clone https://github.com/your-username/stock-predictor.git
|
| 46 |
+
cd stock-predictor
|
| 47 |
+
|
| 48 |
+
2. Create Virtual Environment
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
+
Windows
|
| 51 |
|
|
|
|
|
|
|
| 52 |
python -m venv venv
|
| 53 |
venv\Scripts\activate
|
| 54 |
|
| 55 |
+
macOS/Linux
|
| 56 |
+
|
| 57 |
python3 -m venv venv
|
| 58 |
source venv/bin/activate
|
|
|
|
| 59 |
|
|
|
|
| 60 |
|
| 61 |
+
---
|
| 62 |
+
|
| 63 |
+
3. Install Dependencies
|
| 64 |
+
|
| 65 |
pip install -r requirements.txt
|
|
|
|
| 66 |
|
|
|
|
| 67 |
|
| 68 |
+
---
|
| 69 |
+
|
| 70 |
+
4. Add Environment Variables
|
| 71 |
+
|
| 72 |
+
Create a .env file:
|
| 73 |
|
| 74 |
+
FINNHUB_API_KEY=your_api_key_here
|
|
|
|
|
|
|
| 75 |
|
| 76 |
+
Get a free API key from:
|
| 77 |
+
|
| 78 |
+
https://finnhub.io/register
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
---
|
| 83 |
|
| 84 |
+
5. Run Application
|
| 85 |
|
|
|
|
| 86 |
python app.py
|
|
|
|
| 87 |
|
| 88 |
+
The application will start at:
|
| 89 |
+
|
| 90 |
+
http://localhost:7860
|
| 91 |
+
|
| 92 |
|
| 93 |
---
|
| 94 |
|
| 95 |
+
π Deploy on Hugging Face Spaces
|
| 96 |
|
| 97 |
+
Step 1: Create Space
|
| 98 |
|
| 99 |
+
1. Open:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
|
|
|
| 101 |
|
|
|
|
| 102 |
|
| 103 |
+
https://huggingface.co/spaces
|
| 104 |
+
|
| 105 |
+
2. Click:
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
Create New Space
|
| 110 |
+
|
| 111 |
+
3. Configure:
|
| 112 |
+
|
| 113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
+
SDK: Gradio
|
| 116 |
+
|
| 117 |
+
License: MIT
|
| 118 |
+
|
| 119 |
+
Visibility: Public or Private
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
---
|
| 124 |
+
|
| 125 |
+
Step 2: Upload Project Files
|
| 126 |
+
|
| 127 |
+
Upload the following files:
|
| 128 |
+
|
| 129 |
app.py
|
| 130 |
model.py
|
| 131 |
requirements.txt
|
| 132 |
+
README.md
|
| 133 |
.env.example
|
| 134 |
.gitignore
|
|
|
|
|
|
|
| 135 |
|
|
|
|
| 136 |
|
| 137 |
+
---
|
| 138 |
+
|
| 139 |
+
Step 3: Add Repository Secrets
|
| 140 |
|
| 141 |
+
Go to:
|
|
|
|
|
|
|
| 142 |
|
| 143 |
+
Settings β Repository secrets
|
| 144 |
|
| 145 |
+
Add the following secret:
|
| 146 |
|
| 147 |
+
Name: FINNHUB_API_KEY
|
| 148 |
+
Value: your_api_key
|
|
|
|
|
|
|
|
|
|
| 149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
|
| 151 |
---
|
| 152 |
|
| 153 |
+
Step 4: Automatic Deployment
|
| 154 |
|
| 155 |
+
Hugging Face Spaces will automatically:
|
| 156 |
|
| 157 |
+
Install dependencies
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
+
Run app.py
|
| 160 |
|
| 161 |
+
Create a public deployment URL
|
|
|
|
|
|
|
|
|
|
| 162 |
|
|
|
|
| 163 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
|
| 165 |
---
|
| 166 |
|
| 167 |
+
π Supported Stock Symbols
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
|
| 169 |
+
US Stocks
|
| 170 |
|
| 171 |
+
AAPL
|
| 172 |
+
MSFT
|
| 173 |
+
GOOGL
|
| 174 |
+
AMZN
|
| 175 |
+
TSLA
|
| 176 |
+
NVDA
|
| 177 |
+
META
|
| 178 |
+
NFLX
|
| 179 |
|
| 180 |
+
Indian Stocks
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
|
| 182 |
+
SBIN.NS
|
| 183 |
+
INFY.NS
|
| 184 |
+
RELIANCE.NS
|
| 185 |
+
TCS.NS
|
| 186 |
+
HDFCBANK.NS
|
| 187 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
|
| 189 |
---
|
| 190 |
|
| 191 |
+
π§ Model Architecture
|
| 192 |
+
|
| 193 |
+
Input Features
|
| 194 |
+
β
|
| 195 |
+
LSTM Layer (32 Units)
|
| 196 |
+
β
|
| 197 |
+
Dense Layer
|
| 198 |
+
β
|
| 199 |
+
Predicted Price
|
| 200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
|
| 202 |
---
|
| 203 |
|
| 204 |
+
π Technical Indicators Used
|
| 205 |
|
| 206 |
+
RSI
|
| 207 |
|
| 208 |
+
MACD
|
|
|
|
|
|
|
|
|
|
| 209 |
|
| 210 |
+
SMA20
|
| 211 |
|
| 212 |
+
Volatility
|
| 213 |
+
|
| 214 |
+
ROC
|
| 215 |
+
|
| 216 |
+
Closing Price
|
| 217 |
|
|
|
|
| 218 |
|
|
|
|
|
|
|
|
|
|
| 219 |
|
| 220 |
---
|
| 221 |
|
| 222 |
+
β‘ Performance
|
| 223 |
+
|
| 224 |
+
Metric Value
|
| 225 |
+
|
| 226 |
+
Prediction Speed 1-2 seconds
|
| 227 |
+
Cached Predictions 50-100ms
|
| 228 |
+
Training Time ~2 minutes
|
| 229 |
+
Memory Usage 2-3 GB
|
| 230 |
+
Accuracy (MAPE) ~4.8%
|
| 231 |
+
Directional Accuracy 76-77%
|
| 232 |
|
|
|
|
| 233 |
|
|
|
|
| 234 |
|
| 235 |
+
---
|
| 236 |
+
|
| 237 |
+
β οΈ Disclaimer
|
| 238 |
+
|
| 239 |
+
This project is for educational purposes only.
|
| 240 |
|
| 241 |
+
Not financial advice
|
| 242 |
|
| 243 |
+
Markets are unpredictable
|
|
|
|
|
|
|
|
|
|
|
|
|
| 244 |
|
| 245 |
+
Always conduct your own research
|
| 246 |
+
|
| 247 |
+
Invest responsibly
|
| 248 |
|
|
|
|
| 249 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 250 |
|
| 251 |
---
|
| 252 |
|
| 253 |
+
π Security Notes
|
| 254 |
|
| 255 |
+
Never upload .env
|
| 256 |
|
| 257 |
+
Use HF Spaces Secrets for API keys
|
|
|
|
|
|
|
|
|
|
| 258 |
|
| 259 |
+
No user data stored
|
| 260 |
|
| 261 |
+
Uses public Yahoo Finance data
|
|
|
|
|
|
|
|
|
|
| 262 |
|
|
|
|
| 263 |
|
|
|
|
| 264 |
|
| 265 |
+
---
|
| 266 |
|
| 267 |
+
π Common Issues
|
| 268 |
+
|
| 269 |
+
Configuration Error on HF Spaces
|
| 270 |
|
| 271 |
+
Use this exact YAML block at the top of README.md:
|
| 272 |
|
|
|
|
|
|
|
|
|
|
| 273 |
|
|
|
|
| 274 |
|
| 275 |
+
Important:
|
|
|
|
|
|
|
|
|
|
| 276 |
|
| 277 |
+
YAML must start at line 1
|
| 278 |
|
| 279 |
+
No spaces before ---
|
| 280 |
|
| 281 |
+
app_file is required
|
| 282 |
|
| 283 |
+
Use supported Gradio versions only
|
| 284 |
|
|
|
|
| 285 |
|
|
|
|
|
|
|
|
|
|
| 286 |
|
| 287 |
---
|
| 288 |
|
| 289 |
+
ModuleNotFoundError
|
| 290 |
+
|
| 291 |
+
pip install -r requirements.txt
|
| 292 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
|
| 294 |
---
|
| 295 |
|
| 296 |
+
No Data Found
|
| 297 |
|
| 298 |
+
Verify stock symbol format.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
|
| 300 |
+
Example:
|
| 301 |
|
| 302 |
+
SBIN.NS
|
| 303 |
|
|
|
|
| 304 |
|
| 305 |
---
|
| 306 |
|
| 307 |
+
π Project Structure
|
| 308 |
+
|
| 309 |
+
stock-predictor/
|
| 310 |
+
β
|
| 311 |
+
βββ app.py
|
| 312 |
+
βββ model.py
|
| 313 |
+
βββ requirements.txt
|
| 314 |
+
βββ README.md
|
| 315 |
+
βββ .env.example
|
| 316 |
+
βββ .gitignore
|
| 317 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 318 |
|
| 319 |
---
|
| 320 |
|
| 321 |
+
π License
|
| 322 |
+
|
| 323 |
+
MIT License
|
| 324 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 325 |
|
| 326 |
---
|
| 327 |
|
| 328 |
+
β€οΈ Built With
|
| 329 |
+
|
| 330 |
+
Gradio
|
| 331 |
+
|
| 332 |
+
PyTorch
|
| 333 |
+
|
| 334 |
+
yfinance
|
| 335 |
+
|
| 336 |
+
Finnhub API
|
| 337 |
|
| 338 |
+
Python
|