Spaces:
Sleeping
Sleeping
File size: 5,080 Bytes
018b244 19a0482 4359352 018b244 e2bee6b cb756bf e2bee6b cb756bf e2bee6b cb756bf e2bee6b cb756bf e2bee6b cb756bf e2bee6b cb756bf e2bee6b cb756bf e2bee6b cb756bf e2bee6b cb756bf e2bee6b cb756bf e2bee6b cb756bf e2bee6b cb756bf e2bee6b cb756bf e2bee6b cb756bf e2bee6b cb756bf e2bee6b cb756bf e2bee6b cb756bf e2bee6b cb756bf e2bee6b cb756bf e2bee6b | 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | ---
title: StockSense AI
emoji: π
colorFrom: indigo
colorTo: purple
sdk: docker
app_port: 7860
short_description: AI trading engine for Indian markets (NSE/BSE)
---
# π StockSense-AI β Enterprise-Grade Trading Engine
> **StockSense-AI** is a multi-factor hybrid intelligence platform that blends Deep Learning, Intraday ML, and LLM reasoning to provide high-precision stock signals for the Indian market (NSE/BSE).
---
## π Vision & Pitch
*"StockSense AI doesn't just predict prices; it understands market context. By fusing **LSTM-based daily forecasting** with **XGBoost intraday signals**, **FinBERT sentiment analysis**, and **Gemini LLM reasoning**, we've built a decision engine that adapts to market regimes in real-time. Whether you're tracking 5-day trends or hunting for intraday breakouts, StockSense AI provides the confidence score and risk-mitigation strategy you need."*
---
## π Key Features
### π§ **The Hybrid Command Engine**
- **LSTM Neural Network**: 2-layer Deep Learning model trained on 2 years of daily data for 5-day price forecasting.
- **XGBoost Intraday Pipeline**: High-velocity ML model trained on 1-minute bars to capture micro-trends.
- **FinBERT Sentiment Analysis**: Advanced NLP scoring of real-time financial news and social sentiment.
- **Gemini LLM Reasoning**: Human-readable trade justifications and "why" analysis for every signal.
- **Factor Blending**: 5-factor weighted scoring (Technicals + Sentiment + LSTM + XGBoost + Market Context).
### π¦ **Paper Trading & Wallet Simulation**
- **Virtual Portfolio Management**: Track open positions, realized/unrealized P&L, and win rates.
- **Integrated Wallet**: Deposit and withdraw (Razorpay-style simulation) with full transaction history.
- **Account Performance Charting**: Visual snapshots of your portfolio growth over time.
### π‘οΈ **Advanced Risk Management**
- **Dynamic ATR-based Levels**: Stop-Loss and Take-Profit targets that adjust automatically to ticker volatility.
- **Adaptive Market Regimes**: System switches behavior across 4 states: *Bull Low-Vol, Bull High-Vol, Bear High-Vol, and Sideways*.
- **Risk-Based Position Sizing**: Automatic share calculation based on your "capital-at-risk" percentage.
- **Trailing Stop-Loss**: Intelligent profit-locking mechanism that follows the price as it rises.
### π **Glassmorphic Interactive UI**
- **Premium Aesthetics**: High-end translucent design system with vibrant neon accents.
- **Multi-Tab Dashboard**: Switch between **Charts**, **Unified Dashboard**, **Auto-Trade Engine**, and **Trading Portfolio**.
- **Real-Time Price Banner**: Live tracking of tickers with market-depth indicators.
- **High-Potential Scanner**: Real-time scanner for "Strong Buy" signals across Top 50 NSE stocks.
---
## ποΈ Architecture & Stack
```mermaid
graph LR
User((User)) -- "Ticker" --> API[FastAPI Gateway]
subgraph "Engine Layer"
API --> LSTM[Deep Learning: Daily Trends]
API --> XGB[XGBoost: Intraday Signals]
API --> NLP[FinBERT: News Sentiment]
API --> Gemini[LLM: Market Reasoning]
end
subgraph "Decision AI"
LSTM & XGB & NLP & Gemini --> Blender[Weighted Composite Blender]
Blender --> Regime[Regime/Volatility Filter]
end
subgraph "Execution Layer"
Regime --> Risk[ATR Risk Engine: SL/TP/Sizing]
Risk --> Sim[[Paper Trading Simulator]]
end
```
### **Tech Stack**
- **Backend**: Python 3.10+, FastAPI, Uvicorn, SQLAlchemy (SQLite).
- **ML/Science**: PyTorch (LSTM), XGBoost, Transformers (FinBERT), Scikit-learn, Pandas, yfinance.
- **Frontend**: Vanilla HTML5/JS (ES6+), Chart.js for visualization, Glassmorphic CSS Engine.
- **Reasoning**: Google Gemini 2.0 API.
---
## π§ Installation & Setup
### **1. Backend (The Brain)**
```bash
cd backend
python -m venv venv
# Windows
.\venv\Scripts\activate
# Linux/Mac
source venv/bin/activate
pip install -r requirements.txt
# Create a .env file with your GEMINI_API_KEY
uvicorn app:app --port 8000
```
### **2. Frontend (The Interface)**
Simply host the `frontend` directory using any local server:
```bash
cd frontend
python -m http.server 5500
```
Visit `http://localhost:5500`.
---
## π ML Pipeline Details
| Stage | Logic |
| :--- | :--- |
| **Data** | 1-min & Daily OHLCV via Yahoo Finance API. |
| **LSTM** | 60-bar lookback window, recursive 5-day out-of-sample forecast. |
| **XGBoost** | Feature-rich ensemble (RSI, MACD, BB, VWAP, Supertrend) for next-5-bar returns. |
| **Regime** | 4-state classification using India VIX and Sector Strength. |
| **Scoring** | Normal: 45% LSTM, 45% XGB, 10% Sent \| Volatile: 48.5% LSTM, 48.5% XGB, 3% Sent. |
---
## β οΈ Disclaimer
StockSense AI is for **educational and simulation purposes only**. This is a paper-trading platform. Algorithms can fail, and market data can be delayed. **Never use this tool for actual financial investments without consulting a certified advisor.**
---
## π License
Distributed under the **MIT License**. See `LICENSE` for more information.
|