A multi-market, multi-strategy terminal-based trading analysis platform that fuses institutional Smart Money Concepts (SMC) with DeepSeek AI to generate high-confidence trade signals across Indian equities, crypto, and forex β all from a single CLI command.
Retail traders rely on lagging indicators (RSI, MACD, moving averages) that institutions exploit as liquidity traps. This platform shifts the paradigm by implementing the "Guardeeer SMC Last Defense Liquidity Model" β a professional institutional framework that tracks where smart money is accumulating and where retail stops are being hunted, giving the user the same structural edge that institutions use.
| Metric | Description | Default |
|---|---|---|
| RSI (14) | Relative Strength Index β overbought > 70, oversold < 30 | 14-period |
| EMA Short (9) | Fast exponential moving average for crossover detection | 9-period |
| EMA Long (21) | Slow exponential moving average for trend confirmation | 21-period |
| Trend Strength | Composite score (1β10) based on EMA crossover, RSI, and price position | Dynamic |
| Support Levels | Pivot-point and rolling-swing derived price floors | Top 3 levels |
| Resistance Levels | Pivot-point and rolling-swing derived price ceilings | Top 3 levels |
| Confidence Bar | Visual 10-segment bar (ββββββββββ) per signal | 1β10 |
| SMC Metric | Description |
|---|---|
| Swing Highs / Swing Lows | Candles with higher/lower extremes than 2 neighbors on each side |
| ITH (Institutional Term High) | Most recent untaken major swing high |
| ITL (Institutional Term Low) | Most recent untaken major swing low |
| Order Blocks (OB) | Last opposing candle before a 3+ candle directional impulse β unmitigated only |
| Fair Value Gaps (FVG) | 3-candle patterns where wicks don't overlap β institutional imbalance zones |
| Liquidity Sweep | Price breaks a swing high/low then closes back inside β stop-loss hunt detected |
| POI (Point of Interest) | Confluence of unmitigated OB + overlapping FVG on the structural leg |
| Market Structure | Bullish (HH/HL) or Bearish (LH/LL) determined by sequential swing points |
| Risk-Reward Ratio (R:R) | Minimum 2:1 filter β calculated from OB entry to opposing structural target |
| OB Midpoint Entry | Precision entry at 50% of the Order Block zone |
| Buffer-Based Stop Loss | Structural invalidation Β± 0.5% buffer on OB boundary |
| Metric | Description |
|---|---|
| Put-Call Ratio (PCR) | Total Put OI Γ· Total Call OI β sentiment gauge |
| OTM % | Distance of strike from underlying price in percentage |
| Option Premium | Live last-traded price for each strike |
| Open Interest (OI) | Number of outstanding contracts per strike |
| Call Writing Opportunities | Top 5 OTM calls ranked by premium |
| Put Writing Opportunities | Top 5 OTM puts ranked by premium |
Instead of relying on RSI crossovers that fire after the move, the SMC engine detects institutional accumulation zones before price explodes. The rule-based signal engine removes human bias β every BUY/SELL has a defined entry, stop, target, confidence score, and rationale.
The liquidity sweep detector identifies when price intentionally pierces a swing high/low to trigger retail stop-losses, then reverses β a classic institutional footprint. The platform flags these sweeps and waits for the 1H "last defense" Order Block before generating an entry, ensuring the user piggybacks the smart money reversal, not the fake-out.
Built for traders operating across asset classes:
- Indian Stocks β Upstox API (NSE/BSE) with OAuth 2.0 full access
- Crypto β Binance public API (BTC, ETH, and all USDT pairs)
- Forex β Yahoo Finance fallback
No need to switch between 3 different platforms. One CLI command covers all.
DeepSeek AI analyzes the complete technical picture (trend, RSI, support/resistance, options chain, PCR) and outputs a structured 5-section trading recommendation:
- π Market Overview
- π Technical Analysis
- π° Options Strategy (specific strikes)
- β‘ Action Plan with confidence levels
- π‘οΈ Risk Management (stop loss, position sizing)
The platform automatically identifies the best OTM call/put writing opportunities by analyzing the live option chain for premium-to-distance ratios. It ranks strikes by premium yield while filtering out deep ITM noise β turning complex options data into actionable SELL_CALL / SELL_PUT signals.
A single docker build && docker run deploys the entire platform anywhere β cloud VMs, on-prem servers, or CI/CD pipelines. Non-root user execution and multi-stage builds ensure security and minimal image size.
βββββββββββββββββββββββββββββββββββββββ
β User (CLI) β
ββββββββββββββββ¬βββββββββββββββββββββββ
β
βββββββββββββΌββββββββββββ
β main.py β
β (Rich CLI + Argparse) β
βββββββββββββ¬ββββββββββββ
β
ββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββ
β β β
ββββββββββββΌβββββββββββ βββββββββββΌββββββββββ βββββββββββββΌββββββββββββ
β DecisionEngine β β TechnicalAnalyzer β β AIAdvisor β
β (Signal Generator) β β (S/R, EMA, RSI) β β (DeepSeek API) β
ββββββββββββ¬βββββββββββ βββββββββββ¬ββββββββββ βββββββββββββββββββββββββ
β β
ββββββββββββΌβββββββββββ βββββββββββΌββββββββββ
β smc_strategy.py β β data_fetcher.py β
β (OB, FVG, Sweeps, β β (Upstox API v2) β
β ITH/ITL Detection) β βββββββββββββββββββββ
βββββββββββββββββββββββ
β
ββββββββββββΌβββββββββββ
β crypto_fetcher.py β
β (Binance API) β
βββββββββββββββββββββββ
upstox-analytics/
βββ main.py # CLI entry point + interactive shell
βββ config.py # Environment config + token management
βββ data_fetcher.py # Upstox API v2 (historical, quotes, options)
βββ crypto_fetcher.py # Binance public API (crypto OHLCV)
βββ analyzer.py # Traditional TA (S/R, EMA, RSI, options)
βββ smc_strategy.py # SMC engine (OB, FVG, sweeps, ITH/ITL)
βββ ai_advisor.py # DeepSeek AI chat completions
βββ decision.py # Unified signal generator (SMC + default)
βββ requirements.txt # Python dependencies
βββ Dockerfile # Multi-stage container build
βββ .env # API keys (gitignored)
βββ strategy1.txt # Guardeer 4H-1H OB Sweep Strategy
βββ strategy2.txt # Guardeer "Last Defense" Liquidity Model
βββ SMC_Three_Strategies_System.txt # 3-strategy complete system
Unlike most trading bots that use a single strategy, this platform implements two independent signal engines that can be toggled at runtime:
--defaultflag β Traditional RSI/EMA engine- Default mode β SMC institutional engine
Both engines feed into the same DecisionEngine β TradingSignal pipeline, allowing direct A/B comparison of strategy performance.
The SMC implementation is not a generic "ICT concepts" wrapper. It faithfully implements the specific Guardeer 4H-1H Institutional Order Block Sweep Strategy documented in strategy1.txt and strategy2.txt:
- True 2-candle-side swing point detection (not just fractals)
- Untaken ITH/ITL tracking β an ITH is only valid if no subsequent candle's high exceeded it
- Impulse-based Order Block identification β requires 3+ consecutive directional candles before the opposing OB qualifies
- Liquidity sweep confirmation β price must break the swing level AND close back inside
- OB midpoint entries β precision execution at 50% of the zone
- Buffer-based structural stops β Β±0.5% on OB boundaries, not arbitrary ATR multiples
The data pipeline is resilient by design:
Upstox OAuth Token (full access)
β
βΌ
Upstox API v2 βββ Primary source (stocks, indices, options)
β
β Failure?
βΌ
Yahoo Finance βββ Fallback (no auth, always available)
For crypto, Binance's public API is used directly β no API key needed. This architecture ensures the platform never fails due to a single API outage or rate limit.
Every API call is wrapped in a caching layer with endpoint-specific expiry:
- Candle data: 60s cache (rate-limit protection)
- Options chain: 30s cache
- Live quotes: 5s cache
- Crypto prices: 10s cache
This prevents redundant API calls when analyzing the same symbol in quick succession and respects the Upstox rate limits.
The AI advisor is integrated as a structured analysis layer, not a generic chat interface:
- System prompt enforces a 5-section structured output (Overview β TA β Options β Action β Risk)
- Prompt builder programmatically constructs the analysis context from all computed metrics
- Temperature is set to 0.7 for balanced creativity vs. factual precision
- 30-second timeout with graceful degradation (shows error panel, does not crash)
The --login command spins up a temporary HTTP server on localhost:8080, opens the browser for Upstox authorization, captures the OAuth code, exchanges it for an access token, and writes it to .env β all automated. No manual copy-paste of tokens.
Signals are rendered with:
- Color-coded tables (green=BUY, red=SELL, yellow=HOLD)
- Confidence bars using block characters (
ββββββββββfor 7/10) - Nested panels for AI advice
- Real-time progress spinners during analysis
The Dockerfile uses a builder stage for dependency installation (cache-friendly) and a slim runtime stage with:
- Dedicated
analystuser (UID 1001) β no root execution PYTHONUNBUFFERED=1for real-time log output- No build tools in the final image (minimal attack surface)
- Python 3.12+
- Upstox Developer Account (for stocks/indices)
- DeepSeek API Key (for AI analysis)
# Clone the repository
git clone https://github.com/Aditya365x/stockAnalyser.git
cd stockAnalyser
# Install dependencies
pip install -r requirements.txt
# Configure API keys
cp .env.example .env
# Edit .env with your keys:
# UPSTOX_ANALYTICS_TOKEN=your-token
# DEEPSEEK_API_KEY=your-deepseek-keypython main.py --login
# Opens browser β login to Upstox β token auto-saved to .env# Analyze a stock with SMC strategy
python main.py RELIANCE
# Analyze with options chain
python main.py RELIANCE --options
# Analyze crypto (Binance)
python main.py BTCUSDT --crypto
# Analyze forex (Yahoo Finance)
python main.py EURUSD --forex
# Use traditional RSI/EMA strategy instead of SMC
python main.py RELIANCE --default
# Skip AI analysis (offline mode)
python main.py RELIANCE --no-ai
# Interactive shell mode
python main.py
> RELIANCE
> crypto ETHUSDT
> forex GBPUSD
> quit# Build the image
docker build -t upstox-analytics .
# Run with your .env file
docker run --rm -it --env-file .env upstox-analytics RELIANCE
# Interactive mode
docker run --rm -it --env-file .env upstox-analyticsββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Market Analysis β
β RELIANCE - βΉ2,847.30 β
β Analyzed: 2026-05-29 19:12:30 β
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββ
β Technical Indicators β
β Indicator β Value β
β Trend β BULLISH β
β Strength β 7/10 β
β RSI β 56.32 β
β EMA Short β βΉ2,834.50 β
β EMA Long β βΉ2,812.10 β
β Signals β ABOVE_LONG_EMA β
βββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββ
β Trading Signals β
β Signal β Confidence β Entry β Target β SL β
β BUY β 7/10 β 2847.30 β 2910.00 β .. β
β β ββββββββββ β β β β
ββββββββββββββββββββββββββββββββββββββββββββββββ
BUY: Bullish structure (HH/HL) | Swept level: 2812.5
ββ DeepSeek Analysis βββββββββββββββββββββββββββββ
β π Market Overview: RELIANCE shows bullish β
β momentum with price above both EMAs... β
β β
β π Technical Analysis: Strong uptrend with β
β RSI at 56 showing room to run... β
β β
β π° Options Strategy: Sell 2950 CE at βΉ18.50 β
β (3.6% OTM, good risk-reward)... β
β β
β β‘ Action Plan: BUY with 7/10 confidence. β
β Entry at CMP βΉ2847, target βΉ2910... β
β β
β π‘οΈ Risk Management: Stop loss at βΉ2810... β
ββββββββββββββββββββββββββββββββββββββββββββββββββ
- All API keys stored in
.env(gitignored) - Docker runs as non-root
analystuser (UID 1001) - OAuth tokens are never committed β auto-generated via
--login - Cached API responses are in-memory only (no disk persistence)
PYTHONUNBUFFERED=1ensures logs are not buffered in container environments
This tool is for educational and informational purposes only. It does not constitute financial advice. Trading stocks, options, crypto, and forex involves substantial risk of loss. Past performance is not indicative of future results. Always conduct your own research and consult a licensed financial advisor before making trading decisions.
MIT License β See LICENSE file for details.
- SMC Strategy β Based on Guardeer's "How To CAPTURE BIG TRADE WITH SMC" methodology
- Market Data β Upstox API, Binance API, Yahoo Finance
- AI Engine β DeepSeek
- Terminal UI β Rich
Built with β€οΈ for traders who think like institutions, not retail.