I'm having trouble understanding whether this is a dict of dicts or a list of dicts and also how do I access keys and their corresponding values such as: 'volatility' = 29.0 or 'ask' = 11.61?
{
"symbol": "SPY",
"status": "SUCCESS",
"underlying": None,
"strategy": "SINGLE",
"interval": 0.0,
"isDelayed": False,
"isIndex": False,
"interestRate": 0.1,
"underlyingPrice": 378.28499999999997,
"volatility": 29.0,
"daysToExpiration": 0.0,
"numberOfContracts": 1,
"putExpDateMap": {
"2021-01-22:7": {
"390.0": [
{
"putCall": "PUT",
"symbol": "SPY_012221P390",
"description": "SPY Jan 22 2021 " "390 Put " "(Weekly)",
"exchangeName": "OPR",
"bid": 11.46,
"ask": 11.61,
"last": 11.84,
"mark": 11.55,
"bidSize": 50,
"askSize": 50,
"bidAskSize": "50X50",
"lastSize": 0,
"highPrice": 11.89,
"lowPrice": 9.38,
"openPrice": 0.0,
"closePrice": 10.27,
"totalVolume": 461,
"tradeDate": None,
"tradeTimeInLong": 1610658217962,
"quoteTimeInLong": 1610658899875,
"netChange": 1.57,
"volatility": 13.012,
"delta": -0.945,
"gamma": 0.02,
"theta": -0.035,
"vega": 0.062,
"rho": -0.035,
"openInterest": 207,
"timeValue": 0.3,
"theoreticalOptionValue": 11.628,
"theoreticalVolatility": 29.0,
"optionDeliverablesList": None,
"strikePrice": 390.0,
"expirationDate": 1611349200000,
"daysToExpiration": 7,
"expirationType": "S",
"lastTradingDay": 1611363600000,
"multiplier": 100.0,
"settlementType": " ",
"deliverableNote": "",
"isIndexOption": None,
"percentChange": 15.29,
"markChange": 1.28,
"markPercentChange": 12.47,
"nonStandard": False,
"inTheMoney": True,
"mini": False,
}
]
}
},
"callExpDateMap": {},
}
So here's the error I keep getting whenever I try to print out print(jsonDict['volatility'].json()): Hope this helps.
Traceback (most recent call last):
File "/Users/casseroleRow/Desktop/Learning/Learning.gyp", line 26, in <module>
print(jsonDict['volatility'].json())
TypeError: 'Response' object is not subscriptable
Well you will have to parse it like this:
jsonDict.json()['volatility'] or jsonDict.json()['putExpDateMap'].json()['2021-01-22:7'].json()['390.0'][0].json()['ask']
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.