{
  "key": "f-drift-skew",
  "approach": "Blind latent-score trend shrinkage. Competitor midpoint p is inverse-normal transformed to x=Phi^-1(p)*sqrt(steps_remaining). EWMA(128) of clipped x increments estimates score slope; shrink slope by 90% toward zero. Predicted dp=phi(z)*(z/(2*T)+0.1*slope/sqrt(T)). Resize N placements by 1 +/- clip(gain*100*dp,-0.30,0.30): positive drift reduces sells and increases buys. Preserve prices, cancellations, and IDs; cap increases by available collateral. No added orders. No source inspection of N. Reference seed 310000 edge 17.1160017503 matches 17.116002 rounded. Current best hash bf0d179f3e47d28819f6fa7e0d25548c2ced43374c216d36460b00a26a26ffae.",
  "tried": {
    "selection": "For each gain retain spreads whose tuning mean exceeds one SE; if none, retain the single spread with largest mean. Choose gain with largest all-200-seed masked tuning mean. No holdout-based changes.",
    "variants": [
      {
        "gain": 8.0,
        "spreads": [
          1
        ],
        "tuning": {
          "n": 200,
          "mean_diff": -2.8112894160675,
          "se": 1.142947729493399,
          "sum_d": -562.2578832135,
          "sum_d2": 53572.58422787244
        },
        "by_spread": {
          "1": {
            "n": 47,
            "mean_diff": -11.962933685393617,
            "se": 4.654895588548315,
            "sum_d": -562.2578832135,
            "sum_d2": 53572.58422787244
          },
          "2": {
            "n": 57,
            "mean_diff": -52.989859775278944,
            "se": 12.659452878171267,
            "sum_d": -3020.4220071909,
            "sum_d2": 671607.2356046593
          },
          "3": {
            "n": 53,
            "mean_diff": -74.62404931025283,
            "se": 15.627017005064882,
            "sum_d": -3955.0746134434003,
            "sum_d2": 968168.9712528032
          },
          "4": {
            "n": 43,
            "mean_diff": -75.64866548901628,
            "se": 17.881436374816204,
            "sum_d": -3252.8926160277,
            "sum_d2": 823537.8402704104
          }
        }
      },
      {
        "gain": 24.0,
        "spreads": [
          1
        ],
        "tuning": {
          "n": 200,
          "mean_diff": -3.2258301936660003,
          "se": 1.2631738468640987,
          "sum_d": -645.1660387332,
          "sum_d2": 65586.40115025098
        },
        "by_spread": {
          "1": {
            "n": 47,
            "mean_diff": -13.726936994323404,
            "se": 5.122470838027282,
            "sum_d": -645.1660387332,
            "sum_d2": 65586.40115025098
          },
          "2": {
            "n": 57,
            "mean_diff": -64.45035890801404,
            "se": 15.103334678091432,
            "sum_d": -3673.6704577568,
            "sum_d2": 964898.7926400121
          },
          "3": {
            "n": 53,
            "mean_diff": -97.85951668322075,
            "se": 23.039946852052367,
            "sum_d": -5186.5543842107,
            "sum_d2": 1970546.405295615
          },
          "4": {
            "n": 43,
            "mean_diff": -94.57217578933721,
            "se": 21.95019291868184,
            "sum_d": -4066.6035589415,
            "sum_d2": 1254738.1569579944
          }
        }
      }
    ]
  },
  "next": "Do not promote: this frozen overlay loses to N on the 500-seed paired holdout. Preserve N. A separate future experiment could test whether quantity changes disrupt incumbent order management; that explanation is a hypothesis, not established here. Finalist seeds 900000..903999 were untouched.",
  "spreads_acted": [
    1
  ],
  "off_equals_n": true,
  "code": "import math as _ds_math\nfrom statistics import NormalDist as _DSNormal\nfrom dataclasses import replace as _ds_replace\nfrom orderbook_pm_challenge.types import PlaceOrder as _DSPlace, CancelAll as _DSAll, CancelOrder as _DSCancel, Side as _DSSide\n\nclass Strategy:\n    # Latent normal-score slope is shrunk 90% toward its zero-trend prior.\n    spreads = (1,)\n    gain = 8.0\n    enabled = True\n\n    def __init__(self):\n        self.n = _N()\n        self.s = None\n        self.last_x = None\n        self.slope = 0.0\n        self.normal = _DSNormal()\n\n    def on_step(self, state):\n        actions = self.n.on_step(state)\n        if self.s is None:\n            b, a = state.competitor_best_bid_ticks, state.competitor_best_ask_ticks\n            self.s = max(1, (a-b+1)//2) if a is not None and b is not None else 0\n        if not self.enabled or self.s not in self.spreads:\n            return actions\n        b, a = state.competitor_best_bid_ticks, state.competitor_best_ask_ticks\n        if a is None or b is None:\n            return actions\n        p = min(0.995, max(0.005, (a+b)/200.0))\n        t = max(1, state.steps_remaining)\n        z = self.normal.inv_cdf(p)\n        x = z * _ds_math.sqrt(t)\n        if self.last_x is not None:\n            delta = min(1.0, max(-1.0, x-self.last_x))\n            self.slope += (delta-self.slope)/128.0\n        self.last_x = x\n        drift = _ds_math.exp(-0.5*z*z)/_ds_math.sqrt(2*_ds_math.pi) * (z/(2*t) + 0.1*self.slope/_ds_math.sqrt(t))\n        skew = min(0.30, max(-0.30, self.gain*100*drift))\n        # Resize only N's placements. No added orders need hiding from N.\n        # Maintain a collateral ledger to keep increases valid after cancellations.\n        orders = {o.order_id: (o.side, o.price_ticks, o.remaining_quantity) for o in state.own_orders}\n        def reserves():\n            yes = state.yes_inventory\n            cash = 0.0\n            for side, tick, qty in orders.values():\n                if side == _DSSide.BUY:\n                    cash += qty*tick/100.0\n                else:\n                    covered = min(yes, qty)\n                    yes -= covered\n                    cash += (qty-covered)*(1-tick/100.0)\n            return cash, yes\n        out = []\n        for i, action in enumerate(actions):\n            if isinstance(action, _DSAll):\n                orders.clear()\n            elif isinstance(action, _DSCancel):\n                orders.pop(action.order_id, None)\n            elif isinstance(action, _DSPlace):\n                used, yes = reserves()\n                free = max(0.0, state.cash-used-1e-7)\n                price = action.price_ticks/100.0\n                capacity = free/price if action.side == _DSSide.BUY else yes+free/(1-price)\n                factor = 1+skew if action.side == _DSSide.BUY else 1-skew\n                qty = _ds_math.floor(min(action.quantity*factor, capacity)*100+1e-9)/100.0\n                if qty < 0.01:\n                    continue\n                action = _ds_replace(action, quantity=qty)\n                orders[action.client_order_id or ('__drift', i)] = (action.side, action.price_ticks, qty)\n            out.append(action)\n        return out\n",
  "code_sha256": "ef39c3c81b0a1881e544e3c2f40faf9d3401143ca906431d044ada27c53cd834",
  "assembled_sha256": "08cb7e9758be0000f74cc90dc9166e92645b6e599ef042abeab699afb4623f2c",
  "tuning": {
    "n": 200,
    "mean_diff": -2.8112894160675,
    "se": 1.142947729493399
  },
  "paired": {
    "n": 500,
    "mean_diff": -2.0238095518382,
    "se": 0.6009124229704581,
    "sum_d": -1011.9047759191,
    "sum_d2": 92141.28970107235,
    "first_seed": 410000,
    "last_seed": 410499,
    "complete": true,
    "incumbent_mean": 104.4137531881468,
    "retail_diff": -1.8872337652555997,
    "arb_diff": -0.1365757865886,
    "failures": []
  },
  "by_spread": {
    "1": {
      "mean_diff": -8.799171964513913,
      "se": 2.5197521091442283,
      "sum_d": -1011.9047759191,
      "sum_d2": 92141.28970107235,
      "runs": 115,
      "incumbent_mean": 28.495154459731303,
      "retail_diff": -8.205364196763476,
      "arb_diff": -0.5938077677765218
    },
    "2": {
      "mean_diff": 0.0,
      "se": 0.0,
      "sum_d": 0.0,
      "sum_d2": 0.0,
      "runs": 116,
      "incumbent_mean": 97.76626247947759,
      "retail_diff": 0.0,
      "arb_diff": 0.0
    },
    "3": {
      "mean_diff": 0.0,
      "se": 0.0,
      "sum_d": 0.0,
      "sum_d2": 0.0,
      "runs": 138,
      "incumbent_mean": 128.4054514027384,
      "retail_diff": 0.0,
      "arb_diff": 0.0
    },
    "4": {
      "mean_diff": 0.0,
      "se": 0.0,
      "sum_d": 0.0,
      "sum_d2": 0.0,
      "runs": 131,
      "incumbent_mean": 151.67248160310686,
      "retail_diff": 0.0,
      "arb_diff": 0.0
    }
  },
  "seconds_per_simulation": 0.32827966268733144
}
