{"slug":"buy-limit-vs-sell-limit-orders","qid":"touch_curve","label":"How often a resting limit was reached, by distance from the prior close (SPY, 2021 to Sep 2026)","post_title":"Buy Limit vs Sell Limit Orders Explained","post_url":"/blog/buy-limit-vs-sell-limit-orders#q-touch_curve","columns":["limit_distance","buy_limit_touched_pct","sell_limit_touched_pct"],"rows":[{"limit_distance":0.25,"buy_limit_touched_pct":60.7,"sell_limit_touched_pct":68.8},{"limit_distance":0.5,"buy_limit_touched_pct":44.1,"sell_limit_touched_pct":48.1},{"limit_distance":1,"buy_limit_touched_pct":23.2,"sell_limit_touched_pct":22.2},{"limit_distance":1.5,"buy_limit_touched_pct":12.4,"sell_limit_touched_pct":10.7},{"limit_distance":2,"buy_limit_touched_pct":5.8,"sell_limit_touched_pct":4.7},{"limit_distance":3,"buy_limit_touched_pct":1.5,"sell_limit_touched_pct":1.1}],"shape":"ranking","sql":"WITH daily AS\n(\n    SELECT\n        date,\n        toFloat64(any(close)) AS close,\n        toFloat64(min(low))   AS low,\n        toFloat64(max(high))  AS high\n    FROM global_markets.stocks_daily_aggs\n    WHERE ticker = 'SPY'\n      AND date >= '2021-01-01'\n      AND date <  '2026-10-01'\n    GROUP BY date\n),\nframed AS\n(\n    SELECT\n        date,\n        low,\n        high,\n        lagInFrame(close, 1) OVER (ORDER BY date ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS prior_close\n    FROM daily\n)\nSELECT\n    limit_distance,\n    round(100 * countIf(low  <= prior_close * (1 - limit_distance / 100)) / count(), 1) AS buy_limit_touched_pct,\n    round(100 * countIf(high >= prior_close * (1 + limit_distance / 100)) / count(), 1) AS sell_limit_touched_pct\nFROM\n(\n    SELECT\n        low,\n        high,\n        prior_close,\n        arrayJoin([0.25, 0.5, 1.0, 1.5, 2.0, 3.0]) AS limit_distance\n    FROM framed\n    WHERE prior_close > 0\n)\nGROUP BY limit_distance\nORDER BY limit_distance","computed_at":"2026-10-05T14:51:08.584812+00:00","elapsed":0.063213935}