{
  "key": "f-probe-stopping",
  "approach": "Sequential value-of-information stopping over a 201-point probability posterior. Probe survival/sweeps use a noisy Bernoulli likelihood (0.12 retail sweep hazard; 0.995 toxic sweep likelihood), approximate diffusion and jump prediction, and last-step competitor bounds. Add 0.01 shares one tick inside N's best same-side quote only when estimated interval-variance reduction, valued by nearby backing exposure, exceeds expected arbitrage loss. Stop each side below the value threshold and restart after competitor quote movement or a one-tick posterior-mean shift. A just-swept overlay probe shrinks retained/new orders behind it to 35% for that callback. Added orders are hidden from N via dataclasses.replace; N is called every step. These posterior/value models are heuristic, not calibrated guarantees.",
  "tried": [
    {
      "variant": 1,
      "status": "aborted diagnostic, not a measurement",
      "n_completed": 19,
      "description": "An extra self-crossing guard prevented all additions in these initial tuning seeds. Removed the unnecessary guard after examining callback actions, not incumbent source. No complete score claimed."
    },
    {
      "variant": 2,
      "status": "complete",
      "description": "Corrected guard; remaining parameters unchanged. Tuned on 310000..310199, selecting spreads with positive per-spread tuning mean (fallback: highest mean if none positive). Frozen before holdout. No other variants.",
      "all_spreads_tuning": {
        "1": {
          "n": 47,
          "mean_diff": -1.0669208764148936,
          "se": 0.6189473385318448
        },
        "2": {
          "n": 57,
          "mean_diff": 0.048753446861402004,
          "se": 0.12634558802317827
        },
        "3": {
          "n": 53,
          "mean_diff": 0.012579087616979442,
          "se": 0.014121497390995235
        },
        "4": {
          "n": 43,
          "mean_diff": -0.04226889511628031,
          "se": 0.034103838704347994
        }
      }
    },
    {
      "incumbent_sha256": "bf0d179f3e47d28819f6fa7e0d25548c2ced43374c216d36460b00a26a26ffae",
      "seed_310000_edge": 17.1160017503,
      "expected_rounded_edge": 17.116002,
      "matches": true
    },
    {
      "off_equality_seeds": "310000..310009",
      "assembled_equality_seeds": "310000..310004",
      "assembled_equals_s1": true,
      "off_callbacks_checked": 20000,
      "synthetic_checks": "informative probe placement, swept backing shrink, order hiding, excluded-spread identity, sequential survival stopping and move reset",
      "blindness": "No incumbent source, other strategy source, earlier network result or leaderboard was viewed, printed, or searched; only opaque hash/loading/required assembly transformation and callback actions were used."
    }
  ],
  "next": "Retain N unless a later authorized finalist measurement establishes a gain. N already emits tiny inside orders, so incremental probing often fails this value test; do not interpret this single overlay holdout as a leaderboard or finalist promotion.",
  "spreads_acted": [
    2,
    3
  ],
  "off_equals_n": true,
  "code": "from dataclasses import replace as _probe_replace\nfrom math import sqrt as _probe_sqrt\nfrom orderbook_pm_challenge.types import PlaceOrder as _PP, CancelOrder as _PC, CancelAll as _PA, Side as _PS\n\nclass Strategy(BaseStrategy):\n    # The incumbent is opaque; only callback inputs and returned actions are used.\n    SPREADS = (2, 3)\n    ENABLED = True\n    SHRINK = 0.35\n\n    def __init__(self):\n        self.n = _N()\n        self.spread = None\n        self.probes = {}\n        self.weights = None\n        self.last_quotes = None\n        self.anchor = None\n        self.stopped = set()\n        self.serial = 0\n\n    def on_step(self, state):\n        if self.spread is None:\n            b, a = state.competitor_best_bid_ticks, state.competitor_best_ask_ticks\n            self.spread = max(1, (a-b+1)//2) if b is not None and a is not None else 1\n        if not self.ENABLED or self.spread not in self.SPREADS:\n            return self.n.on_step(state)\n        own = {o.order_id:o for o in state.own_orders}\n        visible = tuple(o for o in state.own_orders if o.order_id not in self.probes)\n        clean = _probe_replace(state, own_orders=visible)\n        actions = list(self.n.on_step(clean))\n        b = state.competitor_best_bid_ticks\n        a = state.competitor_best_ask_ticks\n        lo, hi = (b if b is not None else 0), (a if a is not None else 100)\n        if self.weights is None:\n            self.weights = [1.0 if lo <= i*.5 <= hi else 0.000001 for i in range(201)]\n        w = self.weights\n        # Diffusion plus a small jump hazard, followed by the last-step bracket.\n        mass = sum(w)\n        w = [(.84*w[i]+.08*w[max(0,i-1)]+.08*w[min(200,i+1)])*.998 + mass*.002/201 for i in range(201)]\n        w = [v*(1 if lo <= i*.5 <= hi else .001) for i,v in enumerate(w)]\n        swept = {}\n        for oid,(side, tick, quantity) in self.probes.items():\n            filled = oid not in own or own[oid].remaining_quantity < quantity-.005\n            # A retail arrival can also sweep a tiny probe: use a noisy likelihood.\n            for i in range(201):\n                toxic = i*.5 < tick if side == _PS.BUY else i*.5 > tick\n                pf = .995 if toxic else .12\n                w[i] *= pf if filled else 1-pf\n            if filled:\n                swept[side] = tick\n                self.stopped.discard(side)\n        z = sum(w)\n        w = [v/z for v in w]\n        self.weights = w\n        mean = sum(i*.5*v for i,v in enumerate(w))\n        variance = sum((i*.5-mean)**2*v for i,v in enumerate(w))\n        quotes = (b,a)\n        if self.last_quotes != quotes or (self.anchor is not None and abs(mean-self.anchor)>1):\n            self.stopped.clear()\n            self.anchor = mean\n        if self.anchor is None:\n            self.anchor = mean\n        self.last_quotes = quotes\n        # Release surviving probes before the incumbent's action list.\n        out = [_PC(oid) for oid in self.probes if oid in own]\n        self.probes = {}\n        # Track the book resulting from N's actions, without inspecting N itself.\n        live = dict((o.order_id,o) for o in visible)\n        revised = []\n        for action in actions:\n            if isinstance(action,_PA):\n                live.clear()\n            elif isinstance(action,_PC):\n                live.pop(action.order_id,None)\n            elif isinstance(action,_PP):\n                tick = swept.get(action.side)\n                behind = tick is not None and (action.price_ticks<tick if action.side==_PS.BUY else action.price_ticks>tick)\n                if behind:\n                    q = max(.01, int(action.quantity*self.SHRINK*100)/100)\n                    action = _probe_replace(action,quantity=q)\n            revised.append(action)\n        # Existing resting orders also shrink if N chose to retain them.\n        for oid,o in list(live.items()):\n            tick = swept.get(o.side)\n            behind = tick is not None and (o.price_ticks<tick if o.side==_PS.BUY else o.price_ticks>tick)\n            if behind:\n                revised.extend([_PC(oid),_PP(o.side,o.price_ticks,max(.01,int(o.remaining_quantity*self.SHRINK*100)/100),oid)])\n        out.extend(revised)\n        # Build a reservation-conservative view of final orders for probe budgeting.\n        book = {oid:(o.side,o.price_ticks,o.remaining_quantity) for oid,o in visible_dict(visible).items()}\n        for act in revised:\n            if isinstance(act,_PA): book.clear()\n            elif isinstance(act,_PC): book.pop(act.order_id,None)\n            elif isinstance(act,_PP): book[act.client_order_id or ('new',len(book))]=(act.side,act.price_ticks,act.quantity)\n        reserve = sum(q*(p/100 if side==_PS.BUY else 1-p/100) for side,p,q in book.values())\n        budget = state.cash-reserve\n        for side in (_PS.BUY,_PS.SELL):\n            candidates = [(p,q) for s,p,q in book.values() if s==side]\n            if not candidates or side in self.stopped: continue\n            best = max(p for p,q in candidates) if side==_PS.BUY else min(p for p,q in candidates)\n            tick = best+(1 if side==_PS.BUY else -1)\n            other = [p for s,p,q in book.values() if s!=side]\n            if not 1<=tick<=99: continue\n            exposure = sum(q for p,q in candidates if abs(p-best)<=1)\n            pf = [(.995 if (i*.5<tick if side==_PS.BUY else i*.5>tick) else .12) for i in range(201)]\n            prob = sum(v*f for v,f in zip(w,pf))\n            mfill = sum(i*.5*v*f for i,(v,f) in enumerate(zip(w,pf)))/max(prob,1e-12)\n            msurvive = (mean-prob*mfill)/max(1-prob,1e-12)\n            reduction = prob*(mfill-mean)**2+(1-prob)*(msurvive-mean)**2\n            loss = .01*.01*sum(v*max(0,tick-i*.5 if side==_PS.BUY else i*.5-tick) for i,v in enumerate(w))\n            value = .15*.01*min(exposure,20)*reduction/max(1,_probe_sqrt(variance))\n            if value <= loss+.00001 or reduction < .002:\n                self.stopped.add(side)\n                continue\n            if budget < .02: continue\n            self.serial += 1\n            oid = '__sequential_probe_%d'%self.serial\n            out.append(_PP(side,tick,.01,oid))\n            self.probes[oid]=(side,tick,.01)\n            budget -= .01\n        return out\n\ndef visible_dict(orders):\n    return {o.order_id:o for o in orders}\n",
  "code_sha256": "7fa10543f5349a27a9f5e739cf38e7fb62bfe02144cbad8a44a6202030a7745a",
  "assembled_sha256": "46434cb8ca37b6f4fd6b7e7e7d5a4ebf60dde34edfb20076eca024ee4ba77c8c",
  "tuning": {
    "n": 200,
    "mean_diff": 0.017228190573999123,
    "se": 0.036002742279609735
  },
  "paired": {
    "first_seed": 410000,
    "last_seed": 410499,
    "n": 500,
    "complete": true,
    "incumbent_mean": 104.4137531881468,
    "mean_diff": 0.016767629280000168,
    "se": 0.030340765993081643,
    "sum_d": 8.383814640000084,
    "sum_d2": 229.82081591704718,
    "retail_diff": -0.053693320717199906,
    "arb_diff": 0.07046094999859989,
    "failures": []
  },
  "by_spread": {
    "1": {
      "runs": 115,
      "incumbent_mean": 28.495154459731303,
      "mean_diff": 0.0,
      "se": 0.0,
      "sum_d": 0.0,
      "sum_d2": 0.0,
      "retail_diff": 0.0,
      "arb_diff": 0.0
    },
    "2": {
      "runs": 116,
      "incumbent_mean": 97.76626247947759,
      "mean_diff": 0.04460301534482666,
      "se": 0.12894293783950417,
      "sum_d": 5.173949779999893,
      "sum_d2": 222.0253652186517,
      "retail_diff": -0.261482267302586,
      "arb_diff": 0.3060852826525858
    },
    "3": {
      "runs": 138,
      "incumbent_mean": 128.4054514027384,
      "mean_diff": 0.02325989028985646,
      "se": 0.020208358226073298,
      "sum_d": 3.2098648600001916,
      "sum_d2": 7.7954506983954825,
      "retail_diff": 0.02525567136594221,
      "arb_diff": -0.0019957810753623525
    },
    "4": {
      "runs": 131,
      "incumbent_mean": 151.67248160310686,
      "mean_diff": 0.0,
      "se": 0.0,
      "sum_d": 0.0,
      "sum_d2": 0.0,
      "retail_diff": 0.0,
      "arb_diff": 0.0
    }
  },
  "seconds_per_simulation": 0.8543097922010348
}
