{"slug":"open-source-gex-dashboard","qid":"max_pain_curve","label":"The same chain, a different question: in the money value by settlement price","post_title":"Open-Source GEX Dashboard: How It Works","post_url":"/blog/open-source-gex-dashboard#q-max_pain_curve","columns":["settle_price","itm_value_bn"],"rows":[{"settle_price":"$759","itm_value_bn":0.89},{"settle_price":"$760","itm_value_bn":0.8},{"settle_price":"$761","itm_value_bn":0.72},{"settle_price":"$762","itm_value_bn":0.64},{"settle_price":"$763","itm_value_bn":0.56},{"settle_price":"$764","itm_value_bn":0.48},{"settle_price":"$765","itm_value_bn":0.41},{"settle_price":"$766","itm_value_bn":0.35},{"settle_price":"$767","itm_value_bn":0.3},{"settle_price":"$768","itm_value_bn":0.25},{"settle_price":"$769","itm_value_bn":0.21},{"settle_price":"$770","itm_value_bn":0.18},{"settle_price":"$771","itm_value_bn":0.19},{"settle_price":"$772","itm_value_bn":0.21},{"settle_price":"$773","itm_value_bn":0.25},{"settle_price":"$774","itm_value_bn":0.3},{"settle_price":"$775","itm_value_bn":0.35},{"settle_price":"$776","itm_value_bn":0.41},{"settle_price":"$777","itm_value_bn":0.47},{"settle_price":"$778","itm_value_bn":0.54},{"settle_price":"$779","itm_value_bn":0.62},{"settle_price":"$780","itm_value_bn":0.69},{"settle_price":"$781","itm_value_bn":0.77}],"shape":"ranking","sql":"WITH chain AS\n(\n    SELECT\n        toFloat64(strike_price)                                             AS k,\n        if(lower(option_type) LIKE 'c%', 'call', 'put')                     AS side,\n        sum(toFloat64(volume))                                              AS contracts,\n        min(abs(toFloat64(strike_price) / toFloat64(underlying_close) - 1)) AS moneyness\n    FROM global_markets.options_greeks\n    WHERE underlying_symbol = 'SPY'\n      AND date = (SELECT max(date) FROM global_markets.options_greeks WHERE underlying_symbol = 'SPY')\n      AND volume > 0\n      AND days_to_expiry BETWEEN 0 AND 7\n    GROUP BY k, side\n)\nSELECT\n    concat('$', toString(round(sk)))          AS settle_price,\n    round(sum(multiIf(\n        side = 'call' AND sk > k, (sk - k) * contracts * 100,\n        side = 'put'  AND sk < k, (k - sk) * contracts * 100,\n        0)) / 1e9, 2)                         AS itm_value_bn\nFROM (SELECT DISTINCT k AS sk FROM chain WHERE moneyness <= 0.015) AS grid\nCROSS JOIN chain\nGROUP BY sk\nORDER BY sk","computed_at":"2026-08-22T04:17:51.854909+00:00","elapsed":2.09094637}