{
  "approach": "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 (held constant thereafter, since under the documented latent process p_t is a martingale and no further signal about it is exposed to the strategy), sized with a flat per-side notional intended to capture a slice of expected retail flow while bounding inventory. S1 is identical except that after any fill on a side (buy_filled_quantity>0 or sell_filled_quantity>0), that side's quote is withdrawn for cooldown_steps steps, then reposted widen_ticks wider than the base half-spread for widen_duration further steps before reverting to the base spread. Rationale from the rules only: a fill means either the informed arbitrageur swept a stale quote against the true probability, or retail landed on us; either way that side is more likely mispriced immediately afterward, so pulling and re-widening it reduces repeated adverse fills.",
  "tried": [
    {
      "variant": "S0 half_spread=4 quote_size=10",
      "tuning_mean_total_edge": -12.2891754824338
    },
    {
      "variant": "S0 half_spread=3 quote_size=10",
      "tuning_mean_total_edge": -12.268148442899001
    },
    {
      "variant": "S0 half_spread=5 quote_size=14 (frozen)",
      "tuning_mean_total_edge": -11.9676603661224
    },
    {
      "variant": "S0 half_spread=6 quote_size=10",
      "tuning_mean_total_edge": -12.7713530810822
    },
    {
      "variant": "S1 base + cooldown=3 widen=6 duration=5",
      "tuning_mean_total_edge": -12.257141485816799
    },
    {
      "variant": "S1 base + cooldown=5 widen=10 duration=8",
      "tuning_mean_total_edge": -13.9208608052976
    },
    {
      "variant": "S1 base + cooldown=2 widen=4 duration=3 (frozen)",
      "tuning_mean_total_edge": -11.8240881954648
    },
    {
      "variant": "S1 base + cooldown=4 widen=8 duration=10",
      "tuning_mean_total_edge": -13.2890319203288
    }
  ],
  "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 clear the promotion bar and should not be promoted standalone. The tuning set is small (500 seeds) relative to the per-seed noise, so the tuning-set win looks like overfitting. Before retrying: (1) make the probability estimate track the market instead of staying fixed at the step-0 competitor midpoint, since most of both S0 and S1's loss is arb_edge from a stale fixed quote being swept as p_t drifts, which likely swamps any adverse-selection benefit; (2) retest the timer against a non-static base that already reduces staleness, where pulling a just-filled side should matter more; (3) if kept standalone, tune cooldown/widen on a larger tuning sample before any holdout run.",
  "code": "from __future__ import annotations\n\nfrom orderbook_pm_challenge.strategy import BaseStrategy\nfrom orderbook_pm_challenge.types import CancelAll, PlaceOrder, Side, StepState\n\n\ndef _clip(v: int) -> int:\n    return max(1, min(99, v))\n\n\nclass Strategy(BaseStrategy):\n    \"\"\"S0 plus an adverse-selection timer.\n\n    Identical to S0 except: after any fill on a side, that side's quote is\n    withdrawn for `cooldown_steps` steps, then reposted `widen_ticks` wider\n    than the base half-spread for `widen_duration` further steps before\n    reverting to the base spread. The rationale (from the challenge rules\n    only): a fill happens either because an informed arbitrageur swept a\n    stale quote against the true probability, or retail flow landed on us;\n    either way the side that just traded is more likely to be mispriced\n    relative to the (unobserved) latent process immediately afterward, so\n    briefly pulling and re-widening that side reduces the chance of being\n    run over repeatedly by the same adverse move.\n    \"\"\"\n\n    half_spread = 5\n    quote_size = 14.0\n    max_inventory = 150.0\n    cooldown_steps = 2\n    widen_ticks = 4\n    widen_duration = 3\n\n    def __init__(self) -> None:\n        self.p_ticks: float | None = None\n        self.bid_cooldown = 0\n        self.ask_cooldown = 0\n        self.bid_widen_left = 0\n        self.ask_widen_left = 0\n\n    def _init_price(self, state: StepState) -> None:\n        bid = state.competitor_best_bid_ticks\n        ask = state.competitor_best_ask_ticks\n        if bid is not None and ask is not None:\n            self.p_ticks = (bid + ask) / 2.0\n        elif bid is not None:\n            self.p_ticks = bid + 1.0\n        elif ask is not None:\n            self.p_ticks = ask - 1.0\n        else:\n            self.p_ticks = 50.0\n\n    def on_step(self, state: StepState):\n        if self.p_ticks is None:\n            self._init_price(state)\n\n        if state.buy_filled_quantity > 0:\n            self.bid_cooldown = self.cooldown_steps\n            self.bid_widen_left = self.widen_duration\n        if state.sell_filled_quantity > 0:\n            self.ask_cooldown = self.cooldown_steps\n            self.ask_widen_left = self.widen_duration\n\n        actions = [CancelAll()]\n\n        bid_extra = self.widen_ticks if self.bid_widen_left > 0 else 0\n        ask_extra = self.widen_ticks if self.ask_widen_left > 0 else 0\n\n        bid_price = _clip(round(self.p_ticks - self.half_spread - bid_extra))\n        ask_price = _clip(round(self.p_ticks + self.half_spread + ask_extra))\n\n        place_bid = self.bid_cooldown <= 0\n        place_ask = self.ask_cooldown <= 0\n\n        if self.bid_cooldown > 0:\n            self.bid_cooldown -= 1\n        if self.ask_cooldown > 0:\n            self.ask_cooldown -= 1\n\n        if bid_price < ask_price:\n            if (\n                place_bid\n                and state.yes_inventory < self.max_inventory\n                and state.free_cash > (bid_price / 100.0) * self.quote_size\n            ):\n                actions.append(PlaceOrder(side=Side.BUY, price_ticks=bid_price, quantity=self.quote_size))\n                if self.bid_widen_left > 0:\n                    self.bid_widen_left -= 1\n\n            if (\n                place_ask\n                and state.no_inventory < self.max_inventory\n                and state.free_cash > (1.0 - ask_price / 100.0) * self.quote_size\n            ):\n                actions.append(PlaceOrder(side=Side.SELL, price_ticks=ask_price, quantity=self.quote_size))\n                if self.ask_widen_left > 0:\n                    self.ask_widen_left -= 1\n\n        return actions\n",
  "code_sha256": "8e9ed8909b277e13d697138b083235303b02238e93bd1612384ba9806e7515e0",
  "code_s0": "from __future__ import annotations\n\nfrom orderbook_pm_challenge.strategy import BaseStrategy\nfrom orderbook_pm_challenge.types import CancelAll, PlaceOrder, Side, StepState\n\n\ndef _clip(v: int) -> int:\n    return max(1, min(99, v))\n\n\nclass Strategy(BaseStrategy):\n    \"\"\"Static passive maker: quotes around a fixed probability estimate.\n\n    The probability estimate is a martingale point estimate anchored once\n    at the competitor midpoint (a reasonable proxy for the sampled starting\n    probability), then held fixed since the latent score process has no\n    further observable drift. Quote size is a flat notional sized to\n    capture a slice of expected per-step retail flow (retail arrival_rate\n    and mean_notional ranges per ParameterVariance defaults) while bounding\n    inventory and adverse-selection exposure with a minimum spread.\n    \"\"\"\n\n    half_spread = 5\n    quote_size = 14.0\n    max_inventory = 150.0\n\n    def __init__(self) -> None:\n        self.p_ticks: float | None = None\n\n    def _init_price(self, state: StepState) -> None:\n        bid = state.competitor_best_bid_ticks\n        ask = state.competitor_best_ask_ticks\n        if bid is not None and ask is not None:\n            self.p_ticks = (bid + ask) / 2.0\n        elif bid is not None:\n            self.p_ticks = bid + 1.0\n        elif ask is not None:\n            self.p_ticks = ask - 1.0\n        else:\n            self.p_ticks = 50.0\n\n    def on_step(self, state: StepState):\n        if self.p_ticks is None:\n            self._init_price(state)\n\n        actions = [CancelAll()]\n\n        bid_price = _clip(round(self.p_ticks - self.half_spread))\n        ask_price = _clip(round(self.p_ticks + self.half_spread))\n        if bid_price >= ask_price:\n            return actions\n\n        if state.yes_inventory < self.max_inventory and state.free_cash > (bid_price / 100.0) * self.quote_size:\n            actions.append(PlaceOrder(side=Side.BUY, price_ticks=bid_price, quantity=self.quote_size))\n\n        if state.no_inventory < self.max_inventory and state.free_cash > (1.0 - ask_price / 100.0) * self.quote_size:\n            actions.append(PlaceOrder(side=Side.SELL, price_ticks=ask_price, quantity=self.quote_size))\n\n        return actions\n",
  "tuning_score": {
    "seeds": "115000-115499",
    "n": 500,
    "s1_mean": -11.8240881954648,
    "s0_mean": -11.9676603661224
  },
  "paired": {
    "seeds": "200000-200999",
    "n": 1000,
    "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,
    "s1_mean": -10.6513733434077,
    "s0_mean": -10.417692815931199,
    "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.",
  "seconds_per_simulation": 0.25
}
