Options chain endpoint not returning any data.
When trying to return options chain data for a symbol, no data is returned. The other endpoints / streaming are working just fine.
This could be due to the fact that I dont have ThinkOrSwim enabled yet. Curious if anyone else is having the same issue. Attempted with custom code, and with code found in the api_demo.py file.
What symbol are you using?
Tried with AAPL, SPY, QQQ, and INTC:
` import schwabdev from datetime import datetime import os
client = schwabdev.Client( app_key=os.getenv("SCHWAB_API_KEY"), app_secret=os.getenv("SCHWAB_API_SECRET"), )
symbol = "SPY" contract_type = "CALL" strike = 569 expiration_date = datetime(2024, 10, 4)
response = client.option_chains( symbol=symbol, contractType=contract_type, strike=strike, fromDate=expiration_date, toDate=expiration_date )
if response.status_code == 200: options_data = response.json()
print(f"Options chain for {symbol} calls with strike {strike} expiring on {expiration_date.date()}:")
for option in options_data.get('callExpDateMap', {}).get(expiration_date.strftime('%Y-%m-%d:%H:%M:%S'), {}).get(str(strike), []):
print(f"Symbol: {option['symbol']}")
print(f"Last Price: {option['last']}")
print(f"Bid: {option['bid']}")
print(f"Ask: {option['ask']}")
print(f"Volume: {option['totalVolume']}")
print(f"Open Interest: {option['openInterest']}")
print("---")
else: print(f"Error: {response.status_code}") print(response.text)
`
From this call:
print(client.option_chains("SPY", contractType="CALL", strike=569, fromDate=datetime.datetime(2024, 10, 4), toDate=datetime.datetime(2024, 10, 4)).json())
I get:
{'symbol': 'SPY', 'status': 'SUCCESS', 'strategy': 'SINGLE', 'interval': 0.0, 'isDelayed': False, 'isIndex': False, 'interestRate': 4.738, 'underlyingPrice': 569.72, 'volatility': 29.0, 'daysToExpiration': 0.0, 'numberOfContracts': 1, 'assetMainType': 'EQUITY', 'assetSubType': 'ETF', 'isChainTruncated': False, 'callExpDateMap': {'2024-10-04:2': {'569.0': [{'putCall': 'CALL', 'symbol': 'SPY 241004C00569000', 'description': 'SPY 10/04/2024 569.00 C', 'exchangeName': 'OPR', 'bid': 3.83, 'ask': 3.85, 'last': 3.81, 'mark': 3.84, 'bidSize': 32, 'askSize': 96, 'bidAskSize': '32X96', 'lastSize': 0, 'highPrice': 4.46, 'lowPrice': 2.62, 'openPrice': 0.0, 'closePrice': 4.15, 'totalVolume': 16431, 'tradeTimeInLong': 1727900082745, 'quoteTimeInLong': 1727900100043, 'netChange': -0.34, 'volatility': 19.89, 'delta': 0.523, 'gamma': 0.047, 'theta': -1.088, 'vega': 0.171, 'rho': 0.017, 'openInterest': 3850, 'timeValue': 3.81, 'theoreticalOptionValue': 3.621, 'theoreticalVolatility': 29.0, 'optionDeliverablesList': [{'symbol': 'SPY', 'assetType': 'STOCK', 'deliverableUnits': 100.0}], 'strikePrice': 569.0, 'expirationDate': '2024-10-04T20:00:00.000+00:00', 'daysToExpiration': 2, 'expirationType': 'W', 'lastTradingDay': 1728086400000, 'multiplier': 100.0, 'settlementType': 'P', 'deliverableNote': '100 SPY', 'percentChange': -8.2, 'markChange': -0.31, 'markPercentChange': -7.43, 'intrinsicValue': -0.14, 'extrinsicValue': 3.95, 'optionRoot': 'SPY', 'exerciseType': 'A', 'high52Week': 8.56, 'low52Week': 0.56, 'nonStandard': False, 'pennyPilot': True, 'inTheMoney': False, 'mini': False}]}}, 'putExpDateMap': {}}
You could try running exactly this. The problem could be realated to TOS. What do you mean by "no data"?
BTW this is what the playground.py file is for. You can copy and paste (or type) code in to be executed.
Did you find a solution?
Going to remove this issue tonight since it is stale, no one else that I am aware of has had this issue. Yours could be related to TOS but I'm not sure since I didn't see your error responses. It could also be related to internet connection e.g. if you are behind a proxy (this could be tested by making other api calls).
Closed due to stale request. (based on previous comment's reasoning)