{"slug":"buy-stop-vs-sell-stop-orders","qid":"open_gap_curve","label":"SPY: share of sessions opening a given distance from the prior close","post_title":"Buy Stop vs Sell Stop Orders: How Each Fires","post_url":"/blog/buy-stop-vs-sell-stop-orders#q-open_gap_curve","columns":["threshold","gap_down_share_pct","gap_up_share_pct"],"rows":[{"threshold":"0.25%","gap_down_share_pct":23.56,"gap_up_share_pct":32.07},{"threshold":"0.5%","gap_down_share_pct":13.19,"gap_up_share_pct":15.81},{"threshold":"1%","gap_down_share_pct":4.89,"gap_up_share_pct":4.3},{"threshold":"2%","gap_down_share_pct":1,"gap_up_share_pct":0.81},{"threshold":"3%","gap_down_share_pct":0.44,"gap_up_share_pct":0.33}],"shape":"ranking","sql":"WITH px AS\n(\n    SELECT\n        date,\n        toFloat64(open) AS open_px,\n        toFloat64(lagInFrame(close, 1) OVER (ORDER BY date)) AS prev_close\n    FROM global_markets.stocks_daily_aggs\n    WHERE ticker = 'SPY'\n      AND date >= '2016-01-01'\n      AND date <  '2026-10-01'\n),\ngaps AS\n(\n    SELECT 100 * (open_px / prev_close - 1) AS gap_pct\n    FROM px\n    WHERE prev_close > 0\n),\nlevels AS\n(\n    SELECT arrayJoin([0.25, 0.5, 1.0, 2.0, 3.0]) AS threshold_pct\n)\nSELECT\n    concat(toString(threshold_pct), '%')                         AS threshold,\n    round(100 * countIf(gap_pct <= -threshold_pct) / count(), 2) AS gap_down_share_pct,\n    round(100 * countIf(gap_pct >=  threshold_pct) / count(), 2) AS gap_up_share_pct\nFROM levels\nCROSS JOIN gaps\nGROUP BY threshold_pct, threshold\nORDER BY threshold_pct","computed_at":"2026-10-06T15:21:11.137189+00:00","elapsed":0.051464362}