{
 "key": "f5-rival-advance-opposite",
 "mechanism": "f5-rival-advance-opposite",
 "approach": "Overlay on RC: when the rival improves one side by exactly one tick (bid up or ask down; both at once ignored), cancel own orders on the opposite side and drop RC's PlaceOrders there for COOLDOWN callbacks. Acts only when sampled spread s (from rival's first quotes) is 2-4; s=1 untouched. Frozen: cooldown 2.",
 "tried": [
  {
   "name": "cooldown1_spreads234",
   "mean_diff": 0.08091157807054734,
   "se": 0.05318185746747471,
   "n_target": 146,
   "by_spread": {
    "1": {
     "mean_diff": 0.0,
     "se": 0.0,
     "n": 54
    },
    "2": {
     "mean_diff": 1.3550814035094294e-05,
     "se": 9.562485695607515e-06,
     "n": 57
    },
    "3": {
     "mean_diff": -0.026037027206124254,
     "se": 0.016605974548153483,
     "n": 49
    },
    "4": {
     "mean_diff": 0.327203308375,
     "se": 0.18924081637293005,
     "n": 40
    }
   }
  },
  {
   "name": "cooldown2_spreads234",
   "mean_diff": 1.634425704995892,
   "se": 1.9887840850680447,
   "n_target": 146,
   "by_spread": {
    "1": {
     "mean_diff": 0.0,
     "se": 0.0,
     "n": 54
    },
    "2": {
     "mean_diff": 4.475049705214033,
     "se": 5.091968832534941,
     "n": 57
    },
    "3": {
     "mean_diff": -0.3848529926897927,
     "se": 0.21075642468195402,
     "n": 49
    },
    "4": {
     "mean_diff": 0.06015290935000319,
     "se": 0.26178904932789665,
     "n": 40
    }
   }
  },
  {
   "name": "cooldown1_spread2only",
   "mean_diff": 5.29038630137243e-06,
   "se": 3.753508326792505e-06,
   "n_target": 146,
   "by_spread": {
    "1": {
     "mean_diff": 0.0,
     "se": 0.0,
     "n": 54
    },
    "2": {
     "mean_diff": 1.3550814035094294e-05,
     "se": 9.562485695607515e-06,
     "n": 57
    },
    "3": {
     "mean_diff": 0.0,
     "se": 0.0,
     "n": 49
    },
    "4": {
     "mean_diff": 0.0,
     "se": 0.0,
     "n": 40
    }
   }
  },
  {
   "name": "cooldown1_spreads34",
   "mean_diff": 0.08090628768424597,
   "se": 0.05318191284075999,
   "n_target": 146,
   "by_spread": {
    "1": {
     "mean_diff": 0.0,
     "se": 0.0,
     "n": 54
    },
    "2": {
     "mean_diff": 0.0,
     "se": 0.0,
     "n": 57
    },
    "3": {
     "mean_diff": -0.026037027206124254,
     "se": 0.016605974548153483,
     "n": 49
    },
    "4": {
     "mean_diff": 0.327203308375,
     "se": 0.18924081637293005,
     "n": 40
    }
   }
  }
 ],
 "next": "Negative on holdout: do not promote. Cooldown 1 never fires at s=2 and is ~0 elsewhere; cooldown 2 loses at s=2,3. Rival one-tick moves do not predict direction usefully for a passive quoter; try informing price estimate instead of withdrawing.",
 "spreads_acted": [
  2,
  3,
  4
 ],
 "off_equals_rc": true,
 "off_equals_rc_detail": "ENABLED=False total/retail/arb identical to RC on seeds 310000-310003 (exact equality); also the 330000-330199 spread-1 diffs and s=1 holdout diffs are exactly 0",
 "code": "from orderbook_pm_challenge.types import CancelAll, CancelOrder, PlaceOrder, Side\n\n\nclass Strategy(_RC):\n    ENABLED = True\n    COOLDOWN = 2\n    SPREADS = (2, 3, 4)\n\n    def __init__(self, *a, **k):\n        super().__init__(*a, **k)\n        self._ov_s = None\n        self._ov_pb = None\n        self._ov_pa = None\n        self._ov_sell = 0\n        self._ov_buy = 0\n\n    def on_step(self, state):\n        acts = list(super().on_step(state))\n        b = state.competitor_best_bid_ticks\n        a = state.competitor_best_ask_ticks\n        if self._ov_s is None and b is not None and a is not None:\n            self._ov_s = max(1, (a - b + 1) // 2)\n        up = dn = False\n        if b is not None and a is not None and self._ov_pb is not None and self._ov_pa is not None:\n            up = b == self._ov_pb + 1\n            dn = a == self._ov_pa - 1\n        self._ov_pb, self._ov_pa = b, a\n        if not self.ENABLED or self._ov_s not in self.SPREADS:\n            return acts\n        if up and not dn:\n            self._ov_sell = self.COOLDOWN\n        elif dn and not up:\n            self._ov_buy = self.COOLDOWN\n        block = set()\n        if self._ov_sell > 0:\n            block.add(Side.SELL)\n            self._ov_sell -= 1\n        if self._ov_buy > 0:\n            block.add(Side.BUY)\n            self._ov_buy -= 1\n        if not block or any(isinstance(x, CancelAll) for x in acts):\n            return acts\n        out = [x for x in acts if not (isinstance(x, PlaceOrder) and x.side in block)]\n        gone = {x.order_id for x in out if isinstance(x, CancelOrder)}\n        for o in state.own_orders:\n            if o.side in block and o.order_id not in gone:\n                out.append(CancelOrder(o.order_id))\n                gone.add(o.order_id)\n        return out\n",
 "code_sha256": "1c9644ab9b045148acf8dff7fd3e5694d27fdbcc3ab31457c7c275f7efc0ab2b",
 "assembled_sha256": "6048f2d0799dafddb1ab2abece876f33d35a92cbaf5eb618006d228230f24464",
 "assembled_note": "RC text with its final 'class Strategy(' renamed '_RC(' (the earlier class Strategy is aliased by RC itself and left as is), then a blank line pair and the overlay",
 "comparator_sha256": "3c07bdcd221ac25729c3ebc92b21ac9e2014510ecb85816c4391ed81e933291f",
 "tuning": {
  "seeds": "330000..330199",
  "n": 200,
  "variants": 4,
  "selected": "cooldown2_spreads234",
  "selected_target_mean_diff": 1.634425704995892,
  "selected_target_se": 1.9887840850680447,
  "selected_overall": {
   "mean_diff": 1.193130764647001,
   "se": 1.4513743612688674
  }
 },
 "paired": {
  "seeds": "440000..440499",
  "n": 500,
  "complete": true,
  "missing_seeds": [],
  "overall": {
   "n": 500,
   "sum_d": -226.87209000400026,
   "sum_d2": 8014.040838045091,
   "mean_diff": -0.4537441800080005,
   "se": 0.17806687343024966,
   "comparator_mean": 101.4369248623788,
   "candidate_mean": 100.9831806823708,
   "retail_diff": -0.5060829953212002,
   "arb_diff": 0.05233881531399983
  },
  "by_spread": {
   "1": {
    "n": 142,
    "sum_d": 0.0,
    "sum_d2": 0.0,
    "mean_diff": 0.0,
    "se": 0.0,
    "comparator_mean": 28.7146791778493,
    "candidate_mean": 28.7146791778493,
    "retail_diff": 0.0,
    "arb_diff": 0.0
   },
   "2": {
    "n": 110,
    "sum_d": -120.72801267500003,
    "sum_d2": 5643.9570605335275,
    "mean_diff": -1.0975273879545457,
    "se": 0.6779903803206124,
    "comparator_mean": 88.78927784058273,
    "candidate_mean": 87.69175045262818,
    "retail_diff": -0.4640741620290909,
    "arb_diff": -0.6334532259236362
   },
   "3": {
    "n": 119,
    "sum_d": -91.6198517883,
    "sum_d2": 795.3522535016726,
    "mean_diff": -0.769914720910084,
    "se": 0.22719482613940942,
    "comparator_mean": 143.37780997585293,
    "candidate_mean": 142.60789525494286,
    "retail_diff": -0.7786981897277325,
    "arb_diff": 0.008783468805881623
   },
   "4": {
    "n": 129,
    "sum_d": -14.524225540700217,
    "sum_d2": 1574.73152400989,
    "mean_diff": -0.11259089566434276,
    "se": 0.30865818987404525,
    "comparator_mean": 153.5829305298,
    "candidate_mean": 153.47033963413566,
    "retail_diff": -0.8475058547271312,
    "arb_diff": 0.7349149590751937
   }
  },
  "target_spreads_234": {
   "n": 358,
   "mean_diff": -0.6337209217988834,
   "se": 0.24815276494875507
  }
 },
 "failures": 0,
 "check_values": {
  "310000": 17.5126554022,
  "310001": 20.6298693268,
  "310002": 2.3903113616,
  "310003": 248.006347259
 },
 "python_version": "3.12.3",
 "seconds_per_simulation": 5.3,
 "notes": "Disclosure: to find the class name for assembly I grep'd RC for 'class'/import lines (import and class headers only); no strategy logic was read. Tuning variants compared against RC on same seeds; tuning variants' code_sha256 not computed (only frozen overlay hashed)."
}