client-python icon indicating copy to clipboard operation
client-python copied to clipboard

Add futures beta support

Open justinpolygon opened this issue 6 months ago • 1 comments

Adds futures REST and Websocket beta support.

REST support was straightforward but websocket support needed a small refactor around how events are processed. Added new parsing logic using MARKET_EVENT_MAP to address event type collisions between markets like stocks and futures. Previously, event types such as "A", "AM", "T", and "Q" were unique across markets. With the addition of futures, these types are now reused, creating ambiguity, and mapping to incorrect model structures. For example, an event with "ev": "T" could be an EquityTrade (stocks) or a FuturesTrade (futures), depending on the market.

The solution uses MARKET_EVENT_MAP, which maps each market to its specific event types and model classes. By leveraging the market context from the WebSocketClient, the parser can now accurately identify and process these events. This change ensures reliable data parsing as we expand to support more markets, while remaining backward-compatible for existing stock market clients.

justinpolygon avatar Jun 09 '25 07:06 justinpolygon

Thanks for catching all the @penelopus!

justinpolygon avatar Jun 09 '25 19:06 justinpolygon