NSE/BSE Hybrid Trader
A decoupled trading intelligence and execution skill for Indian equities and derivatives. The LLM performs
probabilistic technical and market-structure reasoning (nse-trading-skills synthesis), while deterministic Python
scripts enforce INR sizing, broker-accurate brokerage & Indian statutory tax math, 10,000-path Monte Carlo
simulation, and multi-broker paper/live execution gating (day-trader-skill architecture).
Supported Indian Brokers
Select any broker via --broker <name> (or set "default_broker" in
trading_rules.json):
angel_one— Angel One SmartAPI (--broker angel_one, default)zerodha— Zerodha Kite Connect v3 (--broker zerodha/ aliaskite)upstox— Upstox API v3 (--broker upstox)dhan— DhanHQ API v2 (--broker dhan)fyers— Fyers API v3 (--broker fyers)groww— Groww Trading API v1 (--broker groww)kotak_neo— Kotak Neo Trade API (--broker kotak_neo/ aliaskotak)icici_breeze— ICICI Direct Breeze API v1 (--broker icici_breeze/ aliasbreeze)shoonya— Finvasia Shoonya Noren API (--broker shoonya/ aliasfinvasia)
Inspect fee profiles, endpoints, and required .env keys anytime with:
python .agents/skills/nse-bse-hybrid-trader/scripts/broker_bridge.py brokers
Configuration & References
- Defaults, broker fee profiles & tax schedule: trading_rules.json
- NSE/BSE holiday calendar: nse_holidays.json
- Technical frameworks (3-Screen MTF, Confluence 0-6, RSI Divergence, Fibonacci, Hybrid Trailing): technical_frameworks.md
- Indian regulatory rules & multi-broker API/product matrix: indian_market_rules.md
Core 5-Step Operational Pipeline
Never rely on mental math for position sizing, tax drag, or probability estimation. Run this sequence from
.agents/skills/nse-bse-hybrid-trader/ (or pass the script paths from workspace root):
Step 1 & 2: Indian Market Structure & Multi-Timeframe Confluence
Run nse_data_loader.py to fetch live NSE/BSE 5m, 1d, and 1wk data and compute EMA
20/50/200, PDH/PDL/PDC, 15m Opening Range (ORH/ORL), Anchored Intraday VWAP, RSI(14) + divergences, MACD, ADX,
Bollinger Bands, ATR(14), Fibonacci retracements/extensions, RVOL, and a 0-6 Confluence Score:
python .agents/skills/nse-bse-hybrid-trader/scripts/nse_data_loader.py --symbol "<TICKER>" --json
Apply the guardrails in indian_market_rules.md and frameworks in technical_frameworks.md:
- IST Timing: Observe only during
09:00-09:15(pre-open) and09:15-09:30(Opening Range). Primary intraday execution runs09:30-14:30 IST. Block new intraday entries after14:30 IST; flatten open intraday positions by15:10 IST. - Regulatory Checks: Verify circuit bands (
2%/5%/10%/20%), SEBIASM/GSMstatus, NSEF&O Ban(>95% MWPL), and expiry-day pin/gamma risk. Pass--fno-ban,--asm-gsm,--circuit-band, or--delivery-pctwhen known. - Coordinates: Establish concrete
entry, structuralstop_loss(invalidation + ATR buffer, rounded toRs. 0.05ticks),target_1(>= 1.5 net R:R), andtarget_2. Skip setups scoring< 3/6on confluence.
Step 3: Intraday / Swing Time Machine (nse_timemachine.py)
Test the trade coordinates against 10,000 bootstrapped paths drawn from the ticker's recent 60-day 5m intraday
sessions (truncated strictly at 15:15 IST, conservative stop-first check, 1-tick slippage) or 2-year daily pool
(--mode SWING), plus historical 15m ORB replay (pass --broker <BROKER> for broker-specific fee drag):
python .agents/skills/nse-bse-hybrid-trader/scripts/nse_timemachine.py --symbol "<TICKER>.NS" --entry <ENTRY> --stop <STOP> --target <TARGET_1> --mode <INTRADAY|SWING> --broker <BROKER> --write --json
- Gate Requirement: Require positive tax-adjusted Expectancy (
avg_net_r > 0) plus clearing the active probability threshold in trading_rules.json:r_breakeven(default):target_first_resolved_pct >= (1 + tax_drag_r) / (1 + R)— realistic R-scaled edge after Indian charges.strict_55(override via--gate-mode strict_55):target_first_resolved_pct >= 55%— ultra-selective high-win-rate filter.- Both thresholds are always reported; if the active gate returns
NO-TRADE, downgrade the setup immediately.
Step 4: Deterministic Risk, Broker Fee & Tax Gate (indian_risk_gate.py)
Compute exact INR share/lot sizing, broker-specific brokerage (e.g., zero delivery fee on Zerodha/Dhan/Shoonya vs Rs. 10/order on Kotak Neo vs percentage/capped plans on Angel One/Groww/ICICI Breeze), statutory friction (STT 2026 rates, NSE Transaction Fee, SEBI Fee, Stamp Duty, DP charge, 18% GST), and verify all hard circuit breakers:
python .agents/skills/nse-bse-hybrid-trader/scripts/indian_risk_gate.py --broker <BROKER> --symbol "<TICKER>" --capital <CAPITAL_INR> --risk-pct <RISK_PCT> --entry <ENTRY> --stop <STOP> --target <TARGET_1> --segment <EQ_INTRADAY|EQ_DELIVERY|FNO_FUT|FNO_OPT> --timemachine-json .agents/skills/nse-bse-hybrid-trader/state/timemachine_result.json --write --json
- Hard Circuit Breakers: Max risk/trade
1.0%default (2.0%hard ceiling), tax-inclusive sizing, min net R:R>= 1.5, max daily drawdown3.0%(auto-checked against SQLite paper ledger), exact whole-share / F&O lot rounding, IST window lock, and circuit/ban checks. - Never override a
BLOCKverdict.
Step 5: Multi-Broker Order Staging & Paper/Live Dispatch (broker_bridge.py)
Only after Steps 3 and 4 return PASS:
-
(Optional, once daily per broker) Sync instrument master to local SQLite (
<2mssymbol/token/lot-size lookup — supports.json,.json.gz, and.csv):python .agents/skills/nse-bse-hybrid-trader/scripts/broker_bridge.py sync-scrip --broker <BROKER>(Pass
--offline <path>for custom/exported CSV or JSON masters, e.g. Kotak Neo / ICICI Breeze / Shoonya.) -
Paper Ledger (Default): Stage with verified risk fingerprint, broker-native payload, and simulated
Rs. 0.05tick slippage:python .agents/skills/nse-bse-hybrid-trader/scripts/broker_bridge.py stage --broker <BROKER> --symbol "<TICKER>" --segment <SEGMENT> --entry <ENTRY> --stop <STOP> --target <TARGET_1> --risk-json .agents/skills/nse-bse-hybrid-trader/state/risk_verdict.json --paper -
Live Multi-Broker Dispatch (
--live): Requires open IST execution window, resolved token (forangel_one,upstox,dhan, or any F&O contract), broker credentials in.env(checkbrokerssubcommand), and explicit confirmation passing--live --confirm "CONFIRM LIVE".- smartapi_bridge.py remains a full backward-compatible alias defaulting to
angel_one.
- smartapi_bridge.py remains a full backward-compatible alias defaulting to
Required Output Format
Always present final trade analyses in this 4-block structure:
- Market & Regulatory Context: Ticker, Broker, Segment, IST Phase, Circuit/ASM/F&O Ban status, HTF Bias, RVOL & Delivery % notes.
- Technical Setup Matrix: Entry, Stop-Loss, Target 1, Target 2 (Rs. 0.05 tick aligned), Confluence Score (
X/6), and exact triggers (VWAP, 15m ORH/ORL, Fib pocket, RSI Divergence, PDH/PDL). - Time Machine & Tax-Adjusted Risk Gate: Position Size (Shares/Lots), Margin Required, Broker Fee + Statutory
Charges & Breakeven Move (INR), Net R:R after taxes, Monte Carlo Target-First % & Net EV, and Gate Verdict (
PASS/BLOCK). - Actionable Execution Ticket: Ready-to-run
broker_bridge.pyCLI command and broker-native JSON/form payload.
What It Never Does
- Never places a live order automatically or from a scheduled/background run (
--paperis always the default). - Never overrides a
BLOCKverdict fromindian_risk_gate.pyor aNO-TRADEverdict fromnse_timemachine.py. - Never asks for, stores, or echoes broker API keys, MPINs, or TOTP secrets in chat (keys stay in local
.env). - Never relies on mental math for INR position sizing, statutory taxes, or win-rate estimation.
- Never treats a historical Time Machine simulation or stop-loss level as a guaranteed fill or prediction.
Safety, Code Review & Risk Disclaimer
- Trade at your own risk — author is not responsible: Educational and automation tooling only, NOT SEBI-registered investment, financial, or tax advice. You assume 100% responsibility for any trades, bugs, API errors, slippage, circuit freezes, or financial losses.
- Review every file before running: Inspect
config/trading_rules.json(brokerage/STT/GST rates),config/nse_holidays.json(exchange holidays), andscripts/broker_bridge.pybefore live execution. Note that_strip_attached_fields()stripsattached_stoploss_triggerandattached_target_priceon non-ROBO/non-BO live orders, so traders using non-bracket order modes must place and verify separate stop-loss/target/GTT orders on their broker terminal. - Unofficial data disclaimer: Built-in live candles use Yahoo Finance's free unofficial chart endpoint (5m/1d/1wk), which can lag, rate-limit, or miss corporate actions. Verify live quotes directly with your broker before acting.