Adapters (Developer Guide)
What They Do
Adapters translate between FYERS SDK calls and the Store/Broker/DataFeed expectations. REST adapters own auth and rate limits; WS adapters own reconnect and queue behavior.
Why They Exist
Separating transport from business logic makes the Broker and Store deterministic and easier to test.
Config Dependencies
- REST:
config/fyers_rest_limits.yaml - WS:
config/fyers_ws.yaml
With Backtrader
Adapters are usually hidden behind the Store/Broker/DataFeed, but you still configure them.
Without Backtrader
Adapters can be used directly: - REST for history, orderbook, positions, etc. - WS for raw message streaming into a queue.
Limitations
- REST adapter uses single-shot place_order to avoid duplicates.
- WS adapters rely on queue drains; unbounded queues can cause memory growth.
Scenario Example
Scenario: You want a custom WS consumer.
- Use FyersDataWsAdapter.get_queue() and drain in your own loop.
- Keep the adapter reconnect backoff enabled.