{
  "key": "f-join-timing",
  "approach": "Blind composition over incumbent N SHA-256 bf0d179f3e47d28819f6fa7e0d25548c2ced43374c216d36460b00a26a26ffae. N seed 310000 edge 17.1160017503 matches required 17.116002 after rounding. Hidden per-level ahead estimates use first-step spread, best-price depletion/replacement events, join timestamps and probe residuals. Quote notional starts at the midpoint of the documented range, is updated by a bounded own-fill-per-crossed-level proxy, and is NOT an identified competitor depth measurement. Same-price probes are added only on detected best-price change events, sized down behind larger estimated queues, then expire after one step. Added order IDs are hidden from N with dataclasses.replace; N is called every step. N actions remain intact except probe expiry cancellations. Unselected spreads return N actions exactly. Tune-only selection chooses the event variant and positive-mean spreads; if all spread cells lose, it chooses the least negative cell. No finalist seeds were run.",
  "tried": [
    {
      "variant": "depletion",
      "description": "4 dollar notional target discounted by estimated depth; one-step probes; depletion quote-change events only",
      "tuning_by_spread": {
        "1": {
          "n": 47,
          "incumbent_mean": 30.59600304578298,
          "mean_diff": -5.591501572740425,
          "se": 0.7900718536015471,
          "sum_d": -262.80057391879996,
          "sum_d2": 2818.9994825750737,
          "retail_diff": -0.05539995050851221,
          "arb_diff": -5.536101622265957,
          "failures": 0
        },
        "2": {
          "n": 57,
          "incumbent_mean": 81.35713208259824,
          "mean_diff": -4.4993068797543865,
          "se": 0.7775867832607036,
          "sum_d": -256.46049214600004,
          "sum_d2": 3083.9091846592114,
          "retail_diff": 0.07001147705087758,
          "arb_diff": -4.569318356789473,
          "failures": 0
        },
        "3": {
          "n": 53,
          "incumbent_mean": 115.06691980369057,
          "mean_diff": -4.124495482958493,
          "se": 0.7189302635778209,
          "sum_d": -218.59826059680015,
          "sum_d2": 2326.0756934496203,
          "retail_diff": 0.003912328137736316,
          "arb_diff": -4.128407811130188,
          "failures": 0
        },
        "4": {
          "n": 43,
          "incumbent_mean": 112.9910514314628,
          "mean_diff": -2.36502822027907,
          "se": 1.030342525461792,
          "sum_d": -101.696213472,
          "sum_d2": 2157.7743446704244,
          "retail_diff": 0.07902624676046724,
          "arb_diff": -2.44405446705814,
          "failures": 0
        }
      }
    },
    {
      "variant": "both_events",
      "description": "4 dollar notional target discounted by estimated depth; one-step probes; depletion and replacement quote-change events",
      "tuning_by_spread": {
        "1": {
          "n": 47,
          "incumbent_mean": 30.59600304578298,
          "mean_diff": -8.05860713095532,
          "se": 1.0934051271301737,
          "sum_d": -378.7545351549,
          "sum_d2": 5636.980175019645,
          "retail_diff": -0.055278853925533354,
          "arb_diff": -8.003328277089361,
          "failures": 0
        },
        "2": {
          "n": 57,
          "incumbent_mean": 81.35713208259824,
          "mean_diff": -5.932034863349121,
          "se": 1.095506939649847,
          "sum_d": -338.1259872108999,
          "sum_d2": 5836.607516127944,
          "retail_diff": 0.08953453299649156,
          "arb_diff": -6.021569396321052,
          "failures": 0
        },
        "3": {
          "n": 53,
          "incumbent_mean": 115.06691980369057,
          "mean_diff": -5.052093957079249,
          "se": 1.000598521580833,
          "sum_d": -267.7609797252002,
          "sum_d2": 4112.053665841451,
          "retail_diff": 0.02562519997169876,
          "arb_diff": -5.077719157073584,
          "failures": 0
        },
        "4": {
          "n": 43,
          "incumbent_mean": 112.9910514314628,
          "mean_diff": -3.245506399872095,
          "se": 0.8732619074272928,
          "sum_d": -139.5567751945001,
          "sum_d2": 1830.1633713274393,
          "retail_diff": -0.003439805099998272,
          "arb_diff": -3.242066594802326,
          "failures": 0
        }
      }
    },
    {
      "validation": "Mechanism-off actions matched N on every callback of 10 full tuning-seed simulations (310000..310009). Assembled actions matched standalone S1 on every callback of 5 full tuning-seed simulations (310010..310014). Synthetic checks covered event-only placement, cancellation, order hiding and collateral exhaustion. Default ChallengeConfig and ParameterVariance; 2000 steps; serial in-process execution; no sandbox. Both policies evaluated once per holdout seed. All statistics include every completed paired seed, with failures counted rather than silently dropped. seconds_per_simulation is holdout wall time divided by twice the completed pair count.",
      "callbacks_checked": 30000,
      "chosen_variant": "depletion"
    }
  ],
  "next": "Do not promote: the paired holdout fails the positive-gain, twice-SE threshold. Best-price changes do not reveal remaining depth: replenishments occur before the callback and therefore precede new probes in FIFO. Future work should identify depletion before replenishment rather than treating a fresh quote as an empty queue.",
  "spreads_acted": [
    4
  ],
  "off_equals_n": true,
  "code": "from dataclasses import replace as _jt_replace\nfrom math import floor as _jt_floor\nfrom orderbook_pm_challenge.types import PlaceOrder as _JTPlace, CancelOrder as _JTCancel, CancelAll as _JTAll, Side as _JTSide\n\nclass Strategy:\n    # Frozen after tuning. Queue estimates use public history only.\n    SPREADS = (4,)\n    SIZE_NOTIONAL = 4.0\n    REPLACEMENTS = False\n\n    def __init__(self):\n        self.n = _N()\n        self.spread = None\n        self.previous = None\n        self.added = {}\n        self.levels = {}\n        self.notional = 48.0\n        self.flow = { _JTSide.BUY: 0.0, _JTSide.SELL: 0.0 }\n        self.events = 0\n\n    def on_step(self, state):\n        bid, ask = state.competitor_best_bid_ticks, state.competitor_best_ask_ticks\n        if self.spread is None:\n            self.spread = max(1, (ask - bid + 1) // 2) if bid is not None and ask is not None else 0\n        if self.spread not in self.SPREADS:\n            return self.n.on_step(state)\n        visible = tuple(o for o in state.own_orders if o.order_id not in self.added)\n        hidden = tuple(o for o in state.own_orders if o.order_id in self.added)\n        # All probes last one step: N receives no probe order IDs and can never\n        # accidentally retain or cancel one. Cash and fills remain fully visible.\n        actions = list(self.n.on_step(_jt_replace(state, own_orders=visible)))\n        cancel_all = any(isinstance(a, _JTAll) for a in actions)\n        prefix = [] if cancel_all else [_JTCancel(o.order_id) for o in hidden]\n        # A probe filled behind an older competitor proves that queue was cleared.\n        live = {o.order_id: o for o in hidden}\n        for oid, (side, tick, quantity, joined, ahead) in self.added.items():\n            remaining = live[oid].remaining_quantity if oid in live else 0.0\n            filled = max(0.0, quantity - remaining)\n            if filled > 0:\n                self.levels[(side, tick)] = (0.0, joined)\n        self.added = {}\n        events = []\n        if self.previous is not None:\n            for side, old, new, filled in (\n                (_JTSide.BUY, self.previous[0], bid, state.buy_filled_quantity),\n                (_JTSide.SELL, self.previous[1], ask, state.sell_filled_quantity),\n            ):\n                if old is None or new is None:\n                    continue\n                self.flow[side] += filled * old / 100.0\n                if new == old:\n                    # Visible participant fills are a lower-bound flow proxy,\n                    # not a direct observation of hidden competitor volume.\n                    ahead, joined = self.levels.get((side, new), (self.notional * 100 / new, -1))\n                    if filled > 0 and any(o.side == side and o.price_ticks == new for o in visible):\n                        ahead = 0.0\n                    self.levels[(side, new)] = (ahead, joined)\n                    continue\n                depleted = new < old if side == _JTSide.BUY else new > old\n                crossed = max(1, abs(new - old))\n                if depleted:\n                    # Censored method-of-moments proxy, bounded by the documented\n                    # quote-notional range. No hidden simulator fields are used.\n                    observation = max(24.0, min(72.0, self.flow[side] / crossed))\n                    self.notional = 0.95 * self.notional + 0.05 * observation\n                    self.flow[side] = 0.0\n                    self.levels[(side, old)] = (0.0, state.step - 1)\n                    # The newly exposed best may have been partially swept.\n                    ahead = max(0.0, self.notional - min(self.notional, filled * old / 100.0)) * 100 / new\n                else:\n                    # A replacement arrives before our callback, so it is ahead\n                    # of a new probe even though its submitted step is the same.\n                    ahead = self.notional * 100 / new\n                self.levels[(side, new)] = (ahead, state.step)\n                if depleted or self.REPLACEMENTS:\n                    events.append((side, new, ahead))\n        self.previous = (bid, ask)\n        # Conservative collateral bound: ignore all cancellation refunds and\n        # charge sells as fully uncovered. Thus probes cannot overspend N's cash.\n        budget = max(0.0, state.free_cash)\n        for a in actions:\n            if isinstance(a, _JTPlace):\n                unit = a.price_ticks / 100.0 if a.side == _JTSide.BUY else 1.0 - a.price_ticks / 100.0\n                budget -= a.quantity * unit\n        additions = []\n        for side, tick, ahead in events:\n            if budget <= 0.02 or any(isinstance(a, _JTPlace) and a.side == side and a.price_ticks == tick for a in actions):\n                continue\n            unit = tick / 100.0 if side == _JTSide.BUY else 1.0 - tick / 100.0\n            # Smaller size behind a longer estimated queue. Join only on a\n            # depletion/replacement event, never on an unchanged quote.\n            depth_notional = ahead * tick / 100.0\n            target = self.SIZE_NOTIONAL / (1.0 + depth_notional / 48.0)\n            quantity = _jt_floor(min(target / (tick / 100.0), max(0.0, budget - 0.01) / unit) * 100.0) / 100.0\n            if quantity < 0.01:\n                continue\n            oid = '_join_timing_%d_%s' % (state.step, side.value)\n            additions.append(_JTPlace(side, tick, quantity, oid))\n            self.added[oid] = (side, tick, quantity, state.step, ahead)\n            budget -= quantity * unit\n            self.events += 1\n        return prefix + actions + additions\n",
  "code_sha256": "56c54021a1e04a1ba1a46cd74fd82a20acf24e314d3beedd2090ce697eb7aa02",
  "assembled_sha256": "4baf6f540c53e4cca01a8aebec16db2b3ef3b84aa7f3e171ff5cbca7edf057ee",
  "tuning": {
    "n": 200,
    "mean_diff": -0.50848106736,
    "se": 0.23003515929090654
  },
  "paired": {
    "n": 500,
    "incumbent_mean": 104.4137531881468,
    "mean_diff": -0.48611712687180036,
    "se": 0.08468698293516504,
    "sum_d": -243.05856343590017,
    "sum_d2": 1907.5402576449499,
    "retail_diff": 0.06351087063600043,
    "arb_diff": -0.5496279975049998,
    "failures": 0,
    "first_seed": 410000,
    "last_seed": 410499,
    "complete": true
  },
  "by_spread": {
    "1": {
      "incumbent_mean": 28.495154459731307,
      "mean_diff": 0.0,
      "se": 0.0,
      "sum_d": 0.0,
      "sum_d2": 0.0,
      "retail_diff": 0.0,
      "arb_diff": 0.0,
      "runs": 115
    },
    "2": {
      "incumbent_mean": 97.76626247947758,
      "mean_diff": 0.0,
      "se": 0.0,
      "sum_d": 0.0,
      "sum_d2": 0.0,
      "retail_diff": 0.0,
      "arb_diff": 0.0,
      "runs": 116
    },
    "3": {
      "incumbent_mean": 128.4054514027384,
      "mean_diff": 0.0,
      "se": 0.0,
      "sum_d": 0.0,
      "sum_d2": 0.0,
      "retail_diff": 0.0,
      "arb_diff": 0.0,
      "runs": 138
    },
    "4": {
      "incumbent_mean": 151.67248160310686,
      "mean_diff": -1.8554088811900775,
      "se": 0.29245425541254577,
      "sum_d": -243.05856343590017,
      "sum_d2": 1907.5402576449499,
      "retail_diff": 0.24240790319084135,
      "arb_diff": -2.0978167843702282,
      "runs": 131
    }
  },
  "seconds_per_simulation": 0.6515364919789135
}
