{
 "key": "f5-rival-vanish-side",
 "mechanism": "f5-rival-vanish-side",
 "approach": "Overlay on RC: when the rival best bid (ask) becomes None, drop own BUY (SELL) PlaceOrders and cancel resting orders on that side, for at most K callbacks or until the rival side reappears. Gate on rival spread s in {1,2,3,4} from first two-sided quote. Tuned K in {2,5,10} on 330000..330199; froze K=2; holdout 440000..440499 once.",
 "tried": [
  {
   "name": "K=2",
   "code_sha256": "82a618d923a29a9fa6d69756367a98b06b86e40fa4452c218c17e73a509adb3b",
   "mean_diff": -0.23235802096849828,
   "se": 0.3091819472077692,
   "by_spread": {
    "1": {
     "mean_diff": -1.1110577015703718,
     "se": 1.0891795230871877
    },
    "2": {
     "mean_diff": 0.23452912251052774,
     "se": 0.20219500947190472
    },
    "3": {
     "mean_diff": -0.22941933629387437,
     "se": 0.26333085965467656
    },
    "4": {
     "mean_diff": 0.2849724796600046,
     "se": 0.1807701756513377
    }
   }
  },
  {
   "name": "K=5",
   "code_sha256": "8179287428001eb8090424c8ce4e8dc3a54f8ab831c45de851fc28cd7950dd75",
   "mean_diff": -0.2347617239844993,
   "se": 0.3090084700626745,
   "by_spread": {
    "1": {
     "mean_diff": -1.2148724573092593,
     "se": 1.0889407248501666
    },
    "2": {
     "mean_diff": 0.3170756453929815,
     "se": 0.18656783666730883
    },
    "3": {
     "mean_diff": -0.2279374251918322,
     "se": 0.26380304943035593
    },
    "4": {
     "mean_diff": 0.2936597486199995,
     "se": 0.1815651686884781
    }
   }
  },
  {
   "name": "K=10",
   "code_sha256": "e4ea8639f0e9f96a5c4b0c1d12be606349c0b44648d108e62385f88ed1542622",
   "mean_diff": -1.865376706536999,
   "se": 1.3614160239542499,
   "by_spread": {
    "1": {
     "mean_diff": -6.96373389565,
     "se": 4.989984445772933
    },
    "2": {
     "mean_diff": 0.3291868462070184,
     "se": 0.19647723297854192
    },
    "3": {
     "mean_diff": -0.5361581477938766,
     "se": 0.40118465574235523
    },
    "4": {
     "mean_diff": 0.26185970164500144,
     "se": 0.18997924331617494
    }
   }
  }
 ],
 "frozen": "K=2",
 "next": "Effect is small/negative overall, driven by spread 1 (high variance); mild positive on spreads 2 and 4. If pursued, restrict to spreads 2 and 4 and screen on a fresh seed range; otherwise drop.",
 "spreads_acted": [
  1,
  2,
  3,
  4
 ],
 "off_equals_rc": true,
 "off_check_seeds": [
  310000,
  310001,
  310002,
  310003
 ],
 "code": "from orderbook_pm_challenge.types import CancelOrder, CancelAll, PlaceOrder, Side\n\nVANISH_K = 2\nTARGET_SPREADS = (1, 2, 3, 4)\n\n\nclass Strategy(_RC):\n    \"\"\"Overlay f5-rival-vanish-side: when a rival side vanishes (best quote None),\n    cancel own orders on that side and place nothing there until the rival side\n    reappears, for at most VANISH_K callbacks.\"\"\"\n\n    def __init__(self, *a, **k):\n        super().__init__(*a, **k)\n        self._vk = VANISH_K\n        self._vs = None\n        self._vleft = {Side.BUY: 0, Side.SELL: 0}\n        self._vprev = {Side.BUY: True, Side.SELL: True}\n\n    def on_step(self, state):\n        actions = super().on_step(state)\n        if self._vk <= 0:\n            return actions\n        bid = state.competitor_best_bid_ticks\n        ask = state.competitor_best_ask_ticks\n        if self._vs is None and bid is not None and ask is not None:\n            self._vs = max(1, (ask - bid + 1) // 2)\n        if self._vs not in TARGET_SPREADS:\n            return actions\n        present = {Side.BUY: bid is not None, Side.SELL: ask is not None}\n        for side in (Side.BUY, Side.SELL):\n            if not present[side]:\n                if self._vprev[side]:\n                    self._vleft[side] = self._vk\n            else:\n                self._vleft[side] = 0\n            self._vprev[side] = present[side]\n        blocked = {sd for sd in (Side.BUY, Side.SELL) if self._vleft[sd] > 0 and not present[sd]}\n        for sd in blocked:\n            self._vleft[sd] -= 1\n        if not blocked:\n            return actions\n        acts = list(actions or [])\n        out = [a for a in acts if not (isinstance(a, PlaceOrder) and a.side in blocked)]\n        if any(isinstance(a, CancelAll) for a in out):\n            return out\n        cancelled = {a.order_id for a in out if isinstance(a, CancelOrder)}\n        for o in state.own_orders:\n            if o.side in blocked and o.order_id not in cancelled:\n                out.append(CancelOrder(o.order_id))\n        return out\n",
 "code_sha256": "82a618d923a29a9fa6d69756367a98b06b86e40fa4452c218c17e73a509adb3b",
 "assembled_sha256": "85ad7f11afb2d8dea8c34306aba12867b9bd61354e65665f9274192e0c95cb8d",
 "comparator_sha256": "3c07bdcd221ac25729c3ebc92b21ac9e2014510ecb85816c4391ed81e933291f",
 "tuning": {
  "seeds": "330000..330199",
  "selected": "K=2",
  "selection": "best overall paired mean over target spreads 1-4",
  "stats": {
   "seeds": "330000..330199",
   "n": 200,
   "complete": true,
   "missing_seeds": [],
   "overall": {
    "n": 200,
    "sum_d": -46.471604193699655,
    "sum_d2": 3815.4184138533537,
    "mean_diff": -0.23235802096849828,
    "se": 0.3091819472077692,
    "comparator_mean": 97.4672213329115,
    "candidate_mean": 97.234863311943,
    "retail_diff": -1.1335143304814994,
    "arb_diff": 0.9011563095120003
   },
   "by_spread": {
    "1": {
     "n": 54,
     "sum_d": -59.997115884800074,
     "sum_d2": 3461.8852975884024,
     "mean_diff": -1.1110577015703718,
     "se": 1.0891795230871877,
     "comparator_mean": 46.182844338938885,
     "candidate_mean": 45.07178663736851,
     "retail_diff": -4.144705119666666,
     "arb_diff": 3.0336474181092594
    },
    "2": {
     "n": 57,
     "sum_d": 13.368159983100082,
     "sum_d2": 133.6331901926737,
     "mean_diff": 0.23452912251052774,
     "se": 0.20219500947190472,
     "comparator_mean": 87.23571902150526,
     "candidate_mean": 87.47024814401578,
     "retail_diff": -0.04643423456842113,
     "arb_diff": 0.28096335707192915
    },
    "3": {
     "n": 49,
     "sum_d": -11.241547478399845,
     "sum_d2": 165.67409751391025,
     "mean_diff": -0.22941933629387437,
     "se": 0.26333085965467656,
     "comparator_mean": 112.87398754092447,
     "candidate_mean": 112.64456820463062,
     "retail_diff": -0.004732724144897342,
     "arb_diff": -0.22468661216122265
    },
    "4": {
     "n": 40,
     "sum_d": 11.398899186400184,
     "sum_d2": 54.225828558367034,
     "mean_diff": 0.2849724796600046,
     "se": 0.1807701756513377,
     "comparator_mean": 162.4077324637125,
     "candidate_mean": 162.6927049433725,
     "retail_diff": -0.0002533695199987918,
     "arb_diff": 0.2852258491824998
    }
   }
  }
 },
 "paired": {
  "seeds": "440000..440499",
  "n": 500,
  "complete": true,
  "missing_seeds": [],
  "overall": {
   "n": 500,
   "sum_d": -71.19560727259969,
   "sum_d2": 21751.460090946515,
   "mean_diff": -0.14239121454519937,
   "se": 0.2951941208523611,
   "comparator_mean": 101.4369248623788,
   "candidate_mean": 101.29453364783359,
   "retail_diff": -0.32188855778239955,
   "arb_diff": 0.1794973432353998
  },
  "by_spread": {
   "1": {
    "n": 142,
    "sum_d": -69.14863503060008,
    "sum_d2": 20623.434832080755,
    "mean_diff": -0.48696221852535265,
    "se": 1.0140793412581235,
    "comparator_mean": 28.7146791778493,
    "candidate_mean": 28.227716959323942,
    "retail_diff": -0.9637163500915497,
    "arb_diff": 0.47675413156760543
   },
   "2": {
    "n": 110,
    "sum_d": 6.696930725699981,
    "sum_d2": 155.0663837420595,
    "mean_diff": 0.060881188415454375,
    "se": 0.11357363850323848,
    "comparator_mean": 88.78927784058273,
    "candidate_mean": 88.85015902899818,
    "retail_diff": -0.07351537835909085,
    "arb_diff": 0.13439656676818196
   },
   "3": {
    "n": 119,
    "sum_d": 0.6129972670003898,
    "sum_d2": 758.078343244088,
    "mean_diff": 0.005151237537818402,
    "se": 0.23234945391167766,
    "comparator_mean": 143.37780997585293,
    "candidate_mean": 143.38296121339076,
    "retail_diff": -0.06997586716806618,
    "arb_diff": 0.07512710471092367
   },
   "4": {
    "n": 129,
    "sum_d": -9.356900234699978,
    "sum_d2": 214.8805318796146,
    "mean_diff": -0.07253411034651146,
    "se": 0.11389686124003795,
    "comparator_mean": 153.5829305298,
    "candidate_mean": 153.51039641945349,
    "retail_diff": -0.05955610361007652,
    "arb_diff": -0.012978006744186114
   }
  }
 },
 "failures": 0,
 "check_values": [
  17.5126554022,
  20.6298693268,
  2.3903113616,
  248.006347259
 ],
 "python_version": "3.12.3",
 "seconds_per_simulation": 0.7075376479625702,
 "notes": "Spread per seed for by_spread is the sampled cfg.competitor.spread_ticks. Simulator unmodified at b244530, single-process, no sandbox. Screen, not a promotion."
}