# Merge 02 of batch r2-fresh-b: ten blind mechanism items All 10 items are present, all ran 1000 of 1000 holdout seeds with no failures, and no row is flagged. The top two are `f-boundary-asymmetry` and `f-horizon-schedule`. No row beats B, so nothing here is a promotion. All figures are copied from the item results listed under Inputs. ## Ranking | # | key | mechanism_diff | se | retail diff | arb diff | reference_diff | item's own S0 mean | flag | |---|---|---|---|---|---|---|---|---| | 1 | f-boundary-asymmetry | 15.3591320844349 | 1.647981277225783 | -0.9206800697662 | 16.2798121542086 | -95.5945598859886 | -11.2578138180412 | none | | 2 | f-horizon-schedule | 9.27 | 0.639 | 10.556 | -1.285 | -23.163 | 67.263 | none | | 3 | f-breakeven-size | 2.8697899464045 | 0.24341249155458802 | -2.6839379970061 | 5.5537279434106 | -101.72311687220571 | -4.8970286662279 | none | | 4 | f-inventory-dp | 1.1374 | 0.0898 | -1.0419 | 2.1793 | -91.6037 | 6.9547 | none | | 5 | f-reservation-skew | 0.5006 | 0.0886 | -0.3582 | 0.8588 | -93.3495 | 5.8458 | none | | 6 | f-adverse-timer | -0.2336805274765 | 0.2545525900445268 | 0.0572795797 | -0.2909601071765 | -110.34725149579 | -10.417692815931199 | none | | 7 | f-queue-aware | -0.7336 | 0.0359 | -0.9458 | 0.2123 | -92.8255 | 7.6039 | none | | 8 | f-geometric-ladder | -1.0385 | 0.0454 | 0.0198 | -1.0582 | -100.278 | 0.4563 | none | | 9 | f-variance-kelly | -2.1595373820516 | 0.40891258417564375 | -9.3628134530752 | 7.2032760710273 | -97.143476221531 | 4.7119393129029 | none | | 10 | f-spread-switch | -13.1981522195026 | 1.2279953771157022 | -4.3786226169557 | -8.8195296025401 | -166.4452238593074 | -53.5511934874225 | none | ## Caveats - **The ranking does not compare like with like.** Each mechanism_diff is measured against that item's own S0, and those S0 means run from -53.55 to 67.26. A gain on a weak base may not carry over to the current best. `reference_diff` is the comparison with B. - **Sources that did not hold.** Six items had sources fail when re-read: f-inventory-dp (1), f-reservation-skew (1), f-queue-aware (1), f-geometric-ladder (2), f-adverse-timer (1), f-horizon-schedule (3). The result files contain no source list or URLs, so which claims those sources backed could not be determined. The paired figures are reported as simulator runs, not quotes from a page. Rule statements in those rows' `mechanism` and `next` text should be treated as unconfirmed until read against the pinned simulator. This matters most for f-horizon-schedule, which is in `top`. These failures are not one of the brief's flag reasons, so those rows keep `flag: null`. - **b_mean.** It is written at different precisions: 99.69587815238229, 99.6958781523823, 99.6959 and 99.696. These agree at the coarsest precision written (3 decimals), so I treated them as equal and flagged nothing. Rows keep the value as written. - **f-boundary-asymmetry.** Its graft text says "the tuned power"; the frozen value is `BOUNDARY_POWER = -1.0`, which shrinks size near the boundary. Powers +0.5 and +1 lost about 11.8 and 11.9 against S0 on tuning seeds. The item's S0 mean is -11.26, so the gain is on a weak base, and the item itself says to test it as a graft on new seeds. - **f-horizon-schedule.** The item warns against assuming +9 on another base: on tuning seeds about two thirds of the gain came from R>=500, where its S0's fixed horizon of 300 was too cautious. It also reports two S0 parts that may matter more, measured on tuning seeds only and never alone on holdout: cover buying +24.02 (se 2.68) and queue-front orders plus capital floor +16.61 (se 2.43). - **f-breakeven-size.** It tuned on only 100 seeds (115040..115139), and it discloses six S0 prototypes against a cap of four once pilots are counted. - **f-adverse-timer.** Its diff is within one standard error of zero, and it had the opposite sign on tuning seeds (+0.14). Its S0 never updates its probability estimate after step 0, which the item says likely swamps any timer effect. - **f-spread-switch.** Its diff is exactly 0 on spreads 1 and 2, because the S1 table matches S0 there; the whole loss comes from spreads 3 and 4. It was already negative on tuning seeds, and the item says the test should be repeated on a stronger estimator. - **Items advising against their own graft.** f-geometric-ladder, f-queue-aware and f-variance-kelly each advise against using their graft as built. f-queue-aware adds that its weak S0 says little about the effect on B. - **Precision.** f-horizon-schedule's figures are rounded in the item, so its retail and arb diffs sum to 9.271 against a stated 9.27. `h_seeds` is a string in some items and a two-element array in others, and is copied as written. ## Checks run on this merge - All 10 input files match the SHA-256 values in the brief. - All 10 `code` fields hash to their `code_sha256`. - In all 10 items, s1_mean minus s0_mean matches mechanism_diff, and s1_mean minus b_mean matches reference_diff, to the precision written. - f-boundary-asymmetry: the 1000 per-seed samples match their hash and reproduce the stated diff, retail, arb and se. Re-running S0 and S1 on the pinned simulator for seeds 200000-200005 matched the per-seed differences to 6 decimals. - f-horizon-schedule: S0 and S1 ran on the pinned simulator for seeds 200000-200011 without failures. The item ships no per-seed data, so its figures could not be compared seed by seed. - Tuning seeds do not overlap the holdout in any item. Finalist seeds 900000-903999 were not run here. - The other rows' figures are copied as reported and were not re-run. ## Merge object ```json { "rows": [ { "key": "f-boundary-asymmetry", "mechanism": "Blind boundary-distance collateral scaling. S0 estimates probability from competitor best-quote midpoint (missing bid=0, ask=100), quotes at least 1.5 cents away with a recent-move volatility buffer, ", "code_sha256": "0f382e329f1f9209a13e774ffd827d4558899c2eaa4649c6e2d127b6b6a079bb", "h_seeds": [ 200000, 200999 ], "h_n": 1000, "h_complete": true, "mechanism_diff": 15.3591320844349, "mechanism_se": 1.647981277225783, "mechanism_retail_diff": -0.9206800697662, "mechanism_arb_diff": 16.2798121542086, "reference_diff": -95.5945598859886, "reference_se": 5.177436735687836, "b_mean": 99.6958781523823, "failures": [], "graft": "Keep the host probability, quotes and base quantities. If p<0.25 multiply bid quantity by min(8,(0.25/max(p,0.01))**power); if p>0.75 multiply ask quantity by min(8,(0.25/max(1-p,0.01))**power). Use the tuned power and reapply host collateral limits. Change no other rule.", "next": "Test a boundary-facing quantity taper as an isolated graft onto a stronger strategy using new assigned seeds. The blind baseline is intentionally simple; this standalone S1 is not a replacement for B. No promotion is claimed and reserved finalist seeds were not run. Do not retune on this holdout.", "flag": null }, { "key": "f-horizon-schedule", "mechanism": "Blind build from the simulator and its rules only. S0 tracks an interval for p from ladder sweeps, own fills and 0.01-share probes, quotes one tick inside the competitor, keeps an order that sits ahea", "code_sha256": "7df8ececb4960c3b7770305e99055dcdcb2786d3c929f3610cacb77a6863c2f5", "h_seeds": "200000..200999", "h_n": 1000, "h_complete": true, "mechanism_diff": 9.27, "mechanism_se": 0.639, "mechanism_retail_diff": 10.556, "mechanism_arb_diff": -1.285, "reference_diff": -23.163, "reference_se": 2.691, "b_mean": 99.696, "failures": [], "graft": "Compute adverse and gain with steps left R: Z=V(R)*ppf(p), next p=Phi((Z+dZ)/V(R-1)), V matched over Poisson jumps; at R=1 next p is 1 with probability p. Size from P(N>C)=adverse/(flow*gain), no quote when that is >=1. Inside the outer tick use p=V(R)*(pdf(z)+z*edge). Limit bought cover to flow*(R-1)*mean notional; ramp any cash floor to 0 over the last 200.", "next": "1) Graft the R schedule onto B and measure it paired; do not assume +9: on tuning seeds (S1 variant 2 minus S0, net edge by steps remaining) R>=1000 gave +5.51, 500-999 +1.51, 200-499 +0.10, 50-199 +0.68, 10-49 +2.30, below 10 +0.42. The last 50 steps are the part least tied to S0's fixed horizon. 2", "flag": null }, { "key": "f-breakeven-size", "mechanism": "Blind mechanism. S0 infers probability in ticks from the competitor side that most recently moved, quotes two ticks around it when inside the competitor, and uses a fixed four-unit notional cap select", "code_sha256": "f4bfc616ca493987f95e5432035d45087edea45b5485d24e05fc9ff0d718997c", "h_seeds": "200000..200999", "h_n": 1000, "h_complete": true, "mechanism_diff": 2.8697899464045, "mechanism_se": 0.24341249155458802, "mechanism_retail_diff": -2.6839379970061, "mechanism_arb_diff": 5.5537279434106, "reference_diff": -101.72311687220571, "reference_se": 5.769046797216588, "b_mean": 99.6958781523823, "failures": [], "graft": "Track per-side partial retail fills, adverse markouts and fill rates from prior public aggregate fills. At each quote, solve retail rate * edge * demand-tail(q) = calibrated adverse rate * markout; cap q by collateral and a fixed notional budget. Keep the host strategy’s prices.", "next": "The measured size change is positive but its absolute score is far below B. Graft only the adaptive size calculation onto a stronger quote/probability estimator, then measure it paired on fresh seeds. The fill classifier uses competitor-derived markout, which can confuse retail with adverse flow.", "flag": null }, { "key": "f-inventory-dp", "mechanism": "Blind build from the simulator only. S0 (<150 lines): estimates last step's probability as an interval [lo,hi] in ticks. Unswept hidden-competitor best bid/ask bound it, and so do our own last quotes ", "code_sha256": "babe7b41cd1b556bbd22ca4ffa44777a3c5d570e7d8a761b90730b6233ea4375", "h_seeds": "200000..200999", "h_n": 1000, "h_complete": true, "mechanism_diff": 1.1374, "mechanism_se": 0.0898, "mechanism_retail_diff": -1.0419, "mechanism_arb_diff": 2.1793, "reference_diff": -91.6037, "reference_se": 5.3678, "b_mean": 99.6959, "failures": [], "graft": "Solve once at step 0: V_h(q)=V_{h-1}(q)-G*var_h*q^2+f*max(0,e+V_{h-1}(q+1)-V_{h-1}(q))+f*max(0,e+V_{h-1}(q-1)-V_{h-1}(q)), grid of +-60 lots, var_h = model per-step probability variance. Each step, interpolate the two gains at the net YES-NO inventory and scale the bid/ask lots by clamp(gain/e,0,2). Rescale G (1e-3 here), e (edge per lot) and f (fill rate per lot per step) to the host strategy.", "next": "The mechanism gives a real but small gain (+1.1 on a weak S0 at ~7, far below B at ~100). It works through inventory as a toxicity signal, not through risk or capacity, because the score ignores inventory. Graft it onto B with GAMMA rescaled to B's lot size and edge per share, and measure paired aga", "flag": null }, { "key": "f-reservation-skew", "mechanism": "Blind build from simulator source only. S0: probability estimate from the competitor ladder's arb sweeps (asks swept => p just under new best ask; bids swept => p just over new best bid), quotes 1 tic", "code_sha256": "2a3dfecdaa853ce8978ea92a5773c59ff81f3c2135473d59ea3b0577d9bba01f", "h_seeds": "200000-200999", "h_n": 1000, "h_complete": true, "mechanism_diff": 0.5006, "mechanism_se": 0.0886, "mechanism_retail_diff": -0.3582, "mechanism_arb_diff": 0.8588, "reference_diff": -93.3495, "reference_se": 5.48, "b_mean": 99.6959, "failures": [], "graft": "After your fair-value estimate p (ticks) each step: q = yes_inventory - no_inventory; v = H*sd_step(p,H)^2 (sd_step = one-step sd of p in price units); r = p - 100*gamma*q*v; quote bid/ask around r instead of p, keeping your own margins and clips. gamma=0.06 here (about 0.5 tick of skew per 10 shares at p=0.5, H=2000); retune gamma on your base.", "next": "The mechanism is real but small: +0.50 +- 0.09 on holdout, almost all of it lower arbitrage loss (+0.86) bought with some retail edge (-0.36). Try it on B with gamma swept around 0.03-0.1 in B's own units, and an asymmetric version (skew only the side that would add to inventory). The baseline here ", "flag": null }, { "key": "f-adverse-timer", "mechanism": "Blind mechanism test: an adverse-selection timer added to a from-scratch passive maker. S0 quotes a fixed half-spread around a probability estimate anchored once at the competitor midpoint at step 0 (", "code_sha256": "8e9ed8909b277e13d697138b083235303b02238e93bd1612384ba9806e7515e0", "h_seeds": "200000-200999", "h_n": 1000, "h_complete": true, "mechanism_diff": -0.2336805274765, "mechanism_se": 0.2545525900445268, "mechanism_retail_diff": 0.0572795797, "mechanism_arb_diff": -0.2909601071765, "reference_diff": -110.34725149579, "reference_se": 5.692085279089404, "b_mean": 99.69587815238229, "failures": [], "graft": "Per side, keep a cooldown counter and a widen counter. On a step where buy_filled_quantity/sell_filled_quantity>0, set that side's cooldown=2, widen_left=3. Skip placing that side's quote while cooldown>0 (decrement each step). When placing it again, add +4 ticks away from your normal price while widen_left>0, decrementing once per actual placement.", "next": "On the 115000-115499 tuning seeds the lightest-touch timer (cooldown=2, widen=4, duration=3) beat its S0 base by +0.14 mean total_edge, but on the 200000-200999 holdout the paired mechanism_diff was -0.23 +/- 0.25 (not significant, and the wrong sign), so this mechanism as implemented here does not ", "flag": null }, { "key": "f-queue-aware", "mechanism": "Blind build from the simulator source only. S0 (98 lines): fair value in ticks inferred from the static competitor ladder (start at its mid; ask lifted -> fair>=ask-0.5, bid dropped -> fair<=bid+0.5; ", "code_sha256": "8c83ca11bce688a820e6390439df27f853e496565a995dcd72532bef492c63d2", "h_seeds": "200000..200999", "h_n": 1000, "h_complete": true, "mechanism_diff": -0.7336, "mechanism_se": 0.0359, "mechanism_retail_diff": -0.9458, "mechanism_arb_diff": 0.2123, "reference_diff": -92.8255, "reference_se": 5.4357, "b_mean": 99.6959, "failures": [], "graft": "Per side keep consumed=notional taken from competitor best level: reset when its tick changes, +expected retail notional/step while you are not strictly better, =full after you were filled at that tick. If improving by 1 tick is allowed but 48-consumed <= JOIN_Q, quote at the competitor tick and leave the order resting. Measured here: -0.73+-0.04/sim; not recommended.", "next": "Do not graft as built: joining the competitor's tick lost retail flow (-0.95/sim) worth far more than the arb loss it avoided (+0.21/sim); every threshold lost on tuning, monotonically worse as joining got more frequent. The blind estimate of the competitor's remaining size (hidden notional 24-72, u", "flag": null }, { "key": "f-geometric-ladder", "mechanism": "Blind build from the simulator only. S0 (97 lines): keeps an interval [lo,hi] (ticks) for the fair probability from the competitor's best bid/ask. The arbitrageur sweeps every resting ask below p and ", "code_sha256": "836af37a1889ec053188fb9479cdb137e04a8c8e770ce7278162c0b59ca2bef7", "h_seeds": "200000..200999", "h_n": 1000, "h_complete": true, "mechanism_diff": -1.0385, "mechanism_se": 0.0454, "mechanism_retail_diff": 0.0198, "mechanism_arb_diff": -1.0582, "reference_diff": -100.278, "reference_se": 5.4292, "b_mean": 99.6959, "failures": [], "graft": "Replace each side's single quote (tick t, size Q) with LEVELS=3 orders at t, t-3, t-6 for bids (t, t+3, t+6 for asks), sizes Q, 0.3Q, 0.09Q, skipping ticks outside 1..99 and stopping when collateral runs out. Measured here it lowered total edge (deep levels mostly feed the arbitrageur), so graft only to test, not to promote.", "next": "The geometric ladder does not pay here: deeper levels sit behind the static competitor ladder, so retail almost never reaches them (retail gain +0.02) while jumps and fast end-of-run moves sweep them for the arbitrageur (arb -1.06). Mechanism is a take-away for strategies like this. The S0 baseline ", "flag": null }, { "key": "f-variance-kelly", "mechanism": "Blind fresh mechanism: estimate probability as the visible competitor quote midpoint (missing sides bounded by 0/1). Estimate uncertainty V as squared quote width / 12 plus an EWMA (alpha=0.05) of squ", "code_sha256": "60fe920718e3f1f356adfe8ac006b1c50a8011471d129ab1e8ef638f435e4a2b", "h_seeds": [ 200000, 200999 ], "h_n": 1000, "h_complete": true, "mechanism_diff": -2.1595373820516, "mechanism_se": 0.40891258417564375, "mechanism_retail_diff": -9.3628134530752, "mechanism_arb_diff": 7.2032760710273, "reference_diff": -97.143476221531, "reference_se": 5.203482370206133, "b_mean": 99.6958781523823, "failures": [], "graft": "Keep the recipient estimator and prices fixed. Track estimator variance V (e.g. interval-width squared/12 plus EWMA squared innovations). Multiply its base quote size by min(3, variance_budget/max(V,1e-6)), then apply existing cash/inventory caps. Tune budget on separate seeds; freeze and pair-test the graft.", "next": "Reject this standalone mechanism: holdout S1-S0 is -2.159537 (SE 0.408913). Arbitrage edge improves by 7.203276 but retail edge falls by 9.362813. Do not graft this variance proxy unchanged. Future experiments should calibrate estimator-error variance, then repeat a frozen paired comparison. Reserve", "flag": null }, { "key": "f-spread-switch", "mechanism": "Blind construction from pinned simulator only. Estimate probability by clipping the previous estimate to public competitor quotes, smoothing toward their midpoint, and applying a bounded fill correcti", "code_sha256": "e1aaf387e8544537596cdda831eb98042bf1199fc203817ffc9c43a245961891", "h_seeds": [ 200000, 200999 ], "h_n": 1000, "h_complete": true, "mechanism_diff": -13.1981522195026, "mechanism_se": 1.2279953771157022, "mechanism_retail_diff": -4.3786226169557, "mechanism_arb_diff": -8.8195296025401, "reference_diff": -166.4452238593074, "reference_se": 6.325636383554475, "b_mean": 99.6958781523823, "failures": [], "graft": "At initialization infer spread=(competitor_ask-competitor_bid+1)//2; freeze a 1..4 regime index. Select a separately tuned quote-width/size pair from a four-entry table, leaving probability estimation and all other logic unchanged. Initial two-sided quotes are required; do not infer spread from later depleted books.", "next": "Do not promote this strategy: compare the measured reference gap below. The simple probability estimator remains vulnerable to stale competitor quotes. Test spread switching as a graft onto a stronger estimator in an independently seeded follow-up; do not retune on this holdout. The first unguarded ", "flag": null } ], "top": [ { "key": "f-boundary-asymmetry", "code_sha256": "0f382e329f1f9209a13e774ffd827d4558899c2eaa4649c6e2d127b6b6a079bb", "code": "import math\nfrom orderbook_pm_challenge.types import CancelAll, PlaceOrder, Side\n\nclass Strategy:\n # Retail notional target, tuned before the holdout.\n FLOW = 2.0\n BOUNDARY_POWER = -1.0\n\n def __init__(self):\n self.previous = None\n self.move2 = 0.000025\n\n def on_step(self, state):\n bid = state.competitor_best_bid_ticks\n ask = state.competitor_best_ask_ticks\n lo = 0 if bid is None else bid\n hi = 100 if ask is None else ask\n p = (lo + hi) / 200.0\n if self.previous is not None:\n move = p - self.previous\n self.move2 = 0.97 * self.move2 + 0.03 * min(move * move, 0.01)\n self.previous = p\n # A volatility buffer prices diffusion and recent adverse moves.\n risk = math.sqrt(self.move2)\n margin = max(0.015, 1.5 * risk)\n buy_tick = min(hi - 1, int(math.floor(100 * (p - margin))))\n sell_tick = max(lo + 1, int(math.ceil(100 * (p + margin))))\n # Lognormal retail flow is small; avoid exposing a large stale order.\n q = self.FLOW / max(p, 0.05) / (1 + 30 * risk)\n buy_q = q\n sell_q = q\n # S1's sole change: bounded-loss scaling of the boundary-facing side.\n if p < 0.25:\n buy_q *= min(8.0, (0.25 / max(p, 0.01)) ** self.BOUNDARY_POWER)\n if p > 0.75:\n sell_q *= min(8.0, (0.25 / max(1 - p, 0.01)) ** self.BOUNDARY_POWER)\n actions = [CancelAll()]\n cash = max(0.0, state.cash - 0.01)\n if 1 <= buy_tick <= 99:\n price = buy_tick / 100.0\n buy_q = math.floor(min(buy_q, 0.45 * cash / price) * 100) / 100\n if buy_q >= 0.01:\n actions.append(PlaceOrder(Side.BUY, buy_tick, buy_q))\n if 1 <= sell_tick <= 99:\n price = sell_tick / 100.0\n sell_q = math.floor(min(sell_q, state.yes_inventory + 0.45 * cash / (1 - price)) * 100) / 100\n if sell_q >= 0.01:\n actions.append(PlaceOrder(Side.SELL, sell_tick, sell_q))\n return actions\n" }, { "key": "f-horizon-schedule", "code_sha256": "7df8ececb4960c3b7770305e99055dcdcb2786d3c929f3610cacb77a6863c2f5", "code": "\"\"\"S1: S0 plus a quoting schedule over the horizon. Distance and size are explicit functions of steps remaining, through settlement.\n\nThe mechanism is everything marked HORIZON: the adverse-selection and gain terms that set whether a quote pays (its\ndistance) and how large it is are computed with the true steps remaining instead of one fixed horizon; the last step\nuses the binary settlement outcome; and the tail estimate, cover buying and the capital floor run on the same clock.\n\"\"\"\nfrom __future__ import annotations\n\nimport math\nfrom orderbook_pm_challenge.strategy import BaseStrategy\nfrom orderbook_pm_challenge.types import CancelOrder, PlaceOrder, Side, StepState\n\nSIGMA, JUMP_RATE, JUMP_VAR = 0.02, 0.0019, 0.1739 # diffusion per step; middles of the jump bands\nFLOW, LN_SD = 0.1265, 1.2 # retail arrivals per side per step; log-normal notional spread\nLN_MU = math.log(4.488) - 0.5 * LN_SD**2\nMAX_NOTIONAL, CASH_FLOOR, HOG_FLOOR = 100.0, 5.0, 100.0 # the capital-hungry side (over 50c a share) stops at HOG_FLOOR\nPROBE_SIZE, N_PROBES = 0.01, 3 # tiny orders on the ticks nearest the estimate; their sweeps locate p\nSWEEP_ODDS = 0.1 # with a queue-front order, add an inside order only if the far side may be swept next step\nHOG_RAMP = 200 # HORIZON: the capital floor falls to zero over this many final steps\nCOVER_NOTIONAL = 15.0 # YES inventory worth this much at the ask, bought cheaply from the arbitrageur when cash is out\nGH7 = ((0.0, 0.457143), (1.154405, 0.240123), (-1.154405, 0.240123), (2.366759, 0.030757), (-2.366759, 0.030757), (3.750440, 0.000548), (-3.750440, 0.000548))\nGH5 = ((0.0, 0.533333), (1.355626, 0.222076), (-1.355626, 0.222076), (2.856970, 0.011257), (-2.856970, 0.011257))\n\ndef cdf(x: float) -> float:\n return 0.5 * math.erfc(-x / math.sqrt(2.0))\n\ndef ppf(q: float) -> float:\n q = min(max(q, 1e-9), 1.0 - 1e-9)\n if q > 0.5:\n return -ppf(1.0 - q)\n t = math.sqrt(-2.0 * math.log(q))\n return -(t - (2.515517 + 0.802853 * t + 0.010328 * t * t) / (1.0 + t * (1.432788 + t * (0.189269 + 0.001308 * t))))\n\ndef scale(horizon: int) -> float:\n \"\"\"Z scale so Phi(Z / scale) has the slope at Z=0 of the jump-mixed probability with this many steps left.\"\"\"\n lam = JUMP_RATE * horizon\n weight, total = math.exp(-lam), 0.0\n for n in range(14):\n total += weight / math.sqrt(horizon * SIGMA * SIGMA + n * JUMP_VAR)\n weight *= lam / (n + 1)\n return 1.0 / total\n\ndef next_prob_nodes(p: float, err: float, horizon: int) -> tuple[list[tuple[float, float]], float]:\n \"\"\"Weighted nodes for the probability one step ahead, and its diffusion sd.\"\"\"\n v, v1, u = scale(horizon), scale(horizon - 1), ppf(min(max(p, 1e-4), 1.0 - 1e-4))\n slope = math.exp(-0.5 * u * u) / math.sqrt(2.0 * math.pi) / v\n z, sd = v * u, math.sqrt(SIGMA * SIGMA + (err / slope) ** 2)\n js = math.sqrt(sd * sd + JUMP_VAR)\n nodes = [(cdf((z + sd * x) / v1), w * (1.0 - JUMP_RATE)) for x, w in GH7] + [(cdf((z + js * x) / v1), w * JUMP_RATE) for x, w in GH5]\n return nodes, slope * SIGMA\n\ndef horizon_nodes(p: float, err: float, remaining: int) -> tuple[list[tuple[float, float]], float]:\n \"\"\"HORIZON: next-step distribution with this many steps left; on the last step p settles to 1 or 0.\"\"\"\n return ([(1.0, p), (0.0, 1.0 - p)], 0.0) if remaining <= 1 else next_prob_nodes(p, err, remaining)\n\ndef tail_estimate(edge: float, mid: float, remaining: int) -> float:\n \"\"\"HORIZON: mean of p below a small bound, with Z flat over a unit range; shrinks with scale(steps left).\"\"\"\n z = ppf(edge)\n return min(mid, scale(max(remaining, 1)) * (math.exp(-0.5 * z * z) / math.sqrt(2.0 * math.pi) + z * edge))\n\ndef target_notional(sgn: int, x: float, nodes) -> float:\n \"\"\"Solve flow * gain * P(N > C) = adverse for the resting notional C at price x; 0 when no size pays.\"\"\"\n gain = sum(w * max(sgn * (x - n), 0.0) for n, w in nodes)\n adverse = sum(w * max(sgn * (n - x), 0.0) for n, w in nodes)\n if gain <= 0.0 or adverse >= FLOW * gain:\n return 0.0\n r = max(adverse / (FLOW * gain), 1e-6)\n return min(MAX_NOTIONAL, math.exp(LN_MU + LN_SD * ppf(1.0 - r)))\n\ndef read_fills(levels: list[tuple[int, float]], filled: float, sweep_is_arb: bool) -> tuple[float | None, float | None]:\n \"\"\"(tick still resting, so p is on our side of it; tick an arbitrageur swept, so p is beyond it).\"\"\"\n swept, total = 0, 0.0\n while swept < len(levels) and filled >= total + levels[swept][1] - 1e-9:\n total, swept = total + levels[swept][1], swept + 1\n resting = levels[swept][0] / 100.0 if swept < len(levels) else None\n clean = swept and abs(filled - total) < 1e-9 and (swept < len(levels) or sweep_is_arb)\n return resting, levels[swept - 1][0] / 100.0 if clean else None\n\nclass Strategy(BaseStrategy):\n def __init__(self) -> None:\n self.low, self.high, self.vol, self.hog = 0.0, 1.0, 0.0, HOG_FLOOR\n self.prev = {1: 100, -1: 0} # competitor best last step; +1 asks, -1 bids\n self.levels: dict[int, list[tuple[int, float]]] = {1: [], -1: []} # own orders, best first\n self.sweep_is_arb = {1: False, -1: False}\n self.front: dict[int, str | None] = {1: None, -1: None} # order resting ahead of the competitor\n\n def _track(self, s: StepState, bid: int, ask: int) -> None:\n \"\"\"Interval for p: widened by one step of diffusion, cut by what the ladder and own fills reveal.\"\"\"\n width = self.high - self.low\n pad = 0.5 * (math.sqrt(width * width + 12.0 * self.vol * self.vol) - width)\n low, high = max(0.0, self.low - pad), min(1.0, self.high + pad)\n lo, hi = bid / 100.0, ask / 100.0\n lo = max(lo, (ask - 1) / 100.0) if ask > self.prev[1] else lo\n hi = min(hi, (bid + 1) / 100.0) if bid < self.prev[-1] else hi\n rest, swept = read_fills(self.levels[1], s.sell_filled_quantity, self.sweep_is_arb[1]) # asks\n hi, lo = hi if rest is None else min(hi, rest), lo if swept is None else max(lo, swept)\n rest, swept = read_fills(self.levels[-1], s.buy_filled_quantity, self.sweep_is_arb[-1])\n lo, hi = lo if rest is None else max(lo, rest), hi if swept is None else min(hi, swept)\n lo, hi = (bid / 100.0, ask / 100.0) if lo > hi else (lo, hi)\n self.low, self.high = (lo, hi) if low > hi or high < lo else (max(low, lo), min(high, hi))\n\n def _cover(self, tick: int, p: float, nodes, cash: float, yes: float, remaining: int) -> list[tuple[int, float]]:\n \"\"\"Asks below 50c cost about $1 a share uncovered: when cash is out, a bid just above p buys cover from the arbitrageur.\"\"\"\n buy = int(p * 100.0) + 1\n if not 1 <= tick <= 49 or tick - buy < 1:\n return []\n cover = min(COVER_NOTIONAL, FLOW * (remaining - 1) * 4.488) # HORIZON: no more cover than retail can take before settlement\n short = min(target_notional(1, tick / 100.0, nodes), cover) / (tick / 100.0) - yes - max(cash - self.hog, 0.0) / (1.0 - tick / 100.0)\n return [(buy, short)] if short >= 0.01 else []\n\n def _side(self, sgn: int, comp: dict[int, int], kept, p: float, nodes, cash: float, yes: float, actions: list, cover=()):\n \"\"\"Probes from the estimate outward, the quote one tick inside the competitor, then any queue-front order.\"\"\"\n tick, far = comp[sgn] - sgn, comp[-sgn] / 100.0\n main = target_notional(sgn, tick / 100.0, nodes) / (tick / 100.0 if sgn > 0 else max(p, 0.05)) if 1 <= tick <= 99 else 0.0\n main = 0.0 if kept and sum(w for n, w in nodes if sgn * (far - n) > 0.0) < SWEEP_ODDS else main\n first = int(p * 100.0) + (1 if sgn > 0 else 0)\n orders = list(cover) + [(t, PROBE_SIZE) for t in range(first, first + sgn * N_PROBES, sgn)\n if 1 <= t <= 99 and sgn * (tick - t) >= (main >= 0.01)]\n orders += [(tick, main)] if main >= 0.01 else []\n levels: list[tuple[int, float]] = []\n for t, qty in orders:\n unit, free = (1.0 - t / 100.0, yes) if sgn > 0 else (t / 100.0, 0.0)\n room = max(cash - (self.hog if unit > 0.5 and qty > PROBE_SIZE else 0.0), 0.0)\n qty = math.floor(min(qty, free + room / unit) * 100.0) / 100.0\n if qty < 0.01:\n continue\n cash, yes = cash - unit * max(qty - free, 0.0), max(yes - qty, 0.0) if sgn > 0 else yes\n actions.append(PlaceOrder(Side.SELL if sgn > 0 else Side.BUY, t, qty))\n levels.append((t, qty))\n self.levels[sgn] = levels + ([kept[1:]] if kept else [])\n if self.levels[sgn]:\n top = self.levels[sgn][-1][0] / 100.0\n held = sum(q for _, q in self.levels[sgn]) * (top if sgn > 0 else max(p, 0.05))\n cross = sum(w for n, w in nodes if sgn * (n - top) > 0.0)\n self.sweep_is_arb[sgn] = cross > FLOW * (1.0 - cdf((math.log(held) - LN_MU) / LN_SD))\n return cash, yes\n\n def on_step(self, s: StepState):\n bid, ask = s.competitor_best_bid_ticks or 0, s.competitor_best_ask_ticks or 100\n comp = {1: ask, -1: bid}\n if s.step == 0:\n self.low, self.high = (ask + bid - 1) / 200.0, (ask + bid + 1) / 200.0\n self.prev = dict(comp)\n else:\n self._track(s, bid, ask)\n p, err, remaining = 0.5 * (self.low + self.high), (self.high - self.low) / math.sqrt(12.0), s.steps_remaining\n if self.high <= 0.011: # HORIZON: inside the outermost tick p is judged by the steps left\n p = tail_estimate(self.high, p, remaining)\n err = min(err, p)\n elif self.low >= 0.989:\n p = 1.0 - tail_estimate(1.0 - self.low, 1.0 - p, remaining)\n err = min(err, 1.0 - p)\n self.hog = HOG_FLOOR * min(1.0, remaining / HOG_RAMP) # HORIZON\n nodes, self.vol = horizon_nodes(p, err, remaining) # HORIZON\n actions: list = []\n kept: dict[int, tuple | None] = {1: None, -1: None}\n cash, yes = s.cash - CASH_FLOOR, s.yes_inventory\n for o in s.own_orders:\n sgn, tick = (1 if o.side is Side.SELL else -1), o.price_ticks\n ahead = tick == comp[sgn] and (sgn * (self.prev[sgn] - tick) > 0 or o.order_id == self.front[sgn])\n if ahead and o.remaining_quantity > PROBE_SIZE and target_notional(sgn, tick / 100.0, nodes) > 0.0:\n kept[sgn] = (o.order_id, tick, o.remaining_quantity)\n cash -= o.remaining_quantity * ((1.0 - tick / 100.0) if sgn > 0 else tick / 100.0)\n yes -= o.remaining_quantity if sgn > 0 else 0.0\n else:\n actions.append(CancelOrder(o.order_id))\n self.front, self.prev = {k: v[0] if v else None for k, v in kept.items()}, dict(comp)\n yes = max(yes, 0.0)\n cash, yes = self._side(-1, comp, kept[-1], p, nodes, cash, yes, actions, self._cover(ask - 1, p, nodes, cash, yes, remaining))\n self._side(1, comp, kept[1], p, nodes, cash, yes, actions)\n return actions\n" } ], "notes": "Each diff is S1 minus that item's own S0 on seeds 200000-200999; arb diff above 0 means less arbitrage loss. Reduced arbitrage loss: boundary-asymmetry +16.28 (retail -0.92), variance-kelly +7.20 (retail -9.36, net negative), breakeven-size +5.55 (retail -2.68), inventory-dp +2.18 (retail -1.04), reservation-skew +0.86 (retail -0.36), queue-aware +0.21 (retail -0.95, net negative). Raised retail edge: horizon-schedule +10.56 (arb -1.29); adverse-timer +0.06 and geometric-ladder +0.02 are negligible, and both lost overall. spread-switch lost on both (retail -4.38, arb -8.82). Every arbitrage gain cost some retail edge; the net was positive for boundary-asymmetry, breakeven-size, inventory-dp and reservation-skew. boundary-asymmetry's selected power is -1, a taper: positive powers lost on tuning. inventory-dp and reservation-skew both report inventory working as a signal of adverse fills, not as risk control. No row beats B: every reference_diff is negative, the closest being horizon-schedule at -23.163 (se 2.691). horizon-schedule's sources failed re-reading (3 of them), as did sources of five other rows; see Caveats." } ``` ## Inputs - `f-inventory-dp`: `artifacts/goal/batches/r2-fresh-b/items/f-inventory-dp/result.json`, SHA-256 `270901a6194d97305428d0b8429c72af2cd3e08219edfe273032fda8ce7328b5` - `f-reservation-skew`: `artifacts/goal/batches/r2-fresh-b/items/f-reservation-skew/result.json`, SHA-256 `0e30f7fb7e9f201af16b334d5eb62d04a251f2002383bbe8e27b159e89012db0` - `f-queue-aware`: `artifacts/goal/batches/r2-fresh-b/items/f-queue-aware/result.json`, SHA-256 `922f7f0bcb7d036d553f54a3d743e6705a48b8d38debc3b9797ccb194447bbb5` - `f-geometric-ladder`: `artifacts/goal/batches/r2-fresh-b/items/f-geometric-ladder/result.json`, SHA-256 `a27ccc5d0e85b6cec1f5986ac75b6449c50ab2f153ce1a17bb5c8fe5a59eaa5c` - `f-adverse-timer`: `artifacts/goal/batches/r2-fresh-b/items/f-adverse-timer/result.json`, SHA-256 `f00e5afcf59ccaa822254dbfc24cf3ed94d9f9e42534a874e74a86cc2aaf65dd` - `f-horizon-schedule`: `artifacts/goal/batches/r2-fresh-b/items/f-horizon-schedule/result.json`, SHA-256 `08befd19f65a88081a9e3093a8071a84ad02098344dfd42dd74f0ce3f33af103` - `f-spread-switch`: `artifacts/goal/batches/r2-fresh-b/items/f-spread-switch/result.json`, SHA-256 `e8214328a8bf83c5e648c98720a7e0acd7b4fbe15126ed05f50de98d1ce75e04` - `f-boundary-asymmetry`: `artifacts/goal/batches/r2-fresh-b/items/f-boundary-asymmetry/result.json`, SHA-256 `b4b6189439527778745328b0e0ae4c31affdfc95ebe95146fce150a322bf5774` - `f-variance-kelly`: `artifacts/goal/batches/r2-fresh-b/items/f-variance-kelly/result.json`, SHA-256 `9d585aeed762069931e4ea74fb6d6b0628b938e0335a49519da0de8344f872c4` - `f-breakeven-size`: `artifacts/goal/batches/r2-fresh-b/items/f-breakeven-size/result.json`, SHA-256 `c795bbb59fdeeb5b63eadadc2e8341a9a920f6df411e760841bf67374f92feca`