2

I have tried a couple of things, but my goal is simply to get access to last, for example, while using wildcards for 2021-02-12:5 and the 610.0 section.

{ symbol:symbol,test:putExpDateMap.*.[*].last} is closest I have gotten to success but no cigar, appreciate any help in how to write the most efficient query to access only a few of these attributes rather than always all of them.

{
  "symbol": "TSLA",
  "status": "SUCCESS",
  "underlying": null,
  "strategy": "SINGLE",
  "interval": 0,
  "isDelayed": true,
  "isIndex": false,
  "interestRate": 0.1,
  "underlyingPrice": 853.4449999999999,
  "volatility": 29,
  "daysToExpiration": 0,
  "numberOfContracts": 8,
  "putExpDateMap": {
    "2021-02-12:5": {
      "610.0": [
        {
          "putCall": "PUT",
          "symbol": "TSLA_021221P610",
          "description": "TSLA Feb 12 2021 610 Put (Weekly)",
          "exchangeName": "OPR",
          "bid": 2.22,
          "ask": 2.76,
          "last": 2.36,
          "mark": 2.49,
          "bidSize": 10,
          "askSize": 1,
          "bidAskSize": "10X1",
          "lastSize": 0,
          "highPrice": 2.6,
          "lowPrice": 0.4,
          "openPrice": 0,
          "closePrice": 2.47,
          "totalVolume": 103,
          "tradeDate": null,
          "tradeTimeInLong": 1612558387464,
          "quoteTimeInLong": 1612558799414,
          "netChange": -0.11,
          "volatility": 134.512,
          "delta": -0.035,
          "gamma": 0,
          "theta": -0.836,
          "vega": 0.095,
          "rho": -0.007,
          "openInterest": 709,
          "timeValue": 2.36,
          "theoreticalOptionValue": 2.471,
          "theoreticalVolatility": 29,
          "optionDeliverablesList": null,
          "strikePrice": 610,
          "expirationDate": 1613163600000,
          "daysToExpiration": 5,
          "expirationType": "S",
          "lastTradingDay": 1613178000000,
          "multiplier": 100,
          "settlementType": " ",
          "deliverableNote": "",
          "isIndexOption": null,
          "percentChange": -4.49,
          "markChange": 0.02,
          "markPercentChange": 0.77,
          "mini": false,
          "inTheMoney": false,
          "nonStandard": false
        }
      ]
    },
    "2021-02-19:12": {
      "610.0": [
        {
          "putCall": "PUT",
          "symbol": "TSLA_021921P610",
          "description": "TSLA Feb 19 2021 610 Put",
          "exchangeName": "OPR",
          "bid": 3.1,
          "ask": 3.9,
          "last": 3.4,
          "mark": 3.5,
          "bidSize": 1,
          "askSize": 4,
          "bidAskSize": "1X4",
          "lastSize": 0,
          "highPrice": 3.4,
          "lowPrice": 1.11,
          "openPrice": 0,
          "closePrice": 3.42,
          "totalVolume": 22,
          "tradeDate": null,
          "tradeTimeInLong": 1612558029558,
          "quoteTimeInLong": 1612558799676,
          "netChange": -0.02,
          "volatility": 103.828,
          "delta": -0.044,
          "gamma": 0.001,
          "theta": -0.558,
          "vega": 0.158,
          "rho": -0.016,
          "openInterest": 1677,
          "timeValue": 3.4,
          "theoreticalOptionValue": 3.418,
          "theoreticalVolatility": 29,
          "optionDeliverablesList": null,
          "strikePrice": 610,
          "expirationDate": 1613768400000,
          "daysToExpiration": 12,
          "expirationType": "R",
          "lastTradingDay": 1613782800000,
          "multiplier": 100,
          "settlementType": " ",
          "deliverableNote": "",
          "isIndexOption": null,
          "percentChange": -0.53,
          "markChange": 0.08,
          "markPercentChange": 2.39,
          "mini": false,
          "inTheMoney": false,
          "nonStandard": false
        }
      ]
    },
    "2021-02-26:19": {
      "610.0": [
        {
          "putCall": "PUT",
          "symbol": "TSLA_022621P610",
          "description": "TSLA Feb 26 2021 610 Put (Weekly)",
          "exchangeName": "OPR",
          "bid": 4.15,
          "ask": 5.1,
          "last": 4.2,
          "mark": 4.63,
          "bidSize": 4,
          "askSize": 4,
          "bidAskSize": "4X4",
          "lastSize": 0,
          "highPrice": 4.2,
          "lowPrice": 2.15,
          "openPrice": 0,
          "closePrice": 4.67,
          "totalVolume": 6,
          "tradeDate": null,
          "tradeTimeInLong": 1612558446501,
          "quoteTimeInLong": 1612558795805,
          "netChange": -0.47,
          "volatility": 91.456,
          "delta": -0.053,
          "gamma": 0.001,
          "theta": -0.476,
          "vega": 0.226,
          "rho": -0.03,
          "openInterest": 178,
          "timeValue": 4.2,
          "theoreticalOptionValue": 4.674,
          "theoreticalVolatility": 29,
          "optionDeliverablesList": null,
          "strikePrice": 610,
          "expirationDate": 1614373200000,
          "daysToExpiration": 19,
          "expirationType": "S",
          "lastTradingDay": 1614387600000,
          "multiplier": 100,
          "settlementType": " ",
          "deliverableNote": "",
          "isIndexOption": null,
          "percentChange": -10.15,
          "markChange": -0.05,
          "markPercentChange": -1.05,
          "mini": false,
          "inTheMoney": false,
          "nonStandard": false
        }
      ]
    },
    "2021-03-12:33": {
      "610.0": [
        {
          "putCall": "PUT",
          "symbol": "TSLA_031221P610",
          "description": "TSLA Mar 12 2021 610 Put (Weekly)",
          "exchangeName": "OPR",
          "bid": 6.3,
          "ask": 9.35,
          "last": 5.35,
          "mark": 7.82,
          "bidSize": 5,
          "askSize": 1,
          "bidAskSize": "5X1",
          "lastSize": 0,
          "highPrice": 5.8,
          "lowPrice": 5.35,
          "openPrice": 0,
          "closePrice": 7.79,
          "totalVolume": 3,
          "tradeDate": null,
          "tradeTimeInLong": 1612540259726,
          "quoteTimeInLong": 1612558799462,
          "netChange": -2.44,
          "volatility": 80.707,
          "delta": -0.073,
          "gamma": 0.001,
          "theta": -0.418,
          "vega": 0.37,
          "rho": -0.069,
          "openInterest": 2,
          "timeValue": 5.35,
          "theoreticalOptionValue": 7.786,
          "theoreticalVolatility": 29,
          "optionDeliverablesList": null,
          "strikePrice": 610,
          "expirationDate": 1615582800000,
          "daysToExpiration": 33,
          "expirationType": "S",
          "lastTradingDay": 1615597200000,
          "multiplier": 100,
          "settlementType": " ",
          "deliverableNote": "",
          "isIndexOption": null,
          "percentChange": -31.29,
          "markChange": 0.04,
          "markPercentChange": 0.5,
          "mini": false,
          "inTheMoney": false,
          "nonStandard": false
        }
      ]
    },
    "2021-03-19:40": {
      "610.0": [
        {
          "putCall": "PUT",
          "symbol": "TSLA_031921P610",
          "description": "TSLA Mar 19 2021 610 Put",
          "exchangeName": "OPR",
          "bid": 9.15,
          "ask": 10.05,
          "last": 9.56,
          "mark": 9.6,
          "bidSize": 4,
          "askSize": 4,
          "bidAskSize": "4X4",
          "lastSize": 0,
          "highPrice": 9.56,
          "lowPrice": 6.65,
          "openPrice": 0,
          "closePrice": 9.55,
          "totalVolume": 63,
          "tradeDate": null,
          "tradeTimeInLong": 1612558720834,
          "quoteTimeInLong": 1612558795810,
          "netChange": 0.01,
          "volatility": 77.96,
          "delta": -0.082,
          "gamma": 0.001,
          "theta": -0.404,
          "vega": 0.443,
          "rho": -0.093,
          "openInterest": 4367,
          "timeValue": 9.56,
          "theoreticalOptionValue": 9.552,
          "theoreticalVolatility": 29,
          "optionDeliverablesList": null,
          "strikePrice": 610,
          "expirationDate": 1616184000000,
          "daysToExpiration": 40,
          "expirationType": "R",
          "lastTradingDay": 1616198400000,
          "multiplier": 100,
          "settlementType": " ",
          "deliverableNote": "",
          "isIndexOption": null,
          "percentChange": 0.08,
          "markChange": 0.05,
          "markPercentChange": 0.5,
          "mini": false,
          "inTheMoney": false,
          "nonStandard": false
        }
      ]
    },
    "2021-04-16:68": {
      "610.0": [
        {
          "putCall": "PUT",
          "symbol": "TSLA_041621P610",
          "description": "TSLA Apr 16 2021 610 Put",
          "exchangeName": "OPR",
          "bid": 18.4,
          "ask": 19.3,
          "last": 15.64,
          "mark": 18.85,
          "bidSize": 2,
          "askSize": 5,
          "bidAskSize": "2X5",
          "lastSize": 0,
          "highPrice": 16.84,
          "lowPrice": 15.64,
          "openPrice": 0,
          "closePrice": 18.81,
          "totalVolume": 5,
          "tradeDate": null,
          "tradeTimeInLong": 1612544435621,
          "quoteTimeInLong": 1612558796856,
          "netChange": -3.17,
          "volatility": 74.6,
          "delta": -0.118,
          "gamma": 0.001,
          "theta": -0.391,
          "vega": 0.742,
          "rho": -0.231,
          "openInterest": 294,
          "timeValue": 15.64,
          "theoreticalOptionValue": 18.813,
          "theoreticalVolatility": 29,
          "optionDeliverablesList": null,
          "strikePrice": 610,
          "expirationDate": 1618603200000,
          "daysToExpiration": 68,
          "expirationType": "R",
          "lastTradingDay": 1618617600000,
          "multiplier": 100,
          "settlementType": " ",
          "deliverableNote": "",
          "isIndexOption": null,
          "percentChange": -16.87,
          "markChange": 0.04,
          "markPercentChange": 0.19,
          "mini": false,
          "inTheMoney": false,
          "nonStandard": false
        }
      ]
    },
    "2021-06-18:131": {
      "610.0": [
        {
          "putCall": "PUT",
          "symbol": "TSLA_061821P610",
          "description": "TSLA Jun 18 2021 610 Put",
          "exchangeName": "OPR",
          "bid": 42.65,
          "ask": 44.1,
          "last": 40.25,
          "mark": 43.38,
          "bidSize": 2,
          "askSize": 3,
          "bidAskSize": "2X3",
          "lastSize": 0,
          "highPrice": 41.45,
          "lowPrice": 40.25,
          "openPrice": 0,
          "closePrice": 43.34,
          "totalVolume": 2,
          "tradeDate": null,
          "tradeTimeInLong": 1612551889156,
          "quoteTimeInLong": 1612558799879,
          "netChange": -3.09,
          "volatility": 75.159,
          "delta": -0.168,
          "gamma": 0.001,
          "theta": -0.363,
          "vega": 1.293,
          "rho": -0.681,
          "openInterest": 316,
          "timeValue": 40.25,
          "theoreticalOptionValue": 43.338,
          "theoreticalVolatility": 29,
          "optionDeliverablesList": null,
          "strikePrice": 610,
          "expirationDate": 1624046400000,
          "daysToExpiration": 131,
          "expirationType": "R",
          "lastTradingDay": 1624060800000,
          "multiplier": 100,
          "settlementType": " ",
          "deliverableNote": "",
          "isIndexOption": null,
          "percentChange": -7.13,
          "markChange": 0.04,
          "markPercentChange": 0.08,
          "mini": false,
          "inTheMoney": false,
          "nonStandard": false
        }
      ]
    },
    "2021-07-16:159": {
      "610.0": [
        {
          "putCall": "PUT",
          "symbol": "TSLA_071621P610",
          "description": "TSLA Jul 16 2021 610 Put",
          "exchangeName": "OPR",
          "bid": 51.1,
          "ask": 52.65,
          "last": 49.45,
          "mark": 51.88,
          "bidSize": 1,
          "askSize": 2,
          "bidAskSize": "1X2",
          "lastSize": 0,
          "highPrice": 49.45,
          "lowPrice": 49.45,
          "openPrice": 0,
          "closePrice": 51.81,
          "totalVolume": 4,
          "tradeDate": null,
          "tradeTimeInLong": 1612552046681,
          "quoteTimeInLong": 1612558799421,
          "netChange": -2.36,
          "volatility": 74.204,
          "delta": -0.177,
          "gamma": 0.001,
          "theta": -0.337,
          "vega": 1.474,
          "rho": -0.898,
          "openInterest": 373,
          "timeValue": 49.45,
          "theoreticalOptionValue": 51.812,
          "theoreticalVolatility": 29,
          "optionDeliverablesList": null,
          "strikePrice": 610,
          "expirationDate": 1626465600000,
          "daysToExpiration": 159,
          "expirationType": "R",
          "lastTradingDay": 1626480000000,
          "multiplier": 100,
          "settlementType": " ",
          "deliverableNote": "",
          "isIndexOption": null,
          "percentChange": -4.56,
          "markChange": 0.06,
          "markPercentChange": 0.12,
          "mini": false,
          "inTheMoney": false,
          "nonStandard": false
        }
      ]
    }
  },
  "callExpDateMap": {}
}
β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
WTJJ
  • 103
  • 10

