Ranked by best acted-spread mean_diff/se (flagged rows retained). Inputs: the nine `.imd/reads/artifacts/item-{key}` files, with keys below; input hashes match the brief. Numbers are copied reports; flags explained in JSON. | key | spread | mean_diff | se | overall | flag | |---|---:|---:|---:|---:|---| | f-fill-rate-size | 3 | 0.7212 | 1.0548 | 0.0072 | yes | | f-vol-size | 1 | -4.7860 | 3.8758 | -12.8390 | yes | | f-highp-ask-drop | 3 | -0.1580 | 0.0841 | -0.1920 | — | | f-lowp-bid-drop | 4 | -10.7842 | 4.0759 | -24.3182 | — | | f-two-step-split | 2 | -21.4740 | 7.0699 | -30.0189 | yes | | f-late-widen | 3 | -17.6452 | 3.1830 | -14.1493 | yes | | f-inventory-skew | 4 | -46.4462 | 6.7932 | -56.4988 | yes | | f-join-only | 4 | -92.8054 | 8.3655 | -61.6424 | — | | f-rival-size-cap | — | — | — | — | yes | ```json { "rows": [ { "key": "f-vol-size", "mech": "Scale every new order by min(1, v0 / EWMA[(rival midpoint one-step change)^2])**g.", "spreads_acted": [ 1, 2, 3, 4 ], "off_equals_n": { "passed": true, "seeds": "310000..310009 inclusive", "n": 10, "steps_per_seed": 2000, "callbacks_compared": 20000, "comparison": "Exact returned-action sequence equality against an independent N instance on each identical StepState; disabled branch returns N actions before sizing." }, "code_sha256": "e0a27f75a26b4e6d978764b48b198db972ed2820eb3a75fe5d04b6f90803328f", "assembled_sha256": "4e8343c129f3dcfadc401d6ce25bc4b4273e9e31a15add31ce1e09a8dd1e621e", "complete": false, "h_n": 493, "incumbent_mean": 95.37844434617749, "mean_diff": -12.838973177541176, "se": 1.316817931232726, "retail_diff": -5.370424580787222, "arb_diff": -7.468548596748073, "tuning_mean": -11.5659875839595, "tuning_se": 1.5508213136305924, "by_spread": { "1": { "n": 128, "mean_diff": -4.7859868463171855, "se": 3.8757761762071157, "sum_d": -612.6063163285997, "sum_d2": 247123.72134861592 }, "2": { "n": 118, "mean_diff": -9.068721372361018, "se": 1.1109404681146897, "sum_d": -1070.1091219386, "sum_d2": 26743.73098421466 }, "3": { "n": 133, "mean_diff": -14.436529667850374, "se": 1.4712604544662957, "sum_d": -1920.0584458240999, "sum_d2": 65720.82691267588 }, "4": { "n": 114, "mean_diff": -23.919648179267543, "se": 2.7447259406254383, "sum_d": -2726.8398924365, "sum_d2": 162271.86180940262 } }, "failures": [ { "phase": "tuning", "seed": 320049, "strategy": "v4g1", "error": "Insufficient free cash for order collateral", "treatment": "Excluded from paired statistics; not rerun. No score imputation." }, { "phase": "tuning", "seed": 320151, "strategy": "v1g1", "error": "orderbook_pm_challenge.market.OrderBookError: Insufficient free cash for order collateral", "treatment": "Excluded from paired statistics; not rerun. No score imputation." }, { "phase": "holdout", "seed": 430013, "strategy": "v025g05", "error": "orderbook_pm_challenge.market.OrderBookError: Insufficient free cash for order collateral", "treatment": "Excluded from paired statistics; not rerun. No score imputation." }, { "phase": "holdout", "seed": 430108, "strategy": "v025g05", "error": "orderbook_pm_challenge.market.OrderBookError: Insufficient free cash for order collateral", "treatment": "Excluded from paired statistics; not rerun. No score imputation." }, { "phase": "holdout", "seed": 430152, "strategy": "v025g05", "error": "orderbook_pm_challenge.market.OrderBookError: Insufficient free cash for order collateral", "treatment": "Excluded from paired statistics; not rerun. No score imputation." }, { "phase": "holdout", "seed": 430170, "strategy": "v025g05", "error": "orderbook_pm_challenge.market.OrderBookError: Insufficient free cash for order collateral", "treatment": "Excluded from paired statistics; not rerun. No score imputation." }, { "phase": "holdout", "seed": 430225, "strategy": "v025g05", "error": "orderbook_pm_challenge.market.OrderBookError: Insufficient free cash for order collateral", "treatment": "Excluded from paired statistics; not rerun. No score imputation." }, { "phase": "holdout", "seed": 430238, "strategy": "v025g05", "error": "orderbook_pm_challenge.market.OrderBookError: Insufficient free cash for order collateral", "treatment": "Excluded from paired statistics; not rerun. No score imputation." }, { "phase": "holdout", "seed": 430345, "strategy": "v025g05", "error": "orderbook_pm_challenge.market.OrderBookError: Insufficient free cash for order collateral", "treatment": "Excluded from paired statistics; not rerun. No score imputation." } ], "check_values_ok": true, "python_version": "3.12.3", "flag": "h_n below 500; incomplete screen; incumbent_mean differs from common 95.54201511346659; 2 tuning and 7 holdout collateral failures; statistics exclude failed pairs", "code": "from dataclasses import replace as _vol_replace\nfrom orderbook_pm_challenge.types import PlaceOrder as _VolPlaceOrder\n\nclass Strategy(_N):\n # Midpoints and variance are in ticks and ticks squared, respectively.\n VOL_V0 = 0.25\n VOL_G = 0.5\n VOL_ALPHA = 0.05\n VOL_ENABLED = True\n VOL_SPREADS = (1, 2, 3, 4)\n\n def on_step(self, state):\n actions = super().on_step(state)\n bid = state.competitor_best_bid_ticks\n ask = state.competitor_best_ask_ticks\n if state.step == 0 or not hasattr(self, '_vol_prev_mid'):\n self._vol_prev_mid = None\n self._vol_ewma = self.VOL_V0\n if bid is not None and ask is not None:\n mid = (bid + ask) / 2.0\n if self._vol_prev_mid is not None:\n change = mid - self._vol_prev_mid\n self._vol_ewma = ((1.0 - self.VOL_ALPHA) * self._vol_ewma\n + self.VOL_ALPHA * change * change)\n self._vol_prev_mid = mid\n if not self.VOL_ENABLED or self.s not in self.VOL_SPREADS:\n return actions\n factor = min(1.0, self.VOL_V0 / max(self._vol_ewma, 1e-30)) ** self.VOL_G\n if factor == 1.0:\n return actions\n return [_vol_replace(a, quantity=a.quantity * factor)\n if isinstance(a, _VolPlaceOrder) else a for a in actions\n if not isinstance(a, _VolPlaceOrder) or a.quantity * factor >= 0.01]\n" }, { "key": "f-late-widen", "mech": "f-late-widen", "spreads_acted": [ 1, 2, 3, 4 ], "off_equals_n": { "seeds": "310000..310009", "steps_compared": 20000, "mismatched_steps": 0, "equal": true, "how": "LATE_W=0; N and overlay fed the identical StepState every step, repr of action lists compared" }, "code_sha256": "6d2f94dae65d158bf0b26183a5f70750229109979d6054769d5127bc0c2974c6", "assembled_sha256": "65be48cbb1500035cc0ab5ede6aa060fa3f67e1c02a1b99ced01be5ed6173404", "complete": true, "h_n": 500, "incumbent_mean": 95.54587347343701, "mean_diff": -14.1492594920404, "se": 1.1544593355294224, "retail_diff": -15.234180397404089, "arb_diff": 1.0849209053983841, "tuning_mean": -15.557867378893507, "tuning_se": 1.6582036835384026, "by_spread": { "1": { "n": 131, "mean_diff": -9.981147680944275, "se": 1.6789486872704973, "sum_d": -1307.5303462037, "sum_d2": 61055.9873498945 }, "2": { "n": 120, "mean_diff": -14.273862225034167, "se": 1.7876139792467771, "sum_d": -1712.8634670041, "sum_d2": 70081.8273283534 }, "3": { "n": 133, "mean_diff": -17.645202755372928, "se": 3.183034907190754, "sum_d": -2346.811966464599, "sum_d2": 219282.29516225538 }, "4": { "n": 116, "mean_diff": -14.719172123687922, "se": 2.068477196760355, "sum_d": -1707.423966347799, "sum_d2": 82208.36341510764 } }, "failures": { "count": 4, "note": "Failed runs counted with the edge the engine reported at failure (SimulationResult with failed=True); N had no failures. Probable cause: re-placed resting orders were emitted after N's new orders, which could have used the collateral the cancels freed.", "runs": [ { "seed": 430009, "strategy": "candidate W=100", "error": "orderbook_pm_challenge.market.OrderBookError: Insufficient free cash for order collateral", "spread": 1, "total_edge_at_failure": 4.260062 }, { "seed": 430171, "strategy": "candidate W=100", "error": "orderbook_pm_challenge.market.OrderBookError: Insufficient free cash for order collateral", "spread": 1, "total_edge_at_failure": -11.363443 }, { "seed": 430185, "strategy": "candidate W=100", "error": "orderbook_pm_challenge.market.OrderBookError: Insufficient free cash for order collateral", "spread": 1, "total_edge_at_failure": -6.619581 }, { "seed": 430212, "strategy": "candidate W=100", "error": "orderbook_pm_challenge.market.OrderBookError: Insufficient free cash for order collateral", "spread": 3, "total_edge_at_failure": 343.390495 } ] }, "check_values_ok": true, "python_version": "3.10.12", "flag": "incumbent_mean differs from common 95.54201511346659; 4 holdout collateral failures included at partial edge despite complete=true; alternate excluding-failures estimate is in input paired.overall_excluding_failed_seeds", "code": "# f-late-widen overlay: in the last W steps every N order sits one tick\n# further from the rival midpoint (bids -1, asks +1); sizes unchanged.\n# N is shown its own orders at the prices it asked for, so its logic is unchanged.\nfrom dataclasses import replace as _dc_replace\nfrom orderbook_pm_challenge.types import CancelAll as _CA, CancelOrder as _CO, PlaceOrder as _PO, Side as _Side\n\nLATE_W = 100\nACT_SPREADS = (1, 2, 3, 4)\n\n\nclass Strategy(_N):\n def __init__(self, *a, **k):\n super().__init__(*a, **k)\n self._lw_shift = {}\n self._lw_n = 0\n\n def _lw_tick(self, side, px):\n q = px - 1 if side == _Side.BUY else px + 1\n return q if 1 <= q <= 99 else px\n\n def on_step(self, state):\n sh = self._lw_shift\n if sh:\n live = {o.order_id for o in state.own_orders}\n for oid in list(sh):\n if oid not in live:\n del sh[oid]\n view = tuple(_dc_replace(o, price_ticks=o.price_ticks - sh[o.order_id]) if o.order_id in sh else o\n for o in state.own_orders)\n state = _dc_replace(state, own_orders=view)\n acts = super().on_step(state)\n if LATE_W <= 0 or state.steps_remaining > LATE_W or getattr(self, \"s\", None) not in ACT_SPREADS:\n return acts\n acts = list(acts or [])\n out = []\n cancelled = set()\n wiped = False\n for a in acts:\n if isinstance(a, _PO):\n oid = a.client_order_id\n if oid is None:\n self._lw_n += 1\n oid = \"lw%d\" % self._lw_n\n px = self._lw_tick(a.side, a.price_ticks)\n sh[oid] = px - a.price_ticks\n out.append(_PO(side=a.side, price_ticks=px, quantity=a.quantity, client_order_id=oid))\n else:\n if isinstance(a, _CA):\n wiped = True\n elif isinstance(a, _CO):\n cancelled.add(a.order_id)\n out.append(a)\n pre, post = [], []\n if not wiped:\n for o in state.own_orders:\n if o.order_id in sh or o.order_id in cancelled:\n continue\n px = self._lw_tick(o.side, o.price_ticks)\n if px == o.price_ticks:\n continue\n pre.append(_CO(o.order_id))\n post.append(_PO(side=o.side, price_ticks=px, quantity=o.remaining_quantity, client_order_id=o.order_id))\n sh[o.order_id] = px - o.price_ticks\n return pre + out + post\n" }, { "key": "f-inventory-skew", "mech": "inventory skew", "spreads_acted": [ 2, 3, 4 ], "off_equals_n": true, "code_sha256": "0725b55be555ff20a085e74e51f532210c5d7bb55a590955b758e7dfaf40d15d", "assembled_sha256": "fa00ff432fbe160c6397704a4313cd90e569fded28229ea7f7967ff692de1c87", "complete": true, "h_n": 500, "incumbent_mean": 95.54201511346659, "mean_diff": -56.4987774177128, "se": 4.423790267557522, "retail_diff": -45.355344661552806, "arb_diff": -11.143432756183397, "tuning_mean": -50.568438502013, "tuning_se": 4.923959363288024, "by_spread": { "1": { "n": 131, "mean_diff": -51.73284595400535, "se": 11.297336275881472, "sum_d": -6777.0028199747, "sum_d2": 2524129.254939428 }, "2": { "n": 120, "mean_diff": -60.939560609653334, "se": 7.217871865480589, "sum_d": -7312.7472731584, "sum_d2": 1189590.3942012796 }, "3": { "n": 133, "mean_diff": -65.95395390040225, "se": 8.673202554857506, "sum_d": -8771.8758687535, "sum_d2": 1899180.210208813 }, "4": { "n": 116, "mean_diff": -46.44623057732586, "se": 6.793207634426026, "sum_d": -5387.7627469698, "sum_d2": 865851.1881671026 } }, "failures": [], "check_values_ok": true, "python_version": "3.12.3", "flag": "declared spreads_acted excludes 1 but by_spread[1] is nonzero; code gates instantaneous spread, not fixed self.s; declared scope is not established", "code": "from orderbook_pm_challenge.types import PlaceOrder\n\nclass Strategy(_N):\n _inventory_threshold = 1.0\n\n def on_step(self, state):\n actions = super().on_step(state)\n if state.competitor_best_bid_ticks is None or state.competitor_best_ask_ticks is None:\n return actions\n spread = state.competitor_best_ask_ticks - state.competitor_best_bid_ticks\n # A one-tick move is only useful when there is room in the observed rival spread.\n if spread < 2:\n return actions\n skew = 0\n if state.yes_inventory > self._inventory_threshold:\n skew = -1\n elif state.yes_inventory < -self._inventory_threshold:\n skew = 1\n if not skew:\n return actions\n out = []\n for action in actions:\n if isinstance(action, PlaceOrder):\n price = max(1, min(99, action.price_ticks + skew))\n out.append(PlaceOrder(action.side, price, action.quantity, action.client_order_id))\n else:\n out.append(action)\n return out\n" }, { "key": "f-rival-size-cap", "mech": "rival size cap: cap each order to k times rival displayed size at the same tick or nearest rival level; k in [1, 2, 4]", "spreads_acted": [], "off_equals_n": true, "code_sha256": "a5a4dd37a4e05335a51e150d2b92be0649da438b6bb7a5dec84846dc39614882", "assembled_sha256": "ff9d5b57b4ab3645e7f79743ce2ee03c8cc6b0aa54613ada3f3b5915728e69bf", "complete": false, "h_n": 0, "incumbent_mean": null, "mean_diff": null, "se": null, "retail_diff": null, "arb_diff": null, "tuning_mean": null, "tuning_se": null, "by_spread": { "1": { "n": 0, "mean_diff": null, "se": null, "sum_d": null, "sum_d2": null }, "2": { "n": 0, "mean_diff": null, "se": null, "sum_d": null, "sum_d2": null }, "3": { "n": 0, "mean_diff": null, "se": null, "sum_d": null, "sum_d2": null }, "4": { "n": 0, "mean_diff": null, "se": null, "sum_d": null, "sum_d2": null } }, "failures": [ { "kind": "mechanism_infeasible", "detail": "The required rival displayed size/depth is absent from StepState. It is not an unknown requester-owned value. Reading hidden market/config state or replacing size with a guessed or estimated notional would violate the specified mechanism and observable-input constraint. No spread supplies the missing quantity.", "sources": [ "https://raw.githubusercontent.com/danrobinson/prediction-market-challenge/b244530ee2a6247b5f930830eeca9dd950da0e7e/orderbook_pm_challenge/types.py", "https://raw.githubusercontent.com/danrobinson/prediction-market-challenge/b244530ee2a6247b5f930830eeca9dd950da0e7e/orderbook_pm_challenge/market.py", "https://raw.githubusercontent.com/danrobinson/prediction-market-challenge/b244530ee2a6247b5f930830eeca9dd950da0e7e/orderbook_pm_challenge/runner.py" ] }, { "kind": "screen_not_completed", "detail": "No active variant could be implemented faithfully, so none was frozen. All 200 tuning seeds and 500 holdout seeds remain unrun; all 4000 finalist seeds also remain untouched. Null statistics mean unmeasured, not zero effect. The supplied code is explicitly disabled and raises if enabled; it must not be represented as a functioning rival-size cap." } ], "check_values_ok": true, "python_version": "3.13.5", "flag": "h_n below 500; incomplete screen; mechanism infeasible per input: rival sizes unavailable; disabled diagnostic only; no tuning or holdout", "code": "# Disabled diagnostic only: the pinned StepState exposes rival prices, not sizes.\n# This is not an implementation or a performance screen of the requested cap.\nclass Strategy(_N):\n rival_size_cap_enabled = False\n\n def on_step(self, state):\n actions = super().on_step(state)\n if self.rival_size_cap_enabled:\n raise RuntimeError(\n \"Exact rival-size cap unavailable: StepState has no rival sizes.\"\n )\n return actions\n" }, { "key": "f-join-only", "mech": "f-join-only: join only - N orders priced inside rival best quotes moved back to rival best tick on that side, size unchanged", "spreads_acted": [ 2, 3, 4 ], "off_equals_n": true, "code_sha256": "1c295cb7f4cdb7cab1c60e123b72d2faa744daf0a79fd7239c5afff158245cf0", "assembled_sha256": "17b4ee0942e9465ec087eaf415bf1c8a346eb4dd2f6f372583df3ace4a5dcc93", "complete": true, "h_n": 500, "incumbent_mean": 95.54201511346659, "mean_diff": -61.6423864491908, "se": 3.6300082516999357, "retail_diff": -52.8363311357714, "arb_diff": -8.806055313437202, "tuning_mean": -64.4958457421355, "tuning_se": 5.909012173069934, "by_spread": { "1": { "n": 131, "mean_diff": 0.0, "se": 0.0, "sum_d": 0.0, "sum_d2": 0.0 }, "2": { "n": 120, "mean_diff": -67.55151788591667, "se": 5.836364262533413, "sum_d": -8106.1821463100005, "sum_d2": 1034006.6588980327 }, "3": { "n": 133, "mean_diff": -89.84646389126843, "se": 8.083838158413599, "sum_d": -11949.5796975387, "sum_d2": 2220884.6824154602 }, "4": { "n": 116, "mean_diff": -92.80544293747155, "se": 8.365531441646747, "sum_d": -10765.4313807467, "sum_d2": 1932652.0591608984 } }, "failures": 0, "check_values_ok": true, "python_version": "3.12.3", "flag": null, "code": "# Overlay f-join-only: N's new orders priced inside the rival's best quotes\n# are moved back to the rival's best tick on their side (size unchanged).\nJOIN_SPREADS = (2, 3, 4)\nJOIN_ON = True\n\n\nclass Strategy(_N):\n def on_step(self, state):\n actions = super().on_step(state)\n if not JOIN_ON:\n return actions\n s = getattr(self, \"s\", None)\n bid = state.competitor_best_bid_ticks\n ask = state.competitor_best_ask_ticks\n if s not in JOIN_SPREADS or bid is None or ask is None or actions is None:\n return actions\n out = []\n for a in actions:\n if isinstance(a, PlaceOrder):\n if a.side == Side.BUY and a.price_ticks > bid:\n a = PlaceOrder(a.side, bid, a.quantity, a.client_order_id)\n elif a.side == Side.SELL and a.price_ticks < ask:\n a = PlaceOrder(a.side, ask, a.quantity, a.client_order_id)\n out.append(a)\n return out\n" }, { "key": "f-fill-rate-size", "mech": "fill-rate adaptive size", "spreads_acted": [ 2, 3, 4 ], "off_equals_n": true, "code_sha256": "2eed99754103e32ef765bb44910bc40c3635f990186de8cd700378ff3e03ac46", "assembled_sha256": "1a301bbc492851942816bde716632d97c882316b94f48b380e8eb1215a5406fd", "complete": true, "h_n": 500, "incumbent_mean": 95.54201511346659, "mean_diff": 0.0072079097871993875, "se": 0.31783802378154985, "retail_diff": -0.4216279529919995, "arb_diff": 0.4288358627695998, "tuning_mean": 0.6606159068884991, "tuning_se": 0.5298262415524924, "by_spread": { "1": { "n": 131, "mean_diff": 0.0, "se": 0.0, "sum_d": 0.0, "sum_d2": 0.0 }, "2": { "n": 120, "mean_diff": -0.07682974078916728, "se": 0.20368406715749726, "sum_d": -9.219568894700073, "sum_d2": 593.1455418617153 }, "3": { "n": 133, "mean_diff": 0.72119358148421, "se": 1.0548057072466617, "sum_d": 95.91874633739992, "sum_d2": 19602.246329387068 }, "4": { "n": 116, "mean_diff": -0.7163381254232772, "se": 0.6091414845780005, "sum_d": -83.09522254910016, "sum_d2": 5009.375941392552 } }, "failures": { "holdout": 0, "holdout_detail": [], "tuning_frozen_variant": 0, "n_failures_tuning": 0, "note": "8 failures in the unguarded first tuning runs of A and B, fixed by the guard before freezing; see tried." }, "check_values_ok": true, "python_version": "3.12.3", "flag": "8 historical unguarded tuning failures reported; frozen guarded variant has zero failures", "code": "from collections import deque as _deque\n\n\nclass Strategy(_N):\n \"\"\"Fill-rate adaptive size: new quotes scale by clip(rolling/avg, LO, HI).\"\"\"\n ON = True\n LO = 0.6\n HI = 1.0\n SPREADS = (2, 3, 4)\n WINDOW = 200\n WARMUP = 400\n MIN_Q = 0.05\n\n def __init__(self):\n super().__init__()\n self._fr_win = _deque()\n self._fr_sum = 0.0\n self._fr_tot = 0.0\n self._fr_bid = None\n self._fr_ask = None\n self._fr_touched = False\n\n def _fr_scale(self, state):\n n = 0.0\n if self._fr_bid is not None:\n n += state.buy_filled_quantity * self._fr_bid / 100.0\n if self._fr_ask is not None:\n n += state.sell_filled_quantity * self._fr_ask / 100.0\n self._fr_tot += n\n self._fr_sum += n\n self._fr_win.append(n)\n if len(self._fr_win) > self.WINDOW:\n self._fr_sum -= self._fr_win.popleft()\n t = state.step\n if t < self.WARMUP or self._fr_tot <= 0.0:\n return 1.0\n ratio = max(self._fr_sum, 0.0) / (self._fr_tot / t * self.WINDOW)\n return max(self.LO, min(self.HI, ratio))\n\n def on_step(self, state):\n actions = super().on_step(state)\n if not self.ON:\n return actions\n k = self._fr_scale(state)\n out = actions\n if getattr(self, \"s\", None) in self.SPREADS:\n if k != 1.0:\n self._fr_touched = True\n out = self._fr_resize(state, actions, k)\n if self._fr_touched:\n out = self._fr_guard(state, out)\n self._fr_track(state, out)\n return out\n\n def _fr_guard(self, state, actions):\n \"\"\"Replay the book's collateral check; shrink or drop what would raise.\"\"\"\n live = {o.order_id: o for o in state.own_orders}\n bids = sum(o.price_ticks / 100.0 * o.remaining_quantity\n for o in live.values() if o.side.value == \"BUY\")\n sell_cash = max(0.0, state.reserved_cash - bids)\n free = state.free_cash\n held = 0.0\n out = []\n for a in actions:\n name = type(a).__name__\n if name == \"CancelOrder\":\n o = live.pop(a.order_id, None)\n if o is None:\n continue\n if o.side.value == \"BUY\":\n free += o.price_ticks / 100.0 * o.remaining_quantity\n else:\n kept = sum((1.0 - x.price_ticks / 100.0) * x.remaining_quantity\n for x in live.values() if x.side.value == \"SELL\")\n back = max(0.0, sell_cash - kept)\n free += back\n sell_cash -= back\n out.append(a)\n elif name == \"PlaceOrder\":\n p = a.price_ticks / 100.0\n room = max(0.0, free - 1e-6)\n if a.side.value == \"BUY\":\n top = room / p\n avail = 0.0\n else:\n resting = sum(x.remaining_quantity for x in live.values()\n if x.side.value == \"SELL\")\n avail = max(0.0, state.yes_inventory - resting - held)\n top = avail + room / (1.0 - p)\n q = a.quantity\n if q > top:\n q = int(top * 100) / 100.0\n if q < 0.01:\n continue\n a = type(a)(side=a.side, price_ticks=a.price_ticks, quantity=q,\n client_order_id=a.client_order_id)\n if a.side.value == \"BUY\":\n free -= p * q\n else:\n cover = min(q, avail)\n held += cover\n free -= (1.0 - p) * (q - cover)\n out.append(a)\n else:\n out.append(a)\n return out\n\n def _fr_resize(self, state, actions, k):\n need = 0.0\n for a in actions:\n if type(a).__name__ == \"PlaceOrder\":\n need += a.quantity * self._fr_unit(a)\n room = max(0.0, state.free_cash - need)\n out = []\n for a in actions:\n if type(a).__name__ != \"PlaceOrder\" or a.quantity < self.MIN_Q:\n out.append(a)\n continue\n q = a.quantity * k\n if q > a.quantity:\n u = self._fr_unit(a)\n extra = min(q - a.quantity, room / u) if u > 0 else 0.0\n room -= extra * u\n q = a.quantity + extra\n q = int(q * 100 + 1e-9) / 100.0\n if q < 0.01:\n continue\n out.append(type(a)(side=a.side, price_ticks=a.price_ticks, quantity=q,\n client_order_id=a.client_order_id))\n return out\n\n @staticmethod\n def _fr_unit(a):\n p = a.price_ticks / 100.0\n return p if a.side.value == \"BUY\" else 1.0 - p\n\n def _fr_track(self, state, actions):\n gone = {a.order_id for a in actions if type(a).__name__ == \"CancelOrder\"}\n bid = ask = None\n for o in state.own_orders:\n if o.order_id in gone:\n continue\n if o.side.value == \"BUY\":\n bid = o.price_ticks if bid is None else max(bid, o.price_ticks)\n else:\n ask = o.price_ticks if ask is None else min(ask, o.price_ticks)\n for a in actions:\n if type(a).__name__ == \"PlaceOrder\":\n if a.side.value == \"BUY\":\n bid = a.price_ticks if bid is None else max(bid, a.price_ticks)\n else:\n ask = a.price_ticks if ask is None else min(ask, a.price_ticks)\n self._fr_bid = bid\n self._fr_ask = ask\n" }, { "key": "f-two-step-split", "mech": "time split: half now, half next callback only if N still quotes the same side and price", "spreads_acted": [ 1, 2, 3, 4 ], "off_equals_n": { "equal": true, "seeds": [ 310000, 310009 ], "callbacks_checked": 20000, "tested_code_sha256": "3f68fbcd3a8015e23620242a253bcdd4a5fe136bc1f7f604558800abc81d57ca", "cached_N_score_match": true, "simulations": 10, "method": "Each repaired disabled-overlay simulation ran once. On every callback, an independent N shadow instance received the same StepState and its actions were compared exactly with the disabled overlay. Disabled actions were applied; final edge also matched the cached original N baseline within 1e-6. No incumbent SimulationEngine run was repeated." }, "code_sha256": "3f68fbcd3a8015e23620242a253bcdd4a5fe136bc1f7f604558800abc81d57ca", "assembled_sha256": "1885535f89ce281b31c208506fa0a764d919a16e88553d294cb48ee44700ceef", "complete": true, "h_n": 500, "incumbent_mean": 95.5459652894836, "mean_diff": -30.018884196527, "se": 3.9600400768283195, "retail_diff": -24.161496112528198, "arb_diff": -5.8573880840208, "tuning_mean": -38.94010401303, "tuning_se": 33.0168871820053, "by_spread": { "1": { "n": 131, "mean_diff": -25.81006585830382, "se": 6.133768812152205, "sum_d": -3381.1186274378, "sum_d2": 727988.6253399636 }, "2": { "n": 120, "mean_diff": -21.474041011005834, "se": 7.069946785370106, "sum_d": -2576.8849213207, "sum_d2": 769109.7594660247 }, "3": { "n": 133, "mean_diff": -36.65917402709398, "se": 8.116729839690986, "sum_d": -4875.6701456035, "sum_d2": 1335350.2009349312 }, "4": { "n": 116, "mean_diff": -35.998003481909485, "se": 10.172563515695284, "sum_d": -4175.7684039015, "sum_d2": 1530756.512277897 } }, "failures": [ { "phase": "original_tuning", "seed": 320041, "strategy": "all", "error": "orderbook_pm_challenge.market.OrderBookError: Insufficient free cash for order collateral", "repaired": true }, { "phase": "original_tuning", "seed": 320043, "strategy": "all", "error": "orderbook_pm_challenge.market.OrderBookError: Insufficient free cash for order collateral", "repaired": true }, { "phase": "original_tuning", "seed": 320057, "strategy": "all", "error": "orderbook_pm_challenge.market.OrderBookError: Insufficient free cash for order collateral", "repaired": true } ], "check_values_ok": true, "python_version": "Python 3.10.14 (39dc8d3c85a7, Aug 27 2024, 14:32:27)\n[PyPy 7.3.17 with GCC 10.2.1 20210130 (Red Hat 10.2.1-11)]", "flag": "incumbent_mean differs from common 95.54201511346659; 3 original tuning failures repaired before freeze; incumbent differs; tuning fields below use the 10-pair selection, not the 200-pair post-freeze replication", "code": "from dataclasses import replace as _split_replace\nfrom math import floor as _split_floor\nfrom orderbook_pm_challenge.types import PlaceOrder as _SplitPlace, CancelOrder as _SplitCancel, CancelAll as _SplitAll, Side as _SplitSide\n\nclass Strategy(_N):\n # An empty tuple is a strict passthrough, used for the off control.\n spreads_acted = (1, 2, 3, 4)\n\n def on_step(self, state):\n actions = list(super().on_step(state))\n if self.s not in self.spreads_acted:\n return actions\n due = getattr(self, '_split_pending', {})\n pending = {}\n live = {o.order_id: o for o in state.own_orders}\n output = []\n # Resolve cancellations first in the same order as N; additions are\n # represented separately so the quote-survival test sees final intent.\n additions = []\n def units(q):\n return max(0, int(_split_floor(float(q) * 100 + 1e-7)))\n for a in actions:\n if isinstance(a, _SplitAll):\n live.clear()\n additions.clear()\n output.append(a)\n elif isinstance(a, _SplitCancel):\n live.pop(a.order_id, None)\n additions = [(i, p) for i, p in additions if p.client_order_id != a.order_id]\n output.append(a)\n elif isinstance(a, _SplitPlace):\n key = (a.side, a.price_ticks)\n total = units(a.quantity)\n now = total // 2\n if now == 0:\n output.append(a)\n additions.append((len(output)-1, a))\n continue\n later = total - now\n pending[key] = pending.get(key, 0) + later\n p = _split_replace(a, quantity=now / 100)\n output.append(p)\n additions.append((len(output)-1, a))\n else:\n output.append(a)\n # At a newly requested quote, fold yesterday's deferred quantity into\n # today's first tranche, never exceeding N's current requested size.\n for index, original in additions:\n key = (original.side, original.price_ticks)\n room = units(original.quantity) - units(output[index].quantity)\n release = min(room, due.get(key, 0))\n if release:\n output[index] = _split_replace(output[index], quantity=(units(output[index].quantity)+release)/100)\n due[key] -= release\n quotes = {(o.side, o.price_ticks) for o in live.values()}\n quotes.update((a.side, a.price_ticks) for _, a in additions)\n # Upper-bound collateral for all surviving orders. Counting every sell\n # as uncovered is conservative even when YES inventory backs it.\n def collateral(side, tick, quantity):\n return quantity * (tick / 100 if side == _SplitSide.BUY else 1 - tick / 100)\n reserved = sum(collateral(o.side, o.price_ticks, o.remaining_quantity) for o in live.values())\n reserved += sum(collateral(output[i].side, output[i].price_ticks, output[i].quantity) for i, _ in additions)\n free = max(0.0, state.cash - reserved)\n serial = getattr(self, '_split_serial', 0)\n for (side, tick), quantity_units in due.items():\n if quantity_units <= 0 or (side, tick) not in quotes:\n continue\n cost_per_unit = (tick if side == _SplitSide.BUY else 100-tick) / 10000\n release = min(quantity_units, max(0, int(_split_floor((free+1e-10)/cost_per_unit))))\n if release:\n serial += 1\n output.append(_SplitPlace(side, tick, release/100, '_two_step_'+str(serial)))\n free -= release * cost_per_unit\n # A deferred tranche expires after exactly the next callback, including\n # when its quote disappears or collateral prevents its placement.\n self._split_pending = pending\n self._split_serial = serial\n # N may size from persistent private bookkeeping. Splitting changes\n # that bookkeeping's relation to the live book; cap every placement,\n # including its first tranche, against a safe collateral upper bound.\n shadow = {o.order_id: (o.side, o.price_ticks, o.remaining_quantity)\n for o in state.own_orders}\n safe = []\n anonymous = 0\n for a in output:\n if isinstance(a, _SplitAll):\n shadow.clear()\n safe.append(a)\n elif isinstance(a, _SplitCancel):\n shadow.pop(a.order_id, None)\n safe.append(a)\n elif isinstance(a, _SplitPlace):\n used = sum(collateral(side, tick, quantity)\n for side, tick, quantity in shadow.values())\n available = max(0.0, state.cash - used - 1e-8)\n unit_cost = collateral(a.side, a.price_ticks, 0.01)\n q = min(units(a.quantity), int(_split_floor(available / unit_cost)))\n if q <= 0:\n continue\n a = _split_replace(a, quantity=q / 100)\n safe.append(a)\n anonymous += 1\n identity = a.client_order_id if a.client_order_id is not None else ('_split_anon', anonymous)\n shadow[identity] = (a.side, a.price_ticks, a.quantity)\n else:\n safe.append(a)\n return safe\n" }, { "key": "f-lowp-bid-drop", "mech": "drop bids at very low probability: when the rival midpoint is below a cents, place no bids at all; tune a (3, 5, 8)", "spreads_acted": [ 1, 2, 3, 4 ], "off_equals_n": true, "code_sha256": "08bd50493fbfe3fbdb3f5943d0670ef30cd7747c572d1f89b434514e75764e9e", "assembled_sha256": "aa0bfae6008b597fed0038d697f020f8ed776005f35afd43d6f33d491b2d7223", "complete": true, "h_n": 500, "incumbent_mean": 95.542015, "mean_diff": -24.318202, "se": 3.726367, "retail_diff": -24.301712, "arb_diff": -0.01649, "tuning_mean": -17.195168, "tuning_se": 3.808452, "by_spread": { "1": { "n": 131, "mean_diff": -37.500988, "se": 9.799421, "sum_d": -4912.629408, "sum_d2": 1819596.540351 }, "2": { "n": 120, "mean_diff": -36.357551, "se": 9.06849, "sum_d": -4362.906133, "sum_d2": 1332976.162922 }, "3": { "n": 133, "mean_diff": -12.275166, "se": 4.480775, "sum_d": -1632.597142, "sum_d2": 372518.2408 }, "4": { "n": 116, "mean_diff": -10.784208, "se": 4.075897, "sum_d": -1250.968118, "sum_d2": 235107.273136 } }, "failures": 0, "check_values_ok": true, "python_version": "3.12.3", "flag": null, "code": "# f-lowp-bid-drop: when the rival midpoint is below A_CENTS, hold no bids.\nfrom orderbook_pm_challenge.types import CancelAll, CancelOrder, PlaceOrder, Side\n\n\nclass Strategy(_N):\n A_CENTS = 3 # 0 switches the overlay off\n SPREADS = (1, 2, 3, 4)\n\n def __init__(self, *args, **kwargs):\n super().__init__(*args, **kwargs)\n self._ov_gone = set() # ids this overlay cancelled behind N's back\n\n def _ov_active(self, state):\n if getattr(self, \"s\", None) not in self.SPREADS:\n return False\n # A missing side of the ladder counts as the edge of the price range.\n bid = state.competitor_best_bid_ticks\n ask = state.competitor_best_ask_ticks\n bid = 0 if bid is None else bid\n ask = 100 if ask is None else ask\n return (bid + ask) / 2.0 < self.A_CENTS\n\n def on_step(self, state):\n actions = list(super().on_step(state))\n active = self._ov_active(state)\n if not active and not self._ov_gone:\n return actions\n\n out = []\n cleared = False\n for act in actions:\n if isinstance(act, CancelOrder):\n # N may still cancel a bid that this overlay already removed:\n # the simulator fails the run on an unknown id.\n if act.order_id in self._ov_gone:\n self._ov_gone.discard(act.order_id)\n continue\n elif isinstance(act, CancelAll):\n cleared = True\n elif isinstance(act, PlaceOrder):\n if active and act.side is Side.BUY:\n continue\n self._ov_gone.discard(act.client_order_id)\n out.append(act)\n\n if active and not cleared:\n named = {a.order_id for a in out if isinstance(a, CancelOrder)}\n front = []\n for order in state.own_orders:\n if order.side is Side.BUY and order.order_id not in named:\n front.append(CancelOrder(order.order_id))\n self._ov_gone.add(order.order_id)\n out = front + out\n return out\n" }, { "key": "f-highp-ask-drop", "mech": "Drop asks when rival midpoint > 100 - a cents.", "spreads_acted": [ 1, 2, 3, 4 ], "off_equals_n": { "passed": true, "seeds": "310000..310009", "steps_per_seed": [ 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000 ], "total_steps": 20000 }, "code_sha256": "c476c9a74c381039bd49c3e06ab59eaa3d9fce94e2735ed6b996d3c5cc9409fc", "assembled_sha256": "86773e658cf9e2a5e141e83f635770227ddb9d0dfe5f0df9b0b4e75b5279d6eb", "complete": true, "h_n": 500, "incumbent_mean": 95.54201511346659, "mean_diff": -0.19199768489860003, "se": 0.042417202918670745, "retail_diff": -0.14105261955799994, "arb_diff": -0.050945065331800106, "tuning_mean": -0.1665081823429999, "tuning_se": 0.040030757514956994, "by_spread": { "1": { "n": 131, "mean_diff": -0.08128890732671758, "se": 0.029569087747374677, "sum_d": -10.648846859800003, "sum_d2": 15.755489207632083 }, "2": { "n": 120, "mean_diff": -0.2985862554933333, "se": 0.11582255111811876, "sum_d": -35.83035065919999, "sum_d2": 202.26269883877546 }, "3": { "n": 133, "mean_diff": -0.1579705850142858, "se": 0.08406620781885459, "sum_d": -21.01008780690001, "sum_d2": 127.38946268894176 }, "4": { "n": 116, "mean_diff": -0.24577204416724144, "se": 0.09281626469183593, "sum_d": -28.509557123400008, "sum_d2": 121.92907107706237 } }, "failures": [], "check_values_ok": true, "python_version": "3.12.3", "flag": null, "code": "from orderbook_pm_challenge.types import PlaceOrder, CancelOrder, Side\n\nclass Strategy(_N):\n ask_drop_a = 3\n ask_drop_enabled = True\n ask_drop_spreads = (1, 2, 3, 4)\n\n def on_step(self, state):\n actions = super().on_step(state)\n if not self.ask_drop_enabled or self.s not in self.ask_drop_spreads:\n return actions\n bid = state.competitor_best_bid_ticks\n ask = state.competitor_best_ask_ticks\n midpoint = ((0 if bid is None else bid) +\n (100 if ask is None else ask)) / 2\n if midpoint <= 100 - self.ask_drop_a:\n return actions\n # Cancel resting asks before applying N's remaining actions.\n cancels = [CancelOrder(order.order_id) for order in state.own_orders\n if order.side == Side.SELL]\n return cancels + [action for action in actions\n if not (isinstance(action, PlaceOrder)\n and action.side == Side.SELL)]\n" } ], "top": [ { "key": "f-highp-ask-drop", "code_sha256": "c476c9a74c381039bd49c3e06ab59eaa3d9fce94e2735ed6b996d3c5cc9409fc", "assembled_sha256": "86773e658cf9e2a5e141e83f635770227ddb9d0dfe5f0df9b0b4e75b5279d6eb", "code": "from orderbook_pm_challenge.types import PlaceOrder, CancelOrder, Side\n\nclass Strategy(_N):\n ask_drop_a = 3\n ask_drop_enabled = True\n ask_drop_spreads = (1, 2, 3, 4)\n\n def on_step(self, state):\n actions = super().on_step(state)\n if not self.ask_drop_enabled or self.s not in self.ask_drop_spreads:\n return actions\n bid = state.competitor_best_bid_ticks\n ask = state.competitor_best_ask_ticks\n midpoint = ((0 if bid is None else bid) +\n (100 if ask is None else ask)) / 2\n if midpoint <= 100 - self.ask_drop_a:\n return actions\n # Cancel resting asks before applying N's remaining actions.\n cancels = [CancelOrder(order.order_id) for order in state.own_orders\n if order.side == Side.SELL]\n return cancels + [action for action in actions\n if not (isinstance(action, PlaceOrder)\n and action.side == Side.SELL)]\n" }, { "key": "f-lowp-bid-drop", "code_sha256": "08bd50493fbfe3fbdb3f5943d0670ef30cd7747c572d1f89b434514e75764e9e", "assembled_sha256": "aa0bfae6008b597fed0038d697f020f8ed776005f35afd43d6f33d491b2d7223", "code": "# f-lowp-bid-drop: when the rival midpoint is below A_CENTS, hold no bids.\nfrom orderbook_pm_challenge.types import CancelAll, CancelOrder, PlaceOrder, Side\n\n\nclass Strategy(_N):\n A_CENTS = 3 # 0 switches the overlay off\n SPREADS = (1, 2, 3, 4)\n\n def __init__(self, *args, **kwargs):\n super().__init__(*args, **kwargs)\n self._ov_gone = set() # ids this overlay cancelled behind N's back\n\n def _ov_active(self, state):\n if getattr(self, \"s\", None) not in self.SPREADS:\n return False\n # A missing side of the ladder counts as the edge of the price range.\n bid = state.competitor_best_bid_ticks\n ask = state.competitor_best_ask_ticks\n bid = 0 if bid is None else bid\n ask = 100 if ask is None else ask\n return (bid + ask) / 2.0 < self.A_CENTS\n\n def on_step(self, state):\n actions = list(super().on_step(state))\n active = self._ov_active(state)\n if not active and not self._ov_gone:\n return actions\n\n out = []\n cleared = False\n for act in actions:\n if isinstance(act, CancelOrder):\n # N may still cancel a bid that this overlay already removed:\n # the simulator fails the run on an unknown id.\n if act.order_id in self._ov_gone:\n self._ov_gone.discard(act.order_id)\n continue\n elif isinstance(act, CancelAll):\n cleared = True\n elif isinstance(act, PlaceOrder):\n if active and act.side is Side.BUY:\n continue\n self._ov_gone.discard(act.client_order_id)\n out.append(act)\n\n if active and not cleared:\n named = {a.order_id for a in out if isinstance(a, CancelOrder)}\n front = []\n for order in state.own_orders:\n if order.side is Side.BUY and order.order_id not in named:\n front.append(CancelOrder(order.order_id))\n self._ov_gone.add(order.order_id)\n out = front + out\n return out\n" }, { "key": "f-join-only", "code_sha256": "1c295cb7f4cdb7cab1c60e123b72d2faa744daf0a79fd7239c5afff158245cf0", "assembled_sha256": "17b4ee0942e9465ec087eaf415bf1c8a346eb4dd2f6f372583df3ace4a5dcc93", "code": "# Overlay f-join-only: N's new orders priced inside the rival's best quotes\n# are moved back to the rival's best tick on their side (size unchanged).\nJOIN_SPREADS = (2, 3, 4)\nJOIN_ON = True\n\n\nclass Strategy(_N):\n def on_step(self, state):\n actions = super().on_step(state)\n if not JOIN_ON:\n return actions\n s = getattr(self, \"s\", None)\n bid = state.competitor_best_bid_ticks\n ask = state.competitor_best_ask_ticks\n if s not in JOIN_SPREADS or bid is None or ask is None or actions is None:\n return actions\n out = []\n for a in actions:\n if isinstance(a, PlaceOrder):\n if a.side == Side.BUY and a.price_ticks > bid:\n a = PlaceOrder(a.side, bid, a.quantity, a.client_order_id)\n elif a.side == Side.SELL and a.price_ticks < ask:\n a = PlaceOrder(a.side, ask, a.quantity, a.client_order_id)\n out.append(a)\n return out\n" } ], "notes": "Sources: each row copies .imd/reads/artifacts/item-{key}, supplied input hashes verified. All 9 UTF-8 overlay code hashes match; code retained for audit. Assembled hashes are copied, not independently reassembled. Metrics are copied, not recomputed; ratios only determine ranking on an acted spread. Nulls mean unmeasured. Checks compare the four supplied baseline values to their shared values at six-decimal precision; no simulations. Common incumbent mean 95.54201511346659; lowp 95.542015 is consistent rounding. complete preserves input claims, including late-widen failures. Historical failures conservatively flag fill-rate-size and two-step-split even after repair. top is a ranking, not a recommendation: all three lose overall; retain N (bf0d179f3e47d28819f6fa7e0d25548c2ced43374c216d36460b00a26a26ffae). No finalist evidence or promotion. Source-validation warnings supplied by requester: vol-size(2), late-widen(2), inventory-skew(1), fill-rate-size(1), two-step-split(2), lowp-bid-drop(1). Those external citations are unverified here; do not use their causal explanations as established facts. Rankings use only supplied numerical reports and local hash checks, not those citations. No statistics, missing evidence, or rival-size measurements fabricated." } ```