【发布时间】:2021-04-30 10:08:55
【问题描述】:
我正在使用 nsepython 库,我想在其中迭代每个 openInterest 键并检查该键的前 3 个值并打印行使价、OI、交易量、changeinopenInterest。 但是当我为特定脚本提取数据时,它会为每个执行价格提供单独的字典,我无法对其进行迭代。
{
"strikePrice": 2400,
"expiryDate": "27-May-2021",
"underlying": "TCS",
"identifier": "OPTSTKTCS27-05-2021CE2400.00",
"openInterest": 1,
"changeinOpenInterest": 0,
"pchangeinOpenInterest": 0,
"totalTradedVolume": 0,
"impliedVolatility": 0,
"lastPrice": 0,
"change": 0,
"pChange": 0,
"totalBuyQuantity": 5700,
"totalSellQuantity": 11400,
"bidQty": 5700,
"bidprice": 635.75,
"askQty": 11400,
"askPrice": 785.45,
"underlyingValue": 3077.3
}
【问题讨论】:
-
能贴出获取字典数据的代码吗?
-
from nsepython import* from pprint import pprint from nsepython import* print(option_chain("TCS")) -
好的。似乎并非所有记录都包含
PE的值,如何处理?
标签: python-3.x loops dictionary stock