Closed Coding4Sec closed 5 months ago
Hi Rick! Sorry getting started hasn't been smooth sailing.
from tastytrade.instruments import get_option_chain from datetime import date chain = get_option_chain(session, 'SPLG') subs_list = [chain[date(2023, 6, 16)][0].streamer_symbol] await streamer.subscribe(EventType.GREEKS, subs_list) greeks = await streamer.get_event(EventType.GREEKS) print(greeks)
The problem here is the streamer hasn't been created. This example was building on the previous one that demonstrated how to create a streamer. You just need to add
async with DXLinkStreamer(session) as streamer:
to wrap the code block.
Next, when looking for a minimum working example, I came across closed Issue #21
from tastytrade.session import Session from tastytrade.streamer import DataStreamer from tastytrade.dxfeed.event import EventType from tastytrade.option import get_option_chain from datetime import date session = Session('username', 'password', is_certification=True) streamer = await DataStreamer.create(session) quote = await streamer.stream(EventType.QUOTE, ['.SPXW230512P3900']) chain = await get_option_chain(session, 'SPXW', date(2023, 5, 15)) print(quote, chain.options)
The problem here is that some names have been changed since the older version used in this example. DataStreamer is now DXLinkStreamer
or DXFeedStreamer
and Session is now ProductionSession
or CertificationSession
. I'm working on bettering some of the documentation now, so I'll definitely visit the README!
The best place you can look for up-to-date examples is in the documentation: https://tastyworks-api.readthedocs.io/en/latest/index.html
I hope this helps and please don't hesitate to reach out if you have more problems!
Hi Rick! Sorry getting started hasn't been smooth sailing.
from tastytrade.instruments import get_option_chain from datetime import date chain = get_option_chain(session, 'SPLG') subs_list = [chain[date(2023, 6, 16)][0].streamer_symbol] await streamer.subscribe(EventType.GREEKS, subs_list) greeks = await streamer.get_event(EventType.GREEKS) print(greeks)
The problem here is the streamer hasn't been created. This example was building on the previous one that demonstrated how to create a streamer. You just need to add
async with DXLinkStreamer(session) as streamer:
to wrap the code block.Next, when looking for a minimum working example, I came across closed Issue #21
from tastytrade.session import Session from tastytrade.streamer import DataStreamer from tastytrade.dxfeed.event import EventType from tastytrade.option import get_option_chain from datetime import date session = Session('username', 'password', is_certification=True) streamer = await DataStreamer.create(session) quote = await streamer.stream(EventType.QUOTE, ['.SPXW230512P3900']) chain = await get_option_chain(session, 'SPXW', date(2023, 5, 15)) print(quote, chain.options)
The problem here is that some names have been changed since the older version used in this example. DataStreamer is now
DXLinkStreamer
orDXFeedStreamer
and Session is nowProductionSession
orCertificationSession
. I'm working on bettering some of the documentation now, so I'll definitely visit the README!The best place you can look for up-to-date examples is in the documentation: https://tastyworks-api.readthedocs.io/en/latest/index.html
I hope this helps and please don't hesitate to reach out if you have more problems!
Hi Graeme.
Got my test scripts working now.
The missing streamer object has been the reason ....
Best, Rick
Hi Tasty Traders.
I really like the idea of a python sdk for the tastytrade api.
What is little frustrating: No example code is working. Even searching the ISSUES gives me code that does not work. Let me give an example: In the readme
Options chain/streaming greeks
This throws error:
It looks like this piece of code is not intended to run on its own?
Next, when looking for a minimum working example, I came across closed Issue #21
This throws error:
I'am not sure how to start using this package when example code is buggy. Can someone provide up-to-date example code that will successfully load option greeks from any contract let's say ticker XSP?
A primer on how the sdk works in principal would be helpful, too.
Regards, Rick