Skip to content

Store (Developer Guide)

What It Does

The Store orchestrates REST and WS adapters, manages lifecycle state, exposes history helpers, and routes order WS messages to the owning broker.

Why It Exists

Centralizing adapter lifecycle and routing makes startup, shutdown, and recovery deterministic. It avoids duplicate sessions and inconsistent state across strategies.

Config Dependencies

  • config/cache.yaml (required for history)
  • config/state.yaml (required for broker state)
  • Resolver env vars (FYERS_STORE_ROOT, FYERS_STATE_YAML, etc)

With Backtrader

Use one Store instance and share it across Broker and DataFeed.

Without Backtrader

Use Store directly for: - get_history(...) - subscribe_market(...) - drain_market_messages(...) - orderbook()/positions()/funds()

Limitations

  • History requires a cache path.
  • WS adapters must be explicitly provided for live data.

Scenario Example

Scenario: You want a REST-only history fetch in a script. - Create a Store with only a REST adapter. - Call store.start(start_market_ws=False, start_order_ws=False) and then get_history(...).