Closed alexonab closed 1 year ago
You should either create a ProductionSession or a CertificationSession
from tastytrade import ProductionSession, CertificationSession e.g. session = CertificationSession(username, password)
You should either create a ProductionSession or a CertificationSession
from tastytrade import ProductionSession, CertificationSession e.g. session = CertificationSession(username, password)
I imported ProductionSession as Session.
I can't reproduce
>>> session = ProductionSession(user, password)
>>> chain = get_option_chain(session, 'SPY')
>>> subs_list = [chain[date(2023, 7, 28)][0].streamer_symbol]
>>> print(subs_list)
['.SPY230728C275']
@Quenos
The error occurs calling Option.get_option.
Option.get_option(session, subs_list[0])
I see. Bet get_option has a different interface:
def get_option(
cls,
session: Session,
symbol: str,
active: Optional[bool] = None
) -> 'Option'
I figured out what I was doing wrong.
When filtering the option chain, I was returning streamer_symbol and not symbol. These have different formats.
>>> subs_list = [chain[date(2023, 7, 28)][0]]
>>> subs_list[0].streamer_symbol
'.SPY230728C275'
>>> subs_list[0].symbol
'SPY 230728C00275000'
>>> Option.get_option(session, subs_list[0].symbol)
<OptionType.CALL: 'C'>, option_chain_type='Standard', expiration_type='Weekly', settlement_type='PM', stops_trading_at=datetime.datetime(2023, 7, 28, 20, 15, tzinfo=datetime.timezone.utc), market_time_instrument_collection='Cash Settled Equity Option', days_to_expiration=1, expires_at=datetime.datetime(2023, 7, 28, 20, 15, tzinfo=datetime.timezone.utc), is_closing_only=False, listed_market=None, halted_at=None, old_security_number=None, streamer_symbol='.SPY230728C275')
Glad you figured it out! So yeah, the streamer symbol is just for use with the streamer.
Describe the bug Option.get_option returns a 404.
How to reproduce