1 Answers1

0

You do have two issues in your query:

  1. putExpDateMap.* won't give you any number of level of unknown properties, but just one level. Since the first item would statically be be accessed via putExpDateMap."2021-02-12:5"."610.0", it means that you have to use two wild cards to access the arrays nested there, so putExpDateMap.*.*
  2. if you need to deal with array you indeed have to use [*] but then it is not a property so is should be putExpDateMap."2021-02-12:5"."610.0"[*] and not putExpDateMap."2021-02-12:5"."610.0".[*], or putExpDateMap.*.*[*] and not putExpDateMap.*.[*] like it your attempt.

Last but not least, with the corrected query:

{ symbol:symbol,test:putExpDateMap.*.*[*].last } 

You still ends with a cluttered output:

{
  "symbol": "TSLA",
  "test": [
    [
      [
        2.36
      ]
    ],
    [
      [
        3.4
      ]
    ],
    [
      [
        4.2
      ]
    ],
    [
      [
        5.35
      ]
    ],
    [
      [
        9.56
      ]
    ],
    [
      [
        15.64
      ]
    ],
    [
      [
        40.25
      ]
    ],
    [
      [
        49.45
      ]
    ]
  ]
}

Because the wildcards are creating some new levels of array — since you can have * properties holding an array.

You might want to read abou the JMESPath flatten operator [] in order to overcome that.

So, we are ending with:

{ symbol:symbol, test:putExpDateMap.*.*[*].last[][] } 

That gives:

{
  "symbol": "TSLA",
  "test": [
    2.36,
    3.4,
    4.2,
    5.35,
    9.56,
    15.64,
    40.25,
    49.45
  ]
}
β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83