{
 "key": "f5-rival-widen-both",
 "mechanism": "f5-rival-widen-both",
 "approach": "Overlay on RC: when the rival best bid falls AND the rival best ask rises versus the previous callback (spread s in 1..4, s from the first rival quotes), cancel all own orders and place nothing for COOLDOWN callbacks; drop RC cancels of ids the overlay removed. In this simulator the event is near-impossible: 0 triggers on tuning, 2 of 500 holdout seeds, d about 1e-6.",
 "tried": [
  {
   "name": "cooldown1",
   "code_sha256": "dd76b20f45f4041a58fecc8c3ef5af0575eb4aab37121754f6e30d946a1dc5fe",
   "mean_diff": 0.0,
   "se": 0.0,
   "n": 200,
   "seeds_identical_to_rc": 200
  },
  {
   "name": "cooldown2",
   "code_sha256": "976441c015dd67f67477ab06ef1fd9f58e7a6603f71c1d1cbb67577b77ca3db4",
   "mean_diff": 0.0,
   "se": 0.0,
   "n": 200,
   "seeds_identical_to_rc": 200
  },
  {
   "name": "cooldown3",
   "code_sha256": "58cead25f077a37fe05278878335f351f98a8e7ff2e5d68c3fd1b3685871fdba",
   "mean_diff": 0.0,
   "se": 0.0,
   "n": 200,
   "seeds_identical_to_rc": 200
  }
 ],
 "next": "Drop this mechanism: a consumed rival level is replenished on the opposite side (tick -/+ spread), so the rival ladder shifts as a block and both best quotes almost never retreat together (bid down 6822, ask up 6909, both 0 of 79960 steps on seeds 330000..330039). The observable signal is a one-sided rival shift (the replenished level reveals an arbitrage sweep); a fresh item could act on that.",
 "frozen_variant": "cooldown1 (all three variants tie at exactly 0 on tuning; smallest change kept)",
 "spreads_acted": [
  1,
  2,
  3,
  4
 ],
 "off_equals_rc": true,
 "off_equals_rc_check": "COOLDOWN=0 vs RC: identical action lists on all 2000 steps of seeds 310000, 310001, 310002",
 "code": "\n\n# ---- overlay f5-rival-widen-both ----\n# When both rival best quotes retreat in the same step (bid down AND ask up\n# versus the previous callback), cancel every own order and place nothing for\n# COOLDOWN callbacks. Acts only when the rival spread s (from the rival's first\n# quotes) is in ACT_SPREADS. COOLDOWN = 0 returns RC's actions unchanged.\nfrom orderbook_pm_challenge.types import CancelOrder as _OvCancel, PlaceOrder as _OvPlace\n\n\nclass Strategy(_RC):\n    COOLDOWN = 1\n    ACT_SPREADS = (1, 2, 3, 4)\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self._ov_prev = None\n        self._ov_s = None\n        self._ov_left = 0\n        self._ov_gone = set()\n\n    def on_step(self, state):\n        actions = super().on_step(state)\n        if self.COOLDOWN <= 0:\n            return actions\n        bid = state.competitor_best_bid_ticks\n        ask = state.competitor_best_ask_ticks\n        if self._ov_s is None and bid is not None and ask is not None:\n            self._ov_s = max(1, (ask - bid + 1) // 2)\n        prev = self._ov_prev\n        self._ov_prev = (bid, ask)\n        if self._ov_s not in self.ACT_SPREADS:\n            return actions\n        if prev is not None and self._ov_left <= 0:\n            pb, pa = prev\n            bid_back = pb is not None and (bid is None or bid < pb)\n            ask_back = pa is not None and (ask is None or ask > pa)\n            if bid_back and ask_back:\n                self._ov_left = self.COOLDOWN\n        live = {o.order_id for o in state.own_orders}\n        if self._ov_left > 0:\n            self._ov_left -= 1\n            self._ov_gone |= live\n            for a in actions:\n                if isinstance(a, _OvPlace) and a.client_order_id:\n                    self._ov_gone.add(a.client_order_id)\n            return [_OvCancel(oid) for oid in sorted(live)]\n        if not self._ov_gone:\n            return actions\n        out = []\n        for a in actions:\n            if isinstance(a, _OvCancel) and a.order_id in self._ov_gone and a.order_id not in live:\n                continue\n            out.append(a)\n        return out\n",
 "code_sha256": "dd76b20f45f4041a58fecc8c3ef5af0575eb4aab37121754f6e30d946a1dc5fe",
 "assembled_sha256": "4636b5cf14606eaa3914adfbed11ea105917d4511bb335566b6edb01235c37eb",
 "comparator_sha256": "3c07bdcd221ac25729c3ebc92b21ac9e2014510ecb85816c4391ed81e933291f",
 "assembly": "RC text with its last top-level \"class Strategy\" header (the exported one, which subclasses an internal class) renamed to \"class _RC\", followed by the overlay",
 "tuning": {
  "seeds": "330000..330199",
  "n": 200,
  "complete": true,
  "missing_seeds": [],
  "overall": {
   "n": 200,
   "sum_d": 0.0,
   "sum_d2": 0.0,
   "mean_diff": 0.0,
   "se": 0.0,
   "comparator_mean": 97.4672213329115,
   "candidate_mean": 97.4672213329115,
   "retail_diff": 0.0,
   "arb_diff": 0.0
  },
  "by_spread": {
   "1": {
    "n": 54,
    "sum_d": 0.0,
    "sum_d2": 0.0,
    "mean_diff": 0.0,
    "se": 0.0,
    "comparator_mean": 46.182844338938885,
    "candidate_mean": 46.182844338938885,
    "retail_diff": 0.0,
    "arb_diff": 0.0
   },
   "2": {
    "n": 57,
    "sum_d": 0.0,
    "sum_d2": 0.0,
    "mean_diff": 0.0,
    "se": 0.0,
    "comparator_mean": 87.23571902150526,
    "candidate_mean": 87.23571902150526,
    "retail_diff": 0.0,
    "arb_diff": 0.0
   },
   "3": {
    "n": 49,
    "sum_d": 0.0,
    "sum_d2": 0.0,
    "mean_diff": 0.0,
    "se": 0.0,
    "comparator_mean": 112.87398754092447,
    "candidate_mean": 112.87398754092447,
    "retail_diff": 0.0,
    "arb_diff": 0.0
   },
   "4": {
    "n": 40,
    "sum_d": 0.0,
    "sum_d2": 0.0,
    "mean_diff": 0.0,
    "se": 0.0,
    "comparator_mean": 162.4077324637125,
    "candidate_mean": 162.4077324637125,
    "retail_diff": 0.0,
    "arb_diff": 0.0
   }
  },
  "chosen": "cooldown1",
  "target_spreads": [
   1,
   2,
   3,
   4
  ]
 },
 "paired": {
  "seeds": "440000..440499",
  "n": 500,
  "complete": true,
  "missing_seeds": [],
  "overall": {
   "n": 500,
   "sum_d": 0.0003881126000016555,
   "sum_d2": 8.536701811148106e-08,
   "mean_diff": 7.76225200003311e-07,
   "se": 5.839048819336723e-07,
   "comparator_mean": 101.4369248623788,
   "candidate_mean": 101.436925638604,
   "retail_diff": 0.0,
   "arb_diff": 7.762251999998693e-07
  },
  "by_spread": {
   "1": {
    "n": 142,
    "sum_d": 0.00012316439999998652,
    "sum_d2": 1.516946942735668e-08,
    "mean_diff": 8.673549295773699e-07,
    "se": 8.673549295773699e-07,
    "comparator_mean": 28.7146791778493,
    "candidate_mean": 28.714680045204222,
    "retail_diff": 0.0,
    "arb_diff": 8.673549295777608e-07
   },
   "2": {
    "n": 110,
    "sum_d": 0.00026494820000166897,
    "sum_d2": 7.019754868412438e-08,
    "mean_diff": 2.4086200000151723e-06,
    "se": 2.4086200000151723e-06,
    "comparator_mean": 88.78927784058273,
    "candidate_mean": 88.78928024920273,
    "retail_diff": 0.0,
    "arb_diff": 2.4086199999990236e-06
   },
   "3": {
    "n": 119,
    "sum_d": 0.0,
    "sum_d2": 0.0,
    "mean_diff": 0.0,
    "se": 0.0,
    "comparator_mean": 143.37780997585293,
    "candidate_mean": 143.37780997585293,
    "retail_diff": 0.0,
    "arb_diff": 0.0
   },
   "4": {
    "n": 129,
    "sum_d": 0.0,
    "sum_d2": 0.0,
    "mean_diff": 0.0,
    "se": 0.0,
    "comparator_mean": 153.5829305298,
    "candidate_mean": 153.5829305298,
    "retail_diff": 0.0,
    "arb_diff": 0.0
   }
  }
 },
 "holdout_notes": "Candidate differs from RC on 2 of 500 holdout seeds (440323 s=2: +0.000265; 440458 s=1: +0.000123), each from exactly one trigger, both following a crossed or locked rival book. The other 498 seeds are bit-identical. A screen, not a promotion.",
 "failures": [],
 "check_values": {
  "310000": 17.5126554022,
  "310001": 20.6298693268,
  "310002": 2.3903113616,
  "310003": 248.006347259
 },
 "python_version": "3.12.3",
 "seconds_per_simulation": 0.211
}