Operator Safety

Operator Safety

The safety snapshot is read-only. It exists to keep the operator’s view of the account consistent across /status, /safety, /positions, the hourly report, and the audit command. Scan-cycle reconciliation uses that snapshot separately to heal confirmed-flat and orphan state; it does not place broker orders.

Commands

CommandWhat it shows
/safetyOpen positions, total live P&L, per-strategy live P&L, portfolio Greeks, Greek limit status, kill switch, and balance state.
/broker_healthLatest Dhan token, market feed, option-chain, order, position, and margin API health with the current trading-mode downgrade.
/envelopeRisk envelope status, pause reason/until, drawdown counters, and loss-streak count.
/resume_envelope confirmClears an envelope pause and resets the loss-streak counter after operator review.
/statusBot state plus embedded safety summary.
/positionsEach open trade, its strategy tag, and the aggregate live P&L total. DC, DCS, and DCS_SKEW include live Greeks when LTP and spot data are available.
/riskStrategy-specific risk view for DC, DCS, DCS_SKEW, DDC, IC, and AI_MARKET.
/explain_signalLatest pass/fail reason for dc, dcs, dcs_skew/sdcs, ddc, or ic.
/audit_positionsRead-only broker-vs-tracker mismatch report.
/confirm_recon <tag>Acknowledge a pending quantity mismatch and unblock new entries for that strategy.
/golive_statusDRY_RUN / SHADOW / LIVE state plus current confidence summary for each strategy.
/confidence_report <strategy>15-trading-day win-rate breakdown used by the shadow gate.
/ai_promotion_reportAI_MARKET promotion-readiness report: verdict history, confidence-band performance, forecast score, AI cost, DDC with-AI comparison, and error log.
/shadow, /promote, /revertOperator-controlled go-live transitions.
Dashboard Go-Live panelBrowser view of each strategy state, confidence sample, and required margin via /api/go-live/status.
Dashboard AI Market promotion reportBrowser view of the same AI_MARKET promotion gate via /api/ai-market/promotion-report.
Dashboard Portfolio Greeks panelBrowser view of total Greeks, configured limits, breach status, and strategy-wise contribution via /api/safety/portfolio-greeks.
Dashboard Broker Health APIBrowser/API view of latest and recent persisted broker health samples via /api/broker/health.
Dashboard Risk Envelope panelBrowser view of envelope status, caps, and loss streak via /api/envelope/state.
Dashboard Reconciliation LogInline audit table for auto-removals, orphan adoptions, mismatch confirmations, and orphan alerts via /api/reconciliation/log.

Alert Vocabulary

ReasonTrigger
low_balanceBalance check fails or preflight keeps trading paused.
position_driftTracked flat legs, quantity mismatches, or broker orphans appear.
stale_tradeAn open trade stays active longer than the stale window.
duplicate_tradeTwo open trades share the same tag and need operator review.
Exact-leg entry rejectionA new DC-family candidate has incomplete/malformed option security IDs or exactly matches the complete option-leg set of an open position. Entry fails closed before simulation or broker orders.
MDC scale-in rejectionThe newest remaining MDC anchor has insufficient elapsed time/movement, is not OPEN, lacks live P&L/risk data, or is at/below the −10% anchor-loss limit.
broker_orphanBroker position exists but is not tracked locally.
go_live_margin_blockSHADOW/LIVE entry skipped because available balance is below strategy max margin plus 10% buffer.
portfolio_greeks_blockSHADOW/LIVE entry skipped because candidate Greeks would breach portfolio limits.
portfolio_greeks_would_blockDry-run entry would breach portfolio limits but is allowed because PORTFOLIO_BLOCK_DRY_RUN is false.
broker_health_degradedBroker health is DEGRADED, UNSTABLE, or DOWN; live-capital entries are downgraded or blocked.
risk_envelope_pausedRisk envelope is PAUSED or HALTED; existing positions are still monitored, but new scanner entries are skipped.

Broker Health Guard

BrokerHealthMonitor records a read-only health sample each scan cycle in broker_health_samples. It checks token presence, market-feed LTP, expiry/option-chain access, order-list access, position API access, and fund-limits access. The aggregate status controls new entries before strategy scanners run:

StatusRuntime effect
HEALTHYNormal DRY_RUN/SHADOW/LIVE go-live state applies.
DEGRADEDNew entries are allowed only as dry-run simulations.
UNSTABLENew entries are allowed only as dry-run simulations until health recovers.
DOWNNew entry scans are skipped after monitoring and reconciliation complete.

What The Snapshot Shows

open_count ← number of currently open trades live_pnl_total ← total unrealised P&L across open trades by_strategy.DC ← DC count + live P&L by_strategy.DCS ← DCS count + live P&L by_strategy.DCS_SKEW ← skew-aware DCS count + live P&L by_strategy.DDC ← directional diagonal count + live P&L by_strategy.IC ← iron condor count + live P&L by_strategy.AI_MARKET ← AI dry-run option count + live valuation when LTP is available portfolio_greeks.totals ← aggregate Δ/Γ/Θ/ν across open trades with stored Greek data portfolio_greeks.by_strategy ← strategy-wise Greek contribution portfolio_greeks.breaches ← configured limit breaches, if any kill_switch ← active or OK low_balance ← low balance or OK
Operational rule If the safety summary and the broker audit disagree, trust the broker audit first and inspect the trade state before taking action. Never use /confirm_recon to ignore a live quantity mismatch unless the broker position has been reviewed.