Ngat Brokers
Overview
Own the boundary between internal engine components and Zerodha endpoints. Use this skill for reliability and security improvements in broker-facing logic.
Submodules
brokers/utils.py: TOTP generation, login, cache read/write (.keystore.json), token validation.brokers/kite_trade.py:ZerodhaBrokerREST wrapper and retry behavior.brokers/zerodha.py: historical backfill and realtime sync into RedisTimeSeries.
Pros
- Keep provider-specific behavior isolated from core strategy code.
- Reuse cached
enctokenand refresh on retriable auth failures. - Backfill and realtime sync share one candle ingestion path.
Cons
- Keep direct
os.systeminstalls in import path (kite_trade.py) which is unsafe in production. - Keep secret token cache in project root without encryption.
- Keep historical loops broad and potentially expensive when partitions are unset.
Caveats
- Never log secrets;
printstatements currently risk leaking operational internals. - Treat retry login and request replay as non-idempotent for order endpoints.
- Treat timeframe mapping carefully (
dayvs intraday intervals) to avoid API errors. - Handle Zerodha API limits explicitly; current code relies on chunking but not adaptive throttling.
Forward Features
- Add secure credential management (OS keychain or vault) for token cache.
- Add idempotency keys and order state reconciliation layer.
- Add broker abstraction coverage for alternate providers beyond Zerodha.