{"approach":"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 selected from the formal tuning sweep. S1 keeps those quotes and collateral checks exactly, but estimates side-specific retail arrival rate, uncensored retail notional, adverse-fill rate, and markout from prior aggregate fills and competitor quotes. It solves retail_rate * estimated edge * lognormal demand tail(q) = 4 * adverse_rate * estimated loss by bisection, with a 0.5 to 4 notional risk band. The factor 4 calibrates adverse-flow undercount in the approximate markout classifier. The equality is approximate and applies only inside the risk band. Two 20-seed feasibility/timing pilots preceded the formal variant sweep; they are disclosed separately. Counting those pilots, six S0 prototypes were evaluated, exceeding the requested four-variant S0 cap. No finalist seeds were used.","tried":{"timing_pilots":[{"variant":"S0 fixed 8 notional, symmetric inside quotes","role":"S0 timing pilot","seeds":"115000..115019","n":20,"mean_total_edge":-104.726473737575,"mean_retail_edge":35.477299404305,"mean_arb_edge":-140.20377314185},{"variant":"S1 observed flow, symmetric inside quotes","role":"S1 timing pilot","seeds":"115000..115019","n":20,"mean_total_edge":-76.55043709007501,"mean_retail_edge":23.491820531835,"mean_arb_edge":-100.042257622035},{"variant":"S0 fixed 8 notional, moving-side estimate","role":"S0 timing pilot","seeds":"115020..115039","n":20,"mean_total_edge":-14.2946912996,"mean_retail_edge":21.32128427875,"mean_arb_edge":-35.61597557835},{"variant":"S1 observed flow, moving-side estimate","role":"S1 timing pilot","seeds":"115020..115039","n":20,"mean_total_edge":-20.56301662703,"mean_retail_edge":13.678548459155,"mean_arb_edge":-34.241565086185}],"formal_variants":[{"variant":"S0 width 1, notional 4","role":"S0","seeds":"115040..115139","n":100,"mean_total_edge":-31.358243205163,"mean_retail_edge":6.962952817516,"mean_arb_edge":-38.32119602268},{"variant":"S0 width 1, notional 8","role":"S0","seeds":"115040..115139","n":100,"mean_total_edge":-44.343834559055,"mean_retail_edge":7.053753580412,"mean_arb_edge":-51.397588139466},{"variant":"S0 width 2, notional 4 [selected]","role":"S0","seeds":"115040..115139","n":100,"mean_total_edge":-6.721255563159,"mean_retail_edge":10.424363024291,"mean_arb_edge":-17.145618587448},{"variant":"S0 width 2, notional 8","role":"S0","seeds":"115040..115139","n":100,"mean_total_edge":-14.758893820576,"mean_retail_edge":10.921245730624,"mean_arb_edge":-25.680139551195},{"variant":"S1 width 2, notional cap 4, arb calibration 1","role":"S1","seeds":"115040..115139","n":100,"mean_total_edge":-5.905550009736,"mean_retail_edge":10.120878114483,"mean_arb_edge":-16.026428124217},{"variant":"S1 width 2, notional cap 4, arb calibration 4 [selected]","role":"S1","seeds":"115040..115139","n":100,"mean_total_edge":-2.82641889828,"mean_retail_edge":6.813665453547,"mean_arb_edge":-9.640084351824001}]},"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.","code":"import math\nfrom orderbook_pm_challenge.types import CancelAll, PlaceOrder, Side\n\n\nclass Strategy:\n    WIDTH = 2\n    NOTIONAL = 4.0\n    FLOW_HALF_LIFE = 180\n    RISK_SCALE = 4.0\n\n    def __init__(self):\n        self.retail_rate = [.10, .10]\n        self.arb_rate = [.003, .003]\n        self.retail_mean = [4.5, 4.5]\n        self.arb_loss = [.035, .035]\n        self.prev = [None, None]\n        self.last_quotes = None\n        self.mid = None\n\n    def estimate(self, bid, ask):\n        if self.last_quotes is None:\n            self.mid = (bid + ask) / 2\n        else:\n            old_bid, old_ask = self.last_quotes\n            if ask > old_ask:\n                self.mid = ask - .6\n            elif bid < old_bid:\n                self.mid = bid + .6\n            elif bid > old_bid:\n                self.mid = max(self.mid, bid + 1.2)\n            elif ask < old_ask:\n                self.mid = min(self.mid, ask - 1.2)\n        self.mid = max(bid + .5, min(ask - .5, self.mid)) if ask > bid + 1 else (bid + ask) / 2\n        self.last_quotes = bid, ask\n        return self.mid\n\n    def update_flow(self, state, mid):\n        alpha = 1 - math.exp(-math.log(2) / self.FLOW_HALF_LIFE)\n        for i, filled in enumerate((state.buy_filled_quantity, state.sell_filled_quantity)):\n            prev = self.prev[i]\n            if prev is None:\n                continue\n            tick, quoted_q = prev\n            price = tick / 100\n            markout = (price - mid / 100) if i == 0 else (mid / 100 - price)\n            arb = filled > 0 and markout > .005\n            retail = filled > 0 and not arb\n            self.retail_rate[i] += alpha * (float(retail) - self.retail_rate[i])\n            self.arb_rate[i] += alpha * (float(arb) - self.arb_rate[i])\n            if retail and filled < quoted_q - .01:\n                notional = filled * price\n                self.retail_mean[i] += .025 * (max(.5, min(30, notional)) - self.retail_mean[i])\n            if arb:\n                self.arb_loss[i] += .06 * (max(.005, min(.3, markout)) - self.arb_loss[i])\n\n    def size(self, i, price, edge):\n        # The retail marginal is edge * rate * P(order size exceeds q).\n        # The arbitrage marginal is loss * event rate: arbitrage consumes the entire quote.\n        benefit = max(.01, self.retail_rate[i]) * max(.002, edge)\n        cost = max(.001, self.arb_rate[i]) * max(.01, self.arb_loss[i]) * self.RISK_SCALE\n        lo, hi = .01, 30 / price\n        mu = math.log(max(.5, self.retail_mean[i])) - .5 * 1.2**2\n        for _ in range(12):\n            q = (lo + hi) / 2\n            tail = .5 * math.erfc((math.log(q * price) - mu) / (1.2 * math.sqrt(2)))\n            if benefit * tail > cost:\n                lo = q\n            else:\n                hi = q\n        return min(80, self.NOTIONAL / price, max(.5 / price, (lo + hi) / 2))\n\n    def on_step(self, state):\n        bid0 = state.competitor_best_bid_ticks\n        ask0 = state.competitor_best_ask_ticks\n        if bid0 is None and ask0 is None:\n            return [CancelAll()]\n        if bid0 is None:\n            bid0 = max(1, ask0 - 6)\n        if ask0 is None:\n            ask0 = min(99, bid0 + 6)\n        mid = self.estimate(bid0, ask0)\n        self.update_flow(state, mid)\n        bid = math.floor(mid - self.WIDTH)\n        ask = math.ceil(mid + self.WIDTH)\n        actions = [CancelAll()]\n        self.prev = [None, None]\n        if 1 <= bid <= 99 and bid > bid0 and bid < ask0 and bid < mid - 0.2:\n            price = bid / 100\n            quantity = self.size(0, price, mid / 100 - price)\n            quantity = math.floor(quantity * 100) / 100\n            if price * quantity < state.cash / 2 and quantity >= .01:\n                actions.append(PlaceOrder(Side.BUY, bid, quantity))\n                self.prev[0] = (bid, quantity)\n        if 1 <= ask <= 99 and ask < ask0 and ask > bid0 and ask > mid + 0.2:\n            price = ask / 100\n            quantity = self.size(1, price, price - mid / 100)\n            quantity = math.floor(quantity * 100) / 100\n            if (1-price) * quantity < state.cash / 2 and quantity >= .01:\n                actions.append(PlaceOrder(Side.SELL, ask, quantity))\n                self.prev[1] = (ask, quantity)\n        return actions\n","code_sha256":"f4bfc616ca493987f95e5432035d45087edea45b5485d24e05fc9ff0d718997c","code_s0":"import math\nfrom orderbook_pm_challenge.types import CancelAll, PlaceOrder, Side\n\n\nclass Strategy:\n    WIDTH = 2\n    NOTIONAL = 4.0\n\n    def __init__(self):\n        self.last_quotes = None\n        self.mid = None\n\n    def estimate(self, bid, ask):\n        if self.last_quotes is None:\n            self.mid = (bid + ask) / 2\n        else:\n            old_bid, old_ask = self.last_quotes\n            if ask > old_ask:\n                self.mid = ask - .6\n            elif bid < old_bid:\n                self.mid = bid + .6\n            elif bid > old_bid:\n                self.mid = max(self.mid, bid + 1.2)\n            elif ask < old_ask:\n                self.mid = min(self.mid, ask - 1.2)\n        self.mid = max(bid + .5, min(ask - .5, self.mid)) if ask > bid + 1 else (bid + ask) / 2\n        self.last_quotes = bid, ask\n        return self.mid\n\n    def on_step(self, state):\n        bid0 = state.competitor_best_bid_ticks\n        ask0 = state.competitor_best_ask_ticks\n        if bid0 is None and ask0 is None:\n            return [CancelAll()]\n        if bid0 is None:\n            bid0 = max(1, ask0 - 6)\n        if ask0 is None:\n            ask0 = min(99, bid0 + 6)\n        mid = self.estimate(bid0, ask0)\n        bid = math.floor(mid - self.WIDTH)\n        ask = math.ceil(mid + self.WIDTH)\n        actions = [CancelAll()]\n        if 1 <= bid <= 99 and bid > bid0 and bid < ask0 and bid < mid - 0.2:\n            price = bid / 100\n            quantity = min(80, self.NOTIONAL / price)\n            quantity = math.floor(quantity * 100) / 100\n            if price * quantity < state.cash / 2 and quantity >= .01:\n                actions.append(PlaceOrder(Side.BUY, bid, quantity))\n        if 1 <= ask <= 99 and ask < ask0 and ask > bid0 and ask > mid + 0.2:\n            price = ask / 100\n            quantity = min(80, self.NOTIONAL / price)\n            quantity = math.floor(quantity * 100) / 100\n            if (1-price) * quantity < state.cash / 2 and quantity >= .01:\n                actions.append(PlaceOrder(Side.SELL, ask, quantity))\n        return actions\n","tuning_score":{"seeds":"115040..115139","n":100,"s1_mean":-2.82641889828,"s0_mean":-6.721255563159,"mechanism_diff":3.8948366648789996,"mechanism_se":1.0306406316761612},"paired":{"seeds":"200000..200999","n":1000,"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,"s1_mean":-2.0272387198234,"s0_mean":-4.8970286662279,"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.","seconds_per_simulation":0.17562775089172647}
