tastyware / tastytrade

An unofficial Python SDK for Tastytrade!
MIT License
98 stars 33 forks source link

Endpoint for OI for entire chain? #143

Open joshuakoh7 opened 2 months ago

joshuakoh7 commented 2 months ago

Hi, is there a tastytrade endpoint to get OI for the entire chain instead of having to subscribe to summary for every option?

Graeme22 commented 2 months ago

There is not! You'll need to subscribe to candles or summary events for each individual option unfortunately.

joshuakoh7 commented 2 months ago

Was afraid of that. Such a terrible design since there's already an endpoint for fetching the entire chain and OI is static every 24 hours.

joshuakoh7 commented 2 months ago

Do you think you could add an input for choosing which fields to subscribe to in the future to only call for certain fields like OI? Napkin code:

    async def _channel_setup(self, event_type: EventType, event_fields: List[str] = ['eventSymbol']) -> None:
    ......
        if len(event_fields) > 1:
            message['acceptEventFields'] = event_fields
        else:
            if event_type == EventType.CANDLE:
                accept = dict_from_schema(Candle)
            elif event_type == EventType.GREEKS:
                accept = dict_from_schema(Greeks)
            elif event_type == EventType.PROFILE:
                accept = dict_from_schema(Profile)
            elif event_type == EventType.QUOTE:
                accept = dict_from_schema(Quote)
            elif event_type == EventType.SUMMARY:
                accept = dict_from_schema(Summary)
            elif event_type == EventType.THEO_PRICE:
                accept = dict_from_schema(TheoPrice)
            elif event_type == EventType.TIME_AND_SALE:
                accept = dict_from_schema(TimeAndSale)
            elif event_type == EventType.TRADE:
                accept = dict_from_schema(Trade)
            elif event_type == EventType.UNDERLYING:
                accept = dict_from_schema(Underlying)
            message['acceptEventFields'] = accept