{"approach": "Retains the base\u2019s tiny tick probes, filtered sub-tick probability estimate, queue-preserving orders, marginal retail-versus-arbitrage quote sizing, and near-zero YES ammunition. Exposed 55 policy constants and searched them with single-constant grids, random mutations, validated-parent mutations, and local sweeps, selecting only on seeds 0-599. Winning changes from the exposed defaults are {\"belief_var\": 0.25, \"bins\": 4.0, \"kLb\": 0.02, \"lam_j\": 0.001, \"sig_n\": 1.35, \"uni\": 0.001}. Code was frozen before the sole holdout evaluation; close local parameter rankings remain statistically uncertain.", "blocked": null, "python_version": "3.12.3", "base_mean_edge": 78.85441957511699, "score": {"mean_edge": 94.08319885091049, "retail_edge": 124.8466673526275, "arb_edge": -30.7634685017025, "simulations": 600, "seed_start": 0, "failures": 0}, "holdout": {"mean_edge": 88.5070473106925, "simulations": 600, "seed_start": 20000, "failures": 0}, "code": "\"\"\"Stale-quote defence with tick probes, a sub-tick belief and YES ammunition.\n\nEvery step the arbitrageur removes any order on the wrong side of p, so tiny\ntwo-sided probes around the estimate locate p to a tick; a grid filter narrows\nthat further.  Quotes sit one tick inside the competitor and are sized by the\nmarginal rule: one more share is worth quoting while the chance a retail order\nreaches it, times its edge, exceeds the expected arbitrage loss.  That rule pulls\nquotes by itself when a move would hurt most.  Near p=0 a retail buy pays almost\nits whole notional as edge, so YES is held to cover low asks.\n\"\"\"\nimport math\nfrom orderbook_pm_challenge.strategy import BaseStrategy\nfrom orderbook_pm_challenge.types import CancelOrder, PlaceOrder, Side\n\n# Policy constants selected on training seeds only.\nP = {'lam_r': 0.25,\n 'm': 5.0,\n 'sig_n': 1.35,\n 'lam_j': 0.001,\n 'sig_j': 0.35,\n 'sig': 0.02,\n 'qmax': 3000.0,\n 'rmin': 2,\n 'kA': 0.7,\n 'kL': 0.15,\n 'pL': 0.05,\n 'ammo': 1.0,\n 'ydem': 0.4,\n 'W': 200.0,\n 'fy': 0.6,\n 'ammo_q': 60.0,\n 'ammo_pmax': 0.05,\n 'ammo_maxpay': 0.02,\n 'fb': 0.9,\n 'fu': 0.5,\n 'xu': 0.1,\n 'sticky': 1.0,\n 'min_ahead': 2.0,\n 'keep_hi': 1.5,\n 'keep_lo': 0.7,\n 'Hu': 300.0,\n 'bins': 4.0,\n 'filt': 1.0,\n 'uni': 0.001,\n 'jumpinfo': 1.0,\n 'dmin': 0.0,\n 'kLb': 0.02,\n 'kLf': 0.08,\n 'pinf': 1.0,\n 'pre': 1500.0,\n 'H1': 100.0,\n 'maxbins': 48,\n 'filter_sd': 1.0,\n 'grid_sd': 0.6,\n 'filter_cutoff': 12.5,\n 'pclip': 0.002,\n 'belief_var': 0.25,\n 'var_floor': 1e-08,\n 'retail_side': 0.5,\n 'tail_floor': 1e-06,\n 'sell_floor': 0.05,\n 'ammo_offset': 1.0,\n 'wealth_floor': 0.005,\n 'cash_buffer': 2.0,\n 'keep_min': 1.0,\n 'inventory_buffer': 0.1,\n 'uncovered_pmax': 0.05,\n 'pre_pmax': 0.01,\n 'probe_sd': 2.0,\n 'probe_cash': 1.0}\nSQ2 = math.sqrt(2.0)\nSQ2PI = math.sqrt(2.0 * math.pi)\ndef cdf(x): return 0.5 * (1.0 + math.erf(x / SQ2))\ndef pdf(x): return math.exp(-0.5 * x * x) / SQ2PI\ndef inv(p):\n    p = min(max(p, 1e-9), 1 - 1e-9)\n    t = math.sqrt(-2.0 * math.log(min(p, 1 - p)))\n    x = t - (2.515517 + 0.802853 * t + 0.010328 * t * t) / (1 + 1.432788 * t + 0.189269 * t * t + 0.001308 * t ** 3)\n    x = -x if p < 0.5 else x\n    for _ in range(2):\n        d = pdf(x)\n        if d < 1e-12:\n            break\n        x -= (cdf(x) - p) / d\n    return x\ndef lpm(k):\n    return pdf(k) + k * cdf(k)\ndef fl(q):\n    return math.floor(q * 100 + 1e-9) / 100\n\nNODES = [(-2.2, .06), (-1.3, .17), (-0.6, .27), (0.6, .27), (1.3, .17), (2.2, .06)]\nPROBE = 0.01\n\n\nclass Strategy(BaseStrategy):\n    def __init__(self):\n        self.n = 0\n        self.ahead = set()     # main orders placed strictly ahead of any competitor order at their tick\n        self.res = {}          # order id -> uncovered quantity at placement\n        self.bc = None         # belief: sub-tick grid centres (ticks)\n        self.bw = None         # belief: weights\n        self.st = 0.5          # last one-step sd in ticks\n        self.pcb = self.pca = None\n        self.pb = set()\n        self.pa = set()\n\n    def _oid(self, tag):\n        self.n += 1\n        return tag + str(self.n)\n\n    def on_step(self, state):\n        H = max(1, state.steps_remaining)\n        cb = state.competitor_best_bid_ticks or 0\n        ca = state.competitor_best_ask_ticks or 100\n        lo, hi = cb, ca\n        for o in state.own_orders:\n            if o.side is Side.BUY:\n                lo = max(lo, o.price_ticks)\n            else:\n                hi = min(hi, o.price_ticks)\n        if P['pinf'] > 0:\n            sb = {o.price_ticks for o in state.own_orders if o.side is Side.BUY and o.remaining_quantity <= PROBE + 1e-9}\n            sa = {o.price_ticks for o in state.own_orders if o.side is Side.SELL and o.remaining_quantity <= PROBE + 1e-9}\n            ea = self.pa - sa\n            eb = self.pb - sb\n            if sa and ea:\n                lo = max(lo, min(max(ea), hi))\n            if sb and eb:\n                hi = min(hi, max(min(eb), lo))\n        if P['jumpinfo'] > 0 and self.pcb is not None:\n            if ca > self.pca + 1:\n                lo = max(lo, ca - 1)\n            if cb < self.pcb - 1:\n                hi = min(hi, cb + 1)\n        self.pcb, self.pca = cb, ca\n        if lo > hi:\n            lo, hi = hi, lo\n        # sub-tick belief over p_(t-1): predict with one-step noise, truncate to [lo, hi]\n        wid = max(hi - lo, 1e-6)\n        nb = max(2, min(int(P['maxbins']), int(round(wid * P['bins']))))\n        cs = [lo + (i + 0.5) * wid / nb for i in range(nb)]\n        if self.bc is None or P['filt'] <= 0:\n            ws = [1.0 / nb] * nb\n        else:\n            sg = max(self.st * P['filter_sd'], P['grid_sd'] * wid / nb)\n            k = -0.5 / (sg * sg)\n            ws = []\n            uni = P['uni'] * sg\n            for c in cs:\n                t = uni\n                for ci, wi in zip(self.bc, self.bw):\n                    d = c - ci\n                    d2 = d * d * k\n                    if d2 > -P['filter_cutoff']:\n                        t += wi * math.exp(d2)\n                ws.append(t)\n            tot = sum(ws)\n            ws = [w / tot for w in ws]\n        self.bc, self.bw = cs, ws\n        mean_t = sum(c * w for c, w in zip(cs, ws))\n        var_t = max(sum(c * c * w for c, w in zip(cs, ws)) - mean_t * mean_t, 0.0)\n        phat = min(max(mean_t / 100.0, P['pclip']), 1-P['pclip'])\n        var = P['sig'] ** 2 + P['lam_j'] * P['sig_j'] ** 2\n        sd = math.sqrt(H * var)\n        z = inv(phat)\n        Z = z * sd\n        sp = pdf(z) / sd * P['sig']\n        self.st = sp * 100.0\n        s = math.sqrt(sp * sp + P['belief_var'] * var_t / 1e4 + P['var_floor'])\n        sd1 = math.sqrt(max(1.0, H - 1.0) * var)\n        jp = [(cdf((Z + n * P['sig_j']) / sd1), w) for n, w in NODES]\n        lj = P['lam_j']\n\n        def AB(x):\n            k = (x - phat) / s\n            a = s * lpm(k)\n            b = a - (x - phat)\n            ja = sum(w * max(0.0, x - p) for p, w in jp)\n            jb = sum(w * max(0.0, p - x) for p, w in jp)\n            return (1 - lj) * a + lj * ja, (1 - lj) * b + lj * jb\n\n        if H == 1:\n            def AB(x):\n                return (1 - phat) * x, phat * (1 - x)\n        rho = P['lam_r'] * P['retail_side']\n        mu = math.log(P['m']) - 0.5 * P['sig_n'] ** 2\n        kA = P['kL'] if phat < P['pL'] else P['kA']\n\n        def qsize(loss, gain, px):\n            loss *= kA\n            if gain <= 0:\n                return 0.0\n            tail = loss / (rho * gain)\n            if tail >= 1.0:\n                return 0.0\n            return min(P['qmax'], math.exp(mu + P['sig_n'] * inv(1 - max(tail, P['tail_floor']))) / px)\n\n        ptk = phat * 100\n        def qbid(t):\n            if not 1 <= t <= 99:\n                return 0.0\n            a, b = AB(t / 100.0)\n            if phat * 100 - t < P['dmin']:\n                return 0.0\n            if phat < P['pL']:\n                ytg = P['ydem'] * min(H, P['W']) / max(ca - 1, ptk + P['ammo_offset']) * 100.0\n                a *= (P['kLb'] if state.yes_inventory < ytg else P['kLf']) / P['kL']\n            return qsize(a, b, max(phat, P['sell_floor']))\n\n        def qask(t):\n            if not 1 <= t <= 99:\n                return 0.0\n            a, b = AB(t / 100.0)\n            if t - phat * 100 < P['dmin']:\n                return 0.0\n            return qsize(b, a, t / 100.0)\n\n        bids = [o for o in state.own_orders if o.side is Side.BUY and o.remaining_quantity > PROBE + 1e-9]\n        asks = [o for o in state.own_orders if o.side is Side.SELL and o.remaining_quantity > PROBE + 1e-9]\n        sticky = P['sticky'] > 0\n        def top(orders, comp, step):\n            if sticky and sum(o.remaining_quantity for o in orders if o.price_ticks == comp and o.order_id in self.ahead) >= P['min_ahead']:\n                return comp\n            return comp + step\n        bid_t = top(bids, cb, 1)\n        ask_t = top(asks, ca, -1)\n        qb = qbid(bid_t)\n        qa = qask(ask_t)\n\n        Y = state.yes_inventory\n        if ask_t == 1 and H > P['H1'] and P['pre'] > 0:\n            qa = 0.0          # let the competitor's 2-tick ask erode instead of fronting it for nothing\n        # ammunition: hold YES so that low asks are covered\n        ptick = phat * 100\n        amt = 0\n        qam = 0.0\n        if P['ammo'] > 0 and ask_t >= 2 and phat < P['ammo_pmax']:\n            wealth = state.cash + Y * phat\n            x = max(ask_t, ptick + P['ammo_offset']) / 100.0\n            target = min(P['ydem'] * min(H, P['W']) / x, P['fy'] * wealth / max(phat, P['wealth_floor']))\n            if Y < target:\n                t = max(1, min(99, int(math.ceil(ptick + 1e-9))))\n                if bid_t <= t < ask_t and t / 100.0 - phat < P['ammo_maxpay']:\n                    amt = t\n                    qam = min(P['ammo_q'], target - Y)\n\n        if P['pre'] > 0 and ca == 2 and phat < P['pre_pmax'] and H > P['H1'] and Y < P['pre'] and not qam:\n            amt, qam = 1, min(P['ammo_q'], P['pre'] - Y)\n        # order management\n        actions = []\n        free = state.free_cash - P['cash_buffer']\n        keep_ask = 0.0\n        new_b = []\n        new_a = []\n        def cancel(o):\n            nonlocal free\n            actions.append(CancelOrder(o.order_id))\n            x = o.price_ticks / 100.0\n            if o.side is Side.BUY:\n                free += x * o.remaining_quantity\n            else:\n                free += (1 - x) * min(self.res.get(o.order_id, 0.0), o.remaining_quantity)\n            self.ahead.discard(o.order_id)\n            self.res.pop(o.order_id, None)\n        for o in state.own_orders:\n            if o.remaining_quantity <= PROBE + 1e-9:\n                cancel(o)\n        kept_ids = set()\n        def manage(orders, t, q, comp):\n            kept = 0.0\n            for o in orders:\n                if o.price_ticks == t and q > 0 and kept + o.remaining_quantity <= max(q * P['keep_hi'], P['keep_min']):\n                    kept += o.remaining_quantity\n                    kept_ids.add(o.order_id)\n                else:\n                    cancel(o)\n            return kept\n        kb = manage(bids, bid_t, qb, cb)\n        ka = manage(asks, ask_t, qa, ca)\n        add_b = (qb - kb) if (kb < qb * P['keep_lo'] and bid_t != cb) else 0.0\n        add_a = (qa - ka) if (ka < qa * P['keep_lo'] and ask_t != ca) else 0.0\n\n        budget = P['fb'] * max(free, 0.0)\n        cost = add_b * bid_t / 100.0 + qam * amt / 100.0\n        if cost > budget:\n            f = budget / cost\n            add_b *= f\n            qam *= f\n            cost = budget\n        out = []\n        if amt and qam >= 0.01:\n            q = fl(qam)\n            out.append(PlaceOrder(side=Side.BUY, price_ticks=amt, quantity=q))\n            free -= q * amt / 100.0 + 1e-6\n        if bid_t >= 1 and add_b >= 0.01:\n            q = fl(add_b)\n            oid = self._oid('b')\n            out.append(PlaceOrder(side=Side.BUY, price_ticks=bid_t, quantity=q, client_order_id=oid))\n            free -= q * bid_t / 100.0 + 1e-6\n            if bid_t > cb:\n                self.ahead.add(oid)\n        if ask_t <= 99 and add_a >= 0.01:\n            x = ask_t / 100.0\n            covk = sum(o.remaining_quantity - min(self.res.get(o.order_id, 0.0), o.remaining_quantity)\n                       for o in asks if o.order_id in kept_ids)\n            cov = max(0.0, Y - covk - P['inventory_buffer'])\n            unc = max(0.0, add_a - cov)\n            if unc > 0:\n                ub = max(0.0, free - (1 - P['fu']) * max(state.cash, 0.0)) if x >= P['xu'] else 0.0\n                if H < P['Hu'] and phat < P['uncovered_pmax']:\n                    ub = max(0.0, free * (1 - H / P['Hu']))\n                unc = min(unc, ub / (1 - x))\n            q = fl(min(add_a, cov + unc))\n            if q >= 0.01:\n                oid = self._oid('a')\n                out.append(PlaceOrder(side=Side.SELL, price_ticks=ask_t, quantity=q, client_order_id=oid))\n                r = max(0.0, q - cov)\n                self.res[oid] = r\n                free -= r * (1 - x) + 1e-6\n                if ask_t < ca:\n                    self.ahead.add(oid)\n\n        # probes: tiny orders that the arbitrageur removes when p crosses them\n        f = int(math.floor(ptick + 1e-9))\n        r = max(int(P['rmin']), int(math.ceil(P['probe_sd'] * s * 100)))\n        self.pb = set()\n        self.pa = set()\n        if free > P['probe_cash']:\n            for t in range(f, f + r + 1):\n                if cb < t < ca and 1 <= t <= 99:\n                    out.append(PlaceOrder(side=Side.BUY, price_ticks=t, quantity=PROBE))\n                    self.pb.add(t)\n            for t in range(f + 1 - r, f + 2):\n                if cb < t < ca and 1 <= t <= 99:\n                    out.append(PlaceOrder(side=Side.SELL, price_ticks=t, quantity=PROBE))\n                    self.pa.add(t)\n        return actions + out\n", "code_sha256": "ae47bc0fec88466d5425edc4f5e5dc477e72d978d64c2c888a47876b29b158c3", "tried": ["Unmodified public simulator revision b244530ee2a6247b5f930830eeca9dd950da0e7e. Reproduced base on seeds 0-199: 78.85441957511699, zero failures. Base on 0-599: 87.41650726068066.", "Exposed the original 36 policy constants plus 19 previously hard-coded policy thresholds/scales (55 total); fixed market units and mathematical approximation coefficients. Scored 3859 distinct variants in 4149 candidate batch evaluations and 57274 search-harness training simulations (excluding standalone CLI checks), all on seeds 0-599, with zero failed simulations. Search used CPython and PyPy 3.11.15; base prefix 0-199 and a changed candidate prefix 0-19 matched CPython per-seed exactly; final scores below use CPython only.", "One-constant grid: 187 variants on seeds [1,3,5,11,26,42]; best screen mean 121.35042362784999 (keep_hi=2). On separate seeds 64-127 the best single change was uni=0.001, mean 78.16770491053593. Uniform-only 600-run training mean 89.65318238623351.", "Random mutations/recombinations: 2430 distinct variants on [1,3,5,11]; best screen mean 182.33162333274998. Leaders were rechecked on 64-, 96-, and 128-seed training blocks; large small-screen gains often reversed. Final late-random checks best mean 75.5410114395211 on seeds 400-527.", "Validated-parent adaptive mutations: 944 variants on seeds 32-39; best screen mean 172.48044821641253. The four-constant combination bins=4, uni=0.001, kLb=0.02, belief_var=0.25 scored 67.45202748521875 on seeds 128-223 and 92.569957367732 on 0-599.", "Local sweeps: 219 variants on 256-287 (best 87.70045525142497), then 243 on 288-303 (best 70.44891757871875). Larger dispersion sig_n=1.8 gave 93.0194654048665 on all 600 training seeds. Promoted refinements to full 600-seed batches: large=9, precision=10, polish=6, joint=2, micro=3.", "Frozen before holdout at 2026-11-05T21:26:43.754643+00:00. PyPy selection mean 94.08225656262621; final CPython training mean 94.08319885091049. Training paired gain versus base: 6.666691590229834 (paired SE 1.168876061552747). Holdout base mean 85.46780344973116; selected-minus-base paired gain 3.0392438609613333 (SE 1.2828644033756091). Base holdout was measured after freeze for comparison only; no holdout results informed selection.", "CPython 3.12.3 --sandbox: final strategy 20/20 infrastructure failures before strategy load, identical to supplied starter 20/20; ImportError: Import of ntpath is not allowed in sandbox mode. Ordinary final training and holdout each had zero failures. Additional PyPy 3.11.15 --sandbox check: 20 simulations, 0 failures.", "Selected winning deltas from the exposed defaults: {\"belief_var\": 0.25, \"bins\": 4.0, \"kLb\": 0.02, \"lam_j\": 0.001, \"sig_n\": 1.35, \"uni\": 0.001}. All 55 winning values are in code.P. Frozen CPython training mean 94.08319885091049, retail 124.8466673526275, arb -30.7634685017025; untouched holdout mean 88.5070473106925; 600 simulations and zero failures in each."], "next": "Replicate the broad improvement on fresh blind seed blocks before choosing between the nearly tied local settings. Next test adaptive filter uniform weight or separate near-zero inventory and quote-size penalties; search-screen winners often failed larger paired checks."}