首页 > 解决方案 > node.js:将 json 转换为数组

问题描述

我正在寻找在内存中创建的表...向 TDA API 发出 Web 请求,并获得 JSON 格式的股票/代码执行价格的回报。我无法获取 json 数组中的单个执行价格详细信息。下面是我得到的输出:

我想要完成的是从每次罢工中获取数据(例如:13.5、14.0...)并创建一个内存中的柱状表/数组,以便我可以使用这些数据来评估/评估潜在的交易/执行。

任何帮助将不胜感激!!!

    {
  "symbol": "F",
  "status": "SUCCESS",
  "underlying": null,
  "strategy": "SINGLE",
  "interval": 0,
  "isDelayed": true,
  "isIndex": false,
  "interestRate": 0.1,
  "underlyingPrice": 13.08,
  "volatility": 29,
  "daysToExpiration": 0,
  "numberOfContracts": 19,
  "putExpDateMap": {},
  "callExpDateMap": {
    "2021-09-03:2": {
      "13.5": [
        {
          "putCall": "CALL",
          "symbol": "F_090321C13.5",
          "description": "F Sep 3 2021 13.5 Call (Weekly)",
          "exchangeName": "OPR",
          "bid": 0.03,
          "ask": 0.04,
          "last": 0.04,
          "mark": 0.04,
          "bidSize": 207,
          "askSize": 655,
          "bidAskSize": "207X655",
          "lastSize": 0,
          "highPrice": 0.05,
          "lowPrice": 0.02,
          "openPrice": 0,
          "closePrice": 0.03,
          "totalVolume": 47477,
          "tradeDate": null,
          "tradeTimeInLong": 1630526399010,
          "quoteTimeInLong": 1630526399727,
          "netChange": 0.01,
          "volatility": 35.069,
          "delta": 0.169,
          "gamma": 0.64,
          "theta": -0.019,
          "vega": 0.003,
          "rho": 0,
          "openInterest": 73416,
          "timeValue": 0.04,
          "theoreticalOptionValue": 0.035,
          "theoreticalVolatility": 29,
          "optionDeliverablesList": null,
          "strikePrice": 13.5,
          "expirationDate": 1630699200000,
          "daysToExpiration": 2,
          "expirationType": "S",
          "lastTradingDay": 1630713600000,
          "multiplier": 100,
          "settlementType": " ",
          "deliverableNote": "",
          "isIndexOption": null,
          "percentChange": 20.12,
          "markChange": 0,
          "markPercentChange": 5.11,
          "inTheMoney": false,
          "mini": false,
          "nonStandard": false
        }
      ],
      "14.0": [
        {
          "putCall": "CALL",
          "symbol": "F_090321C14",
          "description": "F Sep 3 2021 14 Call (Weekly)",
          "exchangeName": "OPR",
          "bid": 0.01,
          "ask": 0.02,
          "last": 0.01,
          "mark": 0.02,
          "bidSize": 66,
          "askSize": 1468,
          "bidAskSize": "66X1468",
          "lastSize": 0,
          "highPrice": 0.02,
          "lowPrice": 0.01,
          "openPrice": 0,
          "closePrice": 0.01,
          "totalVolume": 3453,
          "tradeDate": null,
          "tradeTimeInLong": 1630526389748,
          "quoteTimeInLong": 1630526395218,
          "netChange": 0,
          "volatility": 49.446,
          "delta": 0.063,
          "gamma": 0.224,
          "theta": -0.013,
          "vega": 0.001,
          "rho": 0,
          "openInterest": 31282,
          "timeValue": 0.01,
          "theoreticalOptionValue": 0.015,
          "theoreticalVolatility": 29,
          "optionDeliverablesList": null,
          "strikePrice": 14,
          "expirationDate": 1630699200000,
          "daysToExpiration": 2,
          "expirationType": "S",
          "lastTradingDay": 1630713600000,
          "multiplier": 100,
          "settlementType": " ",
          "deliverableNote": "",
          "isIndexOption": null,
          "percentChange": -33.33,
          "markChange": 0,
          "markPercentChange": 0,
          "inTheMoney": false,
          "mini": false,
          "nonStandard": false
        }
      ],
      "14.5": [
        {
          "putCall": "CALL",
          "symbol": "F_090321C14.5",
          "description": "F Sep 3 2021 14.5 Call (Weekly)",
          "exchangeName": "OPR",
          "bid": 0,
          "ask": 0.01,
          "last": 0.01,
          "mark": 0.01,
          "bidSize": 0,
          "askSize": 386,
          "bidAskSize": "0X386",
          "lastSize": 0,
          "highPrice": 0.01,
          "lowPrice": 0.01,
          "openPrice": 0,
          "closePrice": 0.01,
          "totalVolume": 70,
          "tradeDate": null,
          "tradeTimeInLong": 1630520505930,
          "quoteTimeInLong": 1630526227626,
          "netChange": 0,
          "volatility": 60.163,
          "delta": 0.027,
          "gamma": 0.092,
          "theta": -0.008,
          "vega": 0.001,
          "rho": 0,
          "openInterest": 5529,
          "timeValue": 0.01,
          "theoreticalOptionValue": 0.007,
          "theoreticalVolatility": 29,
          "optionDeliverablesList": null,
          "strikePrice": 14.5,
          "expirationDate": 1630699200000,
          "daysToExpiration": 2,
          "expirationType": "S",
          "lastTradingDay": 1630713600000,
          "multiplier": 100,
          "settlementType": " ",
          "deliverableNote": "",
          "isIndexOption": null,
          "percentChange": 40.85,
          "markChange": 0,
          "markPercentChange": -4.23,
          "inTheMoney": false,
          "mini": false,
          "nonStandard": false
        }
      ],
      "15.0": [
        {
          "putCall": "CALL",
          "symbol": "F_090321C15",
          "description": "F Sep 3 2021 15 Call (Weekly)",
          "exchangeName": "OPR",
          "bid": 0,
          "ask": 0.01,
          "last": 0.01,
          "mark": 0,
          "bidSize": 0,
          "askSize": 594,
          "bidAskSize": "0X594",
          "lastSize": 0,
          "highPrice": 0.01,
          "lowPrice": 0.01,
          "openPrice": 0,
          "closePrice": 0,
          "totalVolume": 184,
          "tradeDate": null,
          "tradeTimeInLong": 1630524777537,
          "quoteTimeInLong": 1630526370053,
          "netChange": 0.01,
          "volatility": 68.916,
          "delta": 0.012,
          "gamma": 0.041,
          "theta": -0.005,
          "vega": 0,
          "rho": 0,
          "openInterest": 4867,
          "timeValue": 0.01,
          "theoreticalOptionValue": 0.003,
          "theoreticalVolatility": 29,
          "optionDeliverablesList": null,
          "strikePrice": 15,
          "expirationDate": 1630699200000,
          "daysToExpiration": 2,
          "expirationType": "S",
          "lastTradingDay": 1630713600000,
          "multiplier": 100,
          "settlementType": " ",
          "deliverableNote": "",
          "isIndexOption": null,
          "percentChange": 185.71,
          "markChange": 0,
          "markPercentChange": -8.57,
          "inTheMoney": false,
          "mini": false,
          "nonStandard": false
        }
      ]
    }
  }
}

标签: node.jsjsonapiwebrequest

解决方案


推荐阅读