{
  "key": "f-behind-level",
  "mech": "rest behind rival best inside midpoint band",
  "approach": "Blind subclass overlay of hash-verified N. At inclusive rival midpoint 20..80 cents, move bids at or above rival best bid to bid-1 and asks at or below rival best ask to ask+1. Quantities unchanged. Apply to new placements and surviving own resting orders; retain N cancellations. All spreads 1..4 eligible. One fixed variant; no tuning search or promotion.",
  "tried": [
    "behind: midpoint [20,80], one tick behind, all spreads; only variant"
  ],
  "next": "Reject the all-spread rest-behind overlay: holdout replicates the tuning loss. Screen only, never a promotion; no finalist seeds used.",
  "spreads_acted": [
    1,
    2,
    3,
    4
  ],
  "off_equals_n": {
    "passed": true,
    "seeds": [
      310000,
      310009
    ],
    "steps": 20000,
    "method": "Two independent instances receive identical StepState each callback; compare complete action lists, execute N actions."
  },
  "code": "from orderbook_pm_challenge.types import PlaceOrder as _Place, CancelOrder as _Cancel, CancelAll as _CancelAll, Side as _Side\nfrom dataclasses import replace as _replace\n\nclass Strategy(_N):\n    enabled = True\n    spreads_acted = (1, 2, 3, 4)\n\n    def on_step(self, state):\n        actions = list(super().on_step(state))\n        if not self.enabled or self.s not in self.spreads_acted:\n            return actions\n        bid = state.competitor_best_bid_ticks\n        ask = state.competitor_best_ask_ticks\n        if bid is None or ask is None or not 40 <= bid + ask <= 160:\n            return actions\n\n        def behind(side, price):\n            if side == _Side.BUY and price >= bid and bid > 1:\n                return bid - 1\n            if side == _Side.SELL and price <= ask and ask < 99:\n                return ask + 1\n            return price\n\n        moved = [\n            _replace(a, price_ticks=behind(a.side, a.price_ticks))\n            if isinstance(a, _Place) else a for a in actions\n        ]\n        # Resting orders that N leaves alive must follow the same price rule.\n        if not any(isinstance(a, _CancelAll) for a in actions):\n            cancelled = {a.order_id for a in actions if isinstance(a, _Cancel)}\n            adjustments = []\n            for order in state.own_orders:\n                if order.order_id in cancelled:\n                    continue\n                price = behind(order.side, order.price_ticks)\n                if price != order.price_ticks:\n                    adjustments.extend([\n                        _Cancel(order.order_id),\n                        _Place(order.side, price, order.remaining_quantity),\n                    ])\n            moved = adjustments + moved\n        return moved\n",
  "code_sha256": "0e0ae3279638bb6672854065fa1a1ccf0dd7ab912e3022093f8e1bf073c5a1a2",
  "assembled_sha256": "b459788a5040f3fe023c4fb6512e868cb54c7c39f3f92a27029ca16599969689",
  "tuning": {
    "incumbent_code_sha256": "bf0d179f3e47d28819f6fa7e0d25548c2ced43374c216d36460b00a26a26ffae",
    "seeds": [
      320000,
      320199
    ],
    "selected": "behind",
    "variants": [
      {
        "name": "behind",
        "paired": {
          "seeds": [
            320000,
            320199
          ],
          "n": 200,
          "complete": true,
          "missing_seeds": [],
          "overall": {
            "n": 200,
            "sum_d": -4045.5470299284,
            "sum_d2": 172643.09449863978,
            "mean_diff": -20.227735149642,
            "se": 1.510522893938135,
            "incumbent_mean": 98.47071831456549,
            "candidate_mean": 78.2429831649235,
            "retail_diff": -18.5598117446285,
            "arb_diff": -1.6679234050385
          },
          "by_spread": {
            "1": {
              "n": 50,
              "sum_d": -329.396951458,
              "sum_d2": 7775.869342092228,
              "mean_diff": -6.58793902916,
              "se": 1.5126436257657299,
              "incumbent_mean": 25.711261479664,
              "candidate_mean": 19.123322450504002,
              "retail_diff": 1.6355244770539994,
              "arb_diff": -8.223463506198
            },
            "2": {
              "n": 50,
              "sum_d": -509.2738799687,
              "sum_d2": 7402.59245663922,
              "mean_diff": -10.185477599374,
              "se": 0.9509167993544908,
              "incumbent_mean": 61.219908510538,
              "candidate_mean": 51.034430911164,
              "retail_diff": -11.95728876688,
              "arb_diff": 1.7718111675120003
            },
            "3": {
              "n": 48,
              "sum_d": -1119.3322523005,
              "sum_d2": 39900.77911995201,
              "mean_diff": -23.31942192292708,
              "se": 2.4731356306905106,
              "incumbent_mean": 130.8342429047854,
              "candidate_mean": 107.51482098185834,
              "retail_diff": -25.067521685812498,
              "arb_diff": 1.7480997628270833
            },
            "4": {
              "n": 52,
              "sum_d": -2087.5439462012,
              "sum_d2": 117563.85357995633,
              "mean_diff": -40.14507588848461,
              "se": 3.567874690008854,
              "incumbent_mean": 174.37579815333268,
              "candidate_mean": 134.23072226484808,
              "retail_diff": -38.31986718298846,
              "arb_diff": -1.8252087055596158
            }
          }
        }
      }
    ]
  },
  "paired": {
    "seeds": [
      430000,
      430499
    ],
    "n": 500,
    "complete": true,
    "missing_seeds": [],
    "overall": {
      "n": 500,
      "sum_d": -9097.4713684522,
      "sum_d2": 412232.3948300254,
      "mean_diff": -18.194942736904398,
      "se": 0.994381862011086,
      "incumbent_mean": 95.54201511346659,
      "candidate_mean": 77.3470723765622,
      "retail_diff": -16.7792795159174,
      "arb_diff": -1.4156632209834006
    },
    "by_spread": {
      "1": {
        "n": 131,
        "sum_d": -646.6903892993998,
        "sum_d2": 60388.02330811718,
        "mean_diff": -4.936567857247327,
        "se": 1.8326264778516703,
        "incumbent_mean": 38.277936657049615,
        "candidate_mean": 33.34136879980229,
        "retail_diff": 3.141004314660307,
        "arb_diff": -8.07757217188855
      },
      "2": {
        "n": 120,
        "sum_d": -1174.7681332522998,
        "sum_d2": 17016.686687058947,
        "mean_diff": -9.789734443769165,
        "se": 0.6215109125284222,
        "incumbent_mean": 77.8558643979175,
        "candidate_mean": 68.06612995414834,
        "retail_diff": -11.405172225211667,
        "arb_diff": 1.6154377814524992
      },
      "3": {
        "n": 133,
        "sum_d": -2996.7537469727004,
        "sum_d2": 103615.87825895115,
        "mean_diff": -22.531983059945116,
        "se": 1.4338349013541491,
        "incumbent_mean": 146.55140363646615,
        "candidate_mean": 124.01942057652104,
        "retail_diff": -24.22411039706015,
        "arb_diff": 1.6921273370804506
      },
      "4": {
        "n": 116,
        "sum_d": -4279.2590989278,
        "sum_d2": 231211.80657589808,
        "mean_diff": -36.89016464592931,
        "se": 2.3448759705751696,
        "incumbent_mean": 120.02204692465259,
        "candidate_mean": 83.13188227872328,
        "retail_diff": -36.29899977021379,
        "arb_diff": -0.5911648756922424
      }
    }
  },
  "failures": [],
  "check_values": [
    17.1160017503,
    20.0171113118,
    2.3903113616,
    241.4847522404
  ],
  "python_version": "3.12.3",
  "seconds_per_simulation": 0.5865310551596232
}
