{
  "key": "f-flow-scales",
  "approach": "Blind arrival-rate overlay: side-specific share-fill EWMAs (24 and 192 steps), 192-step warmup. When short > 1.35*long and long >= 0.02, add at N best resting price, scaled by min(1,short/long-1), capped at 20 collateral per side and a conservative available-cash bound. Cancel overlay orders each callback; hide them from N via dataclasses.replace. Other spreads pass through exactly.",
  "tried": {
    "incumbent_sha256": "bf0d179f3e47d28819f6fa7e0d25548c2ced43374c216d36460b00a26a26ffae",
    "seed_310000_edge": 17.1160017503,
    "expected_seed_check_passed": true,
    "tuning_seeds": [
      310000,
      310199
    ],
    "variants": [
      {
        "size": 0.3,
        "all_spreads": {
          "n": 200,
          "incumbent_mean": 85.16265316504199,
          "mean_diff": -0.08868171712300012,
          "se": 0.11107206618956622,
          "sum_d": -17.736343424600022,
          "sum_d2": 492.58564411762796,
          "retail_diff": 0.06490840637850036,
          "arb_diff": -0.15359012351349996
        },
        "by_spread": {
          "1": {
            "n": 47,
            "incumbent_mean": 30.59600304578298,
            "mean_diff": -0.3476930171638291,
            "se": 0.47417262404820476,
            "sum_d": -16.341571806699967,
            "sum_d2": 491.7852329384662,
            "retail_diff": 0.2705280611255319,
            "arb_diff": -0.6182210783425534
          },
          "2": {
            "n": 57,
            "incumbent_mean": 81.35713208259824,
            "mean_diff": -0.03040935585964919,
            "se": 0.01479569515689153,
            "sum_d": -1.733333284000004,
            "sum_d2": 0.7514785524572484,
            "retail_diff": 0.0020056553263157035,
            "arb_diff": -0.03241501118596477
          },
          "3": {
            "n": 53,
            "incumbent_mean": 115.06691980369057,
            "mean_diff": 0.0006626802698113948,
            "se": 0.0006626802698113948,
            "sum_d": 0.035122054300003924,
            "sum_d2": 0.0012335586982524242,
            "retail_diff": 0.0009765586943396764,
            "arb_diff": -0.0003138784245282984
          },
          "4": {
            "n": 43,
            "incumbent_mean": 112.9910514314628,
            "mean_diff": 0.007056735158138255,
            "se": 0.005022528153505198,
            "sum_d": 0.30343961179994494,
            "sum_d2": 0.047699068006231214,
            "retail_diff": 0.002343777637211027,
            "arb_diff": 0.00471295752325599
          }
        }
      },
      {
        "size": 0.6,
        "all_spreads": {
          "n": 200,
          "incumbent_mean": 85.16265316504199,
          "mean_diff": -0.16274887667699978,
          "se": 0.12463031326368784,
          "sum_d": -32.54977533539996,
          "sum_d2": 623.4994957432828,
          "retail_diff": 0.11164366827600032,
          "arb_diff": -0.27439254497
        },
        "by_spread": {
          "1": {
            "n": 47,
            "incumbent_mean": 30.59600304578298,
            "mean_diff": -0.5634068311382975,
            "se": 0.5245441693317695,
            "sum_d": -26.48012106349998,
            "sum_d2": 609.7859991204101,
            "retail_diff": 0.4667042503297853,
            "arb_diff": -1.030111081538298
          },
          "2": {
            "n": 57,
            "incumbent_mean": 81.35713208259824,
            "mean_diff": -0.050768514957894445,
            "se": 0.02200975212245427,
            "sum_d": -2.8938053525999834,
            "sum_d2": 1.6932121699947886,
            "retail_diff": 0.0020056553263157035,
            "arb_diff": -0.05277417028421049
          },
          "3": {
            "n": 53,
            "incumbent_mean": 115.06691980369057,
            "mean_diff": 0.0022759300981132547,
            "se": 0.0022759300981132547,
            "sum_d": 0.12062429520000251,
            "sum_d2": 0.014550220592497347,
            "retail_diff": 0.003364699950943443,
            "arb_diff": -0.0010887698547169806
          },
          "4": {
            "n": 43,
            "incumbent_mean": 112.9910514314628,
            "mean_diff": -0.0766621677790697,
            "se": 0.08067070538578228,
            "sum_d": -3.296473214499997,
            "sum_d2": 12.005734232285274,
            "retail_diff": 0.0023484288069804005,
            "arb_diff": -0.07901059658604646
          }
        }
      }
    ],
    "selection": "For each size choose spreads with tuning mean > one paired SE, falling back to highest-mean spread if empty; choose size with largest resulting all-seed mean. Frozen before holdout.",
    "selected_size": 0.3,
    "off_action_equality_seeds": [
      310000,
      310009
    ],
    "assembly_action_equality_seeds": [
      310009,
      310013,
      310021,
      310023,
      310024
    ],
    "assembly_equals_s1": true,
    "simulator_commit": "b244530ee2a6247b5f930830eeca9dd950da0e7e",
    "execution": "Unmodified simulator, default ChallengeConfig and ParameterVariance, 2000 steps, one OS process, no sandbox. No finalist seeds used.",
    "synthetic_checks": [
      "Burst adds orders at native best prices",
      "Added orders hidden from incumbent",
      "Fading signal releases extra size",
      "Other spreads return incumbent action object untouched"
    ],
    "holdout_nonzero_pairs": 6,
    "limitations": "Conservative cash bound ignores collateral released by cancellations; extra orders are cancelled and re-added each callback. Activity and observed edge changes are sparse."
  },
  "next": "Do not promote: the 500-seed gain is below twice its paired SE and only 6 pairs changed edge. If pursued, independently replicate this frozen spread-4 overlay through a measure item; do not retune on this holdout or use finalist seeds in fresh items.",
  "spreads_acted": [
    4
  ],
  "off_equals_n": true,
  "code": "from dataclasses import replace as _flow_replace\nfrom orderbook_pm_challenge.types import PlaceOrder as _FlowPlace, CancelOrder as _FlowCancel, CancelAll as _FlowCancelAll, Side as _FlowSide\nimport math as _flow_math\n\nclass Strategy(_N):\n    # Composition: the superclass is never initialized or called on self.\n    FLOW_SPREADS = (4,)\n    FLOW_SIZE = 0.3\n\n    def __init__(self):\n        self._incumbent = _N()\n        self._flow_short = [0.0, 0.0]\n        self._flow_long = [0.0, 0.0]\n        self._flow_spread = None\n        self._flow_serial = 0\n        self._flow_ids = set()\n\n    def on_step(self, state):\n        if self._flow_spread is None:\n            bid = state.competitor_best_bid_ticks\n            ask = state.competitor_best_ask_ticks\n            self._flow_spread = max(1, (ask - bid + 1) // 2) if bid is not None and ask is not None else 0\n        if self._flow_spread not in self.FLOW_SPREADS:\n            return self._incumbent.on_step(state)\n        for i, value in enumerate((state.buy_filled_quantity, state.sell_filled_quantity)):\n            self._flow_short[i] += (value - self._flow_short[i]) / 24.0\n            self._flow_long[i] += (value - self._flow_long[i]) / 192.0\n        extras = tuple(o for o in state.own_orders if o.order_id in self._flow_ids)\n        native = tuple(o for o in state.own_orders if o.order_id not in self._flow_ids)\n        base_actions = list(self._incumbent.on_step(_flow_replace(state, own_orders=native)))\n        actions = [_FlowCancel(o.order_id) for o in extras] + base_actions\n        self._flow_ids.clear()\n        # Reconstruct N's resting quotes from its public actions, never its code.\n        projected = {o.order_id: (o.side, o.price_ticks, o.remaining_quantity) for o in native}\n        pending = []\n        budget = max(0.0, state.free_cash)\n        for action in base_actions:\n            if isinstance(action, _FlowCancelAll):\n                projected.clear()\n                pending.clear()\n            elif isinstance(action, _FlowCancel):\n                projected.pop(action.order_id, None)\n                pending = [(key, v) for key, v in pending if key != action.order_id]\n            elif isinstance(action, _FlowPlace):\n                pending.append((action.client_order_id, (action.side, action.price_ticks, action.quantity)))\n                unit = action.price_ticks / 100.0 if action.side == _FlowSide.BUY else 1.0 - action.price_ticks / 100.0\n                budget -= unit * action.quantity\n        # Ignore all collateral released by cancellations: conservative free-cash bound.\n        budget = max(0.0, budget)\n        quotes = list(projected.values()) + [v for _, v in pending]\n        if state.step < 192:\n            return actions\n        for i, side in enumerate((_FlowSide.BUY, _FlowSide.SELL)):\n            short, long = self._flow_short[i], self._flow_long[i]\n            if short <= 1.35 * long or long < 0.02:\n                continue\n            own = [q for q in quotes if q[0] == side]\n            if not own:\n                continue\n            price = (max if side == _FlowSide.BUY else min)(q[1] for q in own)\n            size = sum(q[2] for q in own if q[1] == price)\n            unit = price / 100.0 if side == _FlowSide.BUY else 1.0 - price / 100.0\n            desired = size * self.FLOW_SIZE * min(1.0, short / long - 1.0)\n            quantity = _flow_math.floor(min(desired, 20.0 / unit, budget / unit) * 100.0) / 100.0\n            if quantity < 0.01:\n                continue\n            self._flow_serial += 1\n            oid = '__flow_scales_extra_' + str(self._flow_serial)\n            self._flow_ids.add(oid)\n            actions.append(_FlowPlace(side, price, quantity, oid))\n            budget = max(0.0, budget - unit * quantity)\n        return actions\n",
  "code_sha256": "32f15d36aa069f24f51d668f00a8078f4a81dc646ed13252cbff516e3b16f9b7",
  "assembled_sha256": "18419c9594a4e685223f3d2eed57f197ccf29f36c13c02f4078e5b9f8e33599f",
  "tuning": {
    "n": 200,
    "mean_diff": 0.0015171980589997248,
    "se": 0.0010894502096014396
  },
  "paired": {
    "n": 500,
    "incumbent_mean": 104.4137531881468,
    "mean_diff": 0.08052538148639997,
    "se": 0.04882673466936453,
    "sum_d": 40.26269074319998,
    "sum_d2": 598.06264814066,
    "retail_diff": 0.07047975590079988,
    "arb_diff": 0.010045625584000057,
    "first_seed": 410000,
    "last_seed": 410499,
    "complete": true,
    "failures": []
  },
  "by_spread": {
    "1": {
      "incumbent_mean": 28.495154459731307,
      "mean_diff": 0.0,
      "se": 0.0,
      "sum_d": 0.0,
      "sum_d2": 0.0,
      "retail_diff": 0.0,
      "arb_diff": 0.0,
      "runs": 115
    },
    "2": {
      "incumbent_mean": 97.76626247947758,
      "mean_diff": 0.0,
      "se": 0.0,
      "sum_d": 0.0,
      "sum_d2": 0.0,
      "retail_diff": 0.0,
      "arb_diff": 0.0,
      "runs": 116
    },
    "3": {
      "incumbent_mean": 128.4054514027384,
      "mean_diff": 0.0,
      "se": 0.0,
      "sum_d": 0.0,
      "sum_d2": 0.0,
      "retail_diff": 0.0,
      "arb_diff": 0.0,
      "runs": 138
    },
    "4": {
      "incumbent_mean": 151.67248160310686,
      "mean_diff": 0.3073487842992365,
      "se": 0.18544956708277158,
      "sum_d": 40.26269074319998,
      "sum_d2": 598.06264814066,
      "retail_diff": 0.26900670191144993,
      "arb_diff": 0.038342082381679604,
      "runs": 131
    }
  },
  "seconds_per_simulation": 0.37700343490811067
}
