Feat: Adding support for equity markets in india#305
Conversation
|
Thanks for the PR — we’ve seen it and will review as soon as we can. For market-support changes, the main things we’ll check are symbol conventions, loader/data-source behavior, deterministic tests, and whether the first version stays narrowly scoped enough to maintain. |
|
Merged to main as 735d396. Review notes: the engine follows the BaseEngine contract cleanly (all 4 abstract methods, cost stack fully config-driven with documented defaults, GST correctly compounded on brokerage+exchange+SEBI, STT bilateral, stamp duty buy-only), the india_broker bridge is strictly read-only and last in the fallback chain, and the mandate wiring only strengthens classification — Dhan/Shoonya remain paper + read-only per our runtime-discriminator rule, exactly as you scoped it. The ~255 factor edits are pure equity_in universe appends with zero behavior change for existing markets — verified by sampling. Two things resolved maintainer-side while landing: the loaders/registry.py conflict with the QVeris entries (keep-both), and full-suite validation you couldn't run in your sandbox — 5020 passed, 0 regressions (46 new India tests green). One caveat logged for follow-up, as you flagged in the PR body: the STT/SEBI/stamp rates are point-in-time defaults and should be re-checked against a current SEBI/NSE fee schedule periodically; they're config-overridable in the meantime. Thanks for a carefully scoped market addition — this is the template for how to do one. |
Summary
equity_infactor universe → live/paper broker + mandate wiring.IndiaEquityEnginemodeling T+1 delivery, no overnight shorts (allow_shortopt-in), configurable circuit bands, 1-share lots, and the STT / stamp-duty / exchange / SEBI / GST cost stack..NS/.BOsymbols to Yahoo (native NSE/BSE coverage), with yfinance and an opt-in Shoonya/Dhan broker data bridge as fallbacks.Why
Indian symbols previously had zero research support: they silently misrouted to China infrastructure (
tushareloader +ChinaAEngine), producing wrong fills and costs. India was the only market withlive broker connectors (Shoonya/Dhan) but no data/backtest/factor path. This wires the broken middle so the existing strategies, factors, and metrics work on NSE/BSE.
Changes
.NS/.BOrouting inmarket_data.py+_market_hooks.py(newindia_equitymarket type); extendedyahoo_loader/yahoo_clientandyfinance_loaderto accept the suffixes;india_equityfallback chain inregistry.py;runner.pysource map. Regexes allow&/-(e.g.M&M.NS,BAJAJ-AUTO.NS).backtest/engines/india_equity.py; wired intocomposite.pyandrunner.pysingle-market routing (precedes source-based routing so India'syahoosource can't fall through to thecrypto default).
equity_into theUniverseliteral andMarketenum (vwap uses the typical-price branch — India bars carry raw price/volume, no Tushare scaling); tagged all 101 Alpha101 and 154QLib158 factors for
equity_in. GTJA191 left China-only (Tushare-scale math).AssetClass.IN_EQUITYand wired it into the mandate-enforcement loader chain; newbacktest/loaders/india_broker_loader.pybridges Shoonya/Dhanget_historical_barsinto thebacktest layer (opt-in
india_brokersource, unavailable without broker creds). Live order placement stays structurally disabled (those brokers expose no paper/live switch).SKILL.mdupdated (8 engines, 19 sources, India symbol convention, factor coverage, paper/read-only-live limitation).Test Plan
pytest --ignore=agent/tests/e2e_backtest --tb=short -q)test_india_equity_engine.py,test_india_backtest_smoke.py,test_india_mandate.py,test_india_broker_loader.py,tests/factors/test_india_universe.py, plus India cases intest_market_data.py,test_market_detection.py,test_yahoo_loader.py,test_registry.pyequity_in; representative Alpha101/QLib158 factors compute on a synthetic NSE panel; end-to-end India backtest emits metricstools/ci_grep_gates.shall gates pass;ruff checkclean across the contributionfootprint
Checklist
src/agent/,src/session/,src/providers/) without prior discussionruff check(the configured gate) passes on all new/changed files; public signatures type-annotated; Google-style docstringsSKILL.mdReviewer notes
pytest --ignore=agent/tests/e2e_backtestrun (the sandbox lacks some optional deps, e.g.fastmcp). Please let CI confirm the full suite.knobs.
india_brokerbridge returns a bounded window of recent bars (broker API limit) — use Yahoo for deep history.blackwas not run: the repo is not black-conformant (untouched core files failblack -l120), so formatting only these files would diverge from house style. Files conform to the configuredruffgateinstead.