Store (src/fyers_store/store.py)
The Store is the central lifecycle manager. It owns adapters and persistence wiring, and it provides poll-friendly helpers to the Backtrader Broker/DataFeed.
Key Responsibilities
The Store starts and stops adapters, provides DB-first historical lookups, exposes queue drains for polling loops, and routes order WebSocket notifications to the correct broker in multi-strategy mode.
flowchart TD
STORE["FyersStore<br/>(store.py)"]
REST["RestAdapter<br/>(adapters/interfaces.py)"]
DATA_WS["Market WsAdapter<br/>(adapters/interfaces.py)"]
ORDER_WS["Order WsAdapter<br/>(adapters/interfaces.py)"]
CACHE["HistoricalCache<br/>(persistence/cache.py)"]
FAIL_CACHE["Missing cache path<br/>fail-fast"]
FAIL_AUTH["AuthError<br/>fail-fast"]
STORE --> REST
STORE --> DATA_WS
STORE --> ORDER_WS
STORE --> CACHE
STORE -->|"get_history(symbol,res,start,end)"| CACHE
CACHE -->|"get_bars + detect_gaps"| STORE
STORE -->|"REST get_history for gaps"| REST
STORE -->|"upsert_bars + watermark"| CACHE
STORE -.missing cache config.-> FAIL_CACHE
REST -.auth failure.-> FAIL_AUTH
Order Message Routing (Multi-Strategy)
flowchart TD
ORDER_WS_QUEUE["Order WS queue"]
STORE["FyersStore"]
OWNER_MAP["order_id -> broker_id map"]
BROKER_A["Broker A"]
BROKER_B["Broker B"]
ORDER_WS_QUEUE --> STORE
STORE --> OWNER_MAP
STORE -->|"route messages"| BROKER_A
STORE -->|"route messages"| BROKER_B