tastyware / tastytrade

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

pulling historical ohlc? #108

Closed fritol closed 1 month ago

fritol commented 7 months ago

Is there any way to pull historical data? I mean how does their web UI pull chart data?

Quenos commented 7 months ago

This can be done with the DXLinkStreamer

async with DXLinkStreamer(session) as streamer:
    subs = ['SPY', 'AAPL']
    await streamer.subscribe_candle(subs, '1d', start_date)
    candle = await streamer.get_event(EventType.CANDLE)
Graeme22 commented 7 months ago

OHLC data is obtained through Candle events. See more here: https://tastyworks-api.readthedocs.io/en/latest/sessions.html#events https://tastyworks-api.readthedocs.io/en/latest/tastytrade.html#tastytrade.streamer.DXLinkStreamer.subscribe_candle

autsauce commented 5 months ago

This can be done with the DXLinkStreamer

async with DXLinkStreamer(session) as streamer:
    subs = ['SPY', 'AAPL']
    await streamer.subscribe_candle(subs, '1d', start_date)
    candle = await streamer.get_event(EventType.CANDLE)

Is this supposed to work with futures contracts as well?

Graeme22 commented 5 months ago

Yes, you'll need to use dxfeed notation for futures though: https://tastyworks-api.readthedocs.io/en/latest/dxfeed.html