{"slug": "building-a-production-ml-trading-dashboard-with-the-dhan-api", "title": "Building a Production ML Trading Dashboard with the Dhan API", "summary": "A developer detailed the integration of machine learning models with live broker data via the Dhan API for a production trading dashboard, focusing on NIFTY options. The system uses XGBoost on 15-minute bars and emphasizes separating inference from execution, with paper trading first. The developer reported 60.5% top-decile accuracy but unprofitable fixed stop-loss backtests, highlighting the importance of honest research status.", "body_md": "Real integration notes for wiring NIFTY ML models to live broker data via Dhan. Research/\n\npaper-trading context — not a live-trading recommendation.\n\nDhan's API exposes direct option-chain access — exactly what an options-ML system needs:\n\n`POST /optionchain`\n\n— full chain for an underlying`POST /optionchain/expirylist`\n\n— available expiries`security_id`\n\n, `last_price`\n\n, `volume`\n\n, `oi`\n\n, `previous_oi`\n\n, `implied_volatility`\n\n,\n`top_bid_price`\n\n, `top_ask_price`\n\n, and greeks (delta/theta/gamma/vega)Security IDs are stable: **NIFTY = 13 (IDX_I)**, **BANKNIFTY = 10001 (IDX_I)**.\n\nA research dashboard pulls live chain + underlying, runs the trained XGBoost model on each\n\nnew 15-minute bar, and displays:\n\nKeep the **inference path separate from the execution path**. The dashboard shows; a\n\npermissioned, human-approved module places orders.\n\nThe `DhanLiveTrader`\n\npattern: load the model, predict on each new bar, place long orders with\n\nconfigurable SL/TP (default 1.0 ATR SL, 2.0 ATR TP), and **run in paper mode first**. Only\n\nafter stable out-of-sample + paper evidence should any execution module even be considered.\n\n```\n{\n  \"client_id\": \"YOUR_DHAN_CLIENT_ID\",\n  \"access_token\": \"YOUR_DHAN_ACCESS_TOKEN\",\n  \"is_paper_trade\": true,\n  \"nifty_symbol\": \"NIFTY\",\n  \"quantity\": 50,\n  \"max_trades_per_day\": 3,\n  \"sl_atr_mult\": 1.0,\n  \"tp_atr_mult\": 2.0\n}\n```\n\nA known footgun: using a Stop-Loss *Limit* (SL-L) order with `price = sl − 0.05`\n\nmeans it\n\nwon't fill if price crashes through the stop. Prefer SL-Market for the protective stop.\n\nExecution quality is its own research topic — don't bolt it on at the end.\n\nThe ML side of this stack showed real directional skill (60.5% top-decile accuracy) but the\n\nfixed-SL backtest was still unprofitable (PF 0.53). A dashboard that displays an honest\n\n\"RESEARCH / PAPER\" status is worth more than one that hides the gap.\n\n*Research only. Not investment advice. SEBI/compliance is a separate, required topic before live trading.*", "url": "https://wpnews.pro/news/building-a-production-ml-trading-dashboard-with-the-dhan-api", "canonical_source": "https://dev.to/shaktitiwari/building-a-production-ml-trading-dashboard-with-the-dhan-api-5cih", "published_at": "2026-08-19 06:55:37+00:00", "updated_at": "2026-08-19 07:12:23.408203+00:00", "lang": "en", "topics": ["machine-learning", "developer-tools"], "entities": ["Dhan", "NIFTY", "BANKNIFTY", "XGBoost"], "alternates": {"html": "https://wpnews.pro/news/building-a-production-ml-trading-dashboard-with-the-dhan-api", "markdown": "https://wpnews.pro/news/building-a-production-ml-trading-dashboard-with-the-dhan-api.md", "text": "https://wpnews.pro/news/building-a-production-ml-trading-dashboard-with-the-dhan-api.txt", "jsonld": "https://wpnews.pro/news/building-a-production-ml-trading-dashboard-with-the-dhan-api.jsonld"}}