{
  "key": "f-cash-reserve-decay",
  "mech": "Decaying cash reserve r(step) = r0 * steps_remaining / 2000; trim lowest-priority new orders.",
  "approach": "Blind subclass overlay calls N first, retaining its action order as priority. New orders are resized or dropped to leave a linearly decaying cash reserve; YES-covered sells need no cash. Existing orders are untouched except for N cancellations. Individual existing SELL cancellation releases are conservatively ignored because their collateral allocation is hidden. Tune only r0 on 200 paired seeds; freeze the highest mean for 500 disjoint holdout seeds. All four spreads remain enabled.",
  "tried": [
    {
      "r0": 100.0,
      "tuning_mean_diff": -0.020700813612000036,
      "tuning_se": 0.07388117173201324
    },
    {
      "r0": 300.0,
      "tuning_mean_diff": -0.14058443294099957,
      "tuning_se": 0.20863297593610544
    },
    {
      "r0": 600.0,
      "tuning_mean_diff": -1.5721216704769998,
      "tuning_se": 0.7800851148612975
    }
  ],
  "next": "Screen only; retain N. Holdout does not justify pursuing this cash-reserve overlay.",
  "spreads_acted": [
    1,
    2,
    3,
    4
  ],
  "off_equals_n": {
    "passed": true,
    "seeds": "310000..310009",
    "simulations": 10,
    "steps_per_simulation": 2000,
    "steps_compared": 20000,
    "method": "Independent N and reserve_initial=0 overlay instances receive each identical StepState; action sequences compared by equality every callback in one N-equivalent trajectory per seed."
  },
  "code": "from orderbook_pm_challenge.types import PlaceOrder, CancelOrder, CancelAll, Side\nfrom orderbook_pm_challenge.utils import quantize_down\n\nclass Strategy(_N):\n    # Earlier new orders in N's action sequence have higher priority.\n    reserve_initial = 100.0\n    spreads_acted = (1, 2, 3, 4)\n\n    def on_step(self, state):\n        actions = super().on_step(state)\n        if self.reserve_initial <= 0 or self.s not in self.spreads_acted:\n            return actions\n        reserve = self.reserve_initial * state.steps_remaining / 2000.0\n        free = state.free_cash\n        # Existing SELL collateral allocations are not exposed. Treat all their\n        # quantity as covered when bounding free YES, and release no cash for\n        # individual existing SELL cancellations. CancelAll releases exactly.\n        yes_free = max(0.0, state.yes_inventory - sum(\n            o.remaining_quantity for o in state.own_orders if o.side == Side.SELL))\n        existing = {o.order_id: o for o in state.own_orders}\n        new_allocations = {}\n        out = []\n        for a in actions:\n            if isinstance(a, CancelAll):\n                free = state.cash\n                yes_free = state.yes_inventory\n                existing.clear()\n                new_allocations.clear()\n                out.append(a)\n            elif isinstance(a, CancelOrder):\n                o = existing.pop(a.order_id, None)\n                if o is not None and o.side == Side.BUY:\n                    free += o.remaining_quantity * o.price_ticks / 100.0\n                allocation = new_allocations.pop(a.order_id, None)\n                if allocation is not None:\n                    free += allocation[0]\n                    yes_free += allocation[1]\n                out.append(a)\n            elif isinstance(a, PlaceOrder):\n                p = a.price_ticks / 100.0\n                budget = max(0.0, free - reserve)\n                covered = 0.0 if a.side == Side.BUY else yes_free\n                unit = p if a.side == Side.BUY else 1.0 - p\n                q = quantize_down(min(a.quantity, covered + budget / unit), 0.01)\n                if q <= 0:\n                    continue\n                cover = min(q, covered)\n                cost = round((q - cover) * unit, 10)\n                free -= cost\n                yes_free -= cover\n                if a.client_order_id is not None:\n                    new_allocations[a.client_order_id] = (cost, cover)\n                out.append(a if q == a.quantity else PlaceOrder(\n                    a.side, a.price_ticks, q, a.client_order_id))\n            else:\n                out.append(a)\n        return out\n",
  "code_sha256": "caa2006c0fa32051c1a6df8462948b3540b3619933ab342c3f6e3eaf2fc07878",
  "assembled_sha256": "1ba3a32eef28174df81ed0e06bb5ba35dc55016baa486be669f079ad6484afa8",
  "tuning": {
    "seeds": "320000..320199",
    "selected": {
      "label": "r100",
      "r0": 100.0,
      "spreads_acted": [
        1,
        2,
        3,
        4
      ],
      "selection_rule": "Highest overall paired tuning mean; ties prefer smaller r0."
    },
    "variants": [
      {
        "id": "r100",
        "r0": 100.0,
        "spreads_acted": [
          1,
          2,
          3,
          4
        ],
        "overall": {
          "n": 200,
          "sum_d": -4.1401627224000075,
          "sum_d2": 217.33112068935,
          "mean_diff": -0.020700813612000036,
          "se": 0.07388117173201324,
          "incumbent_mean": 98.47071831456549,
          "candidate_mean": 98.4500175009535,
          "retail_diff": 0.08299044732000041,
          "arb_diff": -0.10369126093450012
        },
        "by_spread": {
          "1": {
            "n": 50,
            "sum_d": 0.0,
            "sum_d2": 0.0,
            "mean_diff": 0.0,
            "se": 0.0,
            "incumbent_mean": 25.711261479664,
            "candidate_mean": 25.711261479664,
            "retail_diff": 0.0,
            "arb_diff": 0.0
          },
          "2": {
            "n": 50,
            "sum_d": 3.2955435006000044,
            "sum_d2": 11.664562781002088,
            "mean_diff": 0.06591087001200009,
            "se": 0.0683548682759801,
            "incumbent_mean": 61.219908510538,
            "candidate_mean": 61.28581938055,
            "retail_diff": 0.13487774907999892,
            "arb_diff": -0.06896687906799989
          },
          "3": {
            "n": 48,
            "sum_d": -11.123008206199984,
            "sum_d2": 134.21464183900338,
            "mean_diff": -0.23172933762916634,
            "se": 0.2415570011461482,
            "incumbent_mean": 130.8342429047854,
            "candidate_mean": 130.60251356715625,
            "retail_diff": -0.03351949403958324,
            "arb_diff": -0.1982098435958334
          },
          "4": {
            "n": 52,
            "sum_d": 3.687301983199972,
            "sum_d2": 71.45191606934453,
            "mean_diff": 0.07090965352307638,
            "se": 0.1638415740091206,
            "incumbent_mean": 174.37579815333268,
            "candidate_mean": 174.44670780685576,
            "retail_diff": 0.2204449562288487,
            "arb_diff": -0.14953530270961585
          }
        }
      },
      {
        "id": "r300",
        "r0": 300.0,
        "spreads_acted": [
          1,
          2,
          3,
          4
        ],
        "overall": {
          "n": 200,
          "sum_d": -28.11688658819991,
          "sum_d2": 1736.3559987456997,
          "mean_diff": -0.14058443294099957,
          "se": 0.20863297593610544,
          "incumbent_mean": 98.47071831456549,
          "candidate_mean": 98.33013388162449,
          "retail_diff": -0.05861316693650011,
          "arb_diff": -0.08197126600500017
        },
        "by_spread": {
          "1": {
            "n": 50,
            "sum_d": 0.00019719900001291535,
            "sum_d2": 3.8887445606093786e-08,
            "mean_diff": 3.943980000258307e-06,
            "se": 3.943980000258307e-06,
            "incumbent_mean": 25.711261479664,
            "candidate_mean": 25.711265423644,
            "retail_diff": 5.888442000241412e-06,
            "arb_diff": -1.9444619999831046e-06
          },
          "2": {
            "n": 50,
            "sum_d": 2.1018200775999745,
            "sum_d2": 10.707732886062994,
            "mean_diff": 0.04203640155199949,
            "se": 0.06583647005344641,
            "incumbent_mean": 61.219908510538,
            "candidate_mean": 61.26194491209,
            "retail_diff": 0.10667980043799957,
            "arb_diff": -0.0646433988839999
          },
          "3": {
            "n": 48,
            "sum_d": -6.064653381899916,
            "sum_d2": 108.45932223018939,
            "mean_diff": -0.12634694545624825,
            "se": 0.2184863627129835,
            "incumbent_mean": 130.8342429047854,
            "candidate_mean": 130.70789595932916,
            "retail_diff": -0.14000730001666759,
            "arb_diff": 0.013660354574999811
          },
          "4": {
            "n": 52,
            "sum_d": -24.154250482899982,
            "sum_d2": 1617.18894359056,
            "mean_diff": -0.4645048169788458,
            "se": 0.778183186404617,
            "incumbent_mean": 174.37579815333268,
            "candidate_mean": 173.91129333635385,
            "retail_diff": -0.19878014289423016,
            "arb_diff": -0.26572467410192363
          }
        }
      },
      {
        "id": "r600",
        "r0": 600.0,
        "spreads_acted": [
          1,
          2,
          3,
          4
        ],
        "overall": {
          "n": 200,
          "sum_d": -314.42433409539996,
          "sum_d2": 24713.918209197593,
          "mean_diff": -1.5721216704769998,
          "se": 0.7800851148612975,
          "incumbent_mean": 98.47071831456549,
          "candidate_mean": 96.8985966440885,
          "retail_diff": -1.3295607554030002,
          "arb_diff": -0.2425609150775001
        },
        "by_spread": {
          "1": {
            "n": 50,
            "sum_d": -8.64515752850005,
            "sum_d2": 57.799664624152754,
            "mean_diff": -0.172903150570001,
            "se": 0.1515967928828569,
            "incumbent_mean": 25.711261479664,
            "candidate_mean": 25.538358329094,
            "retail_diff": -0.21921486129800016,
            "arb_diff": 0.046311710719999934
          },
          "2": {
            "n": 50,
            "sum_d": 1.138793701200015,
            "sum_d2": 12.229867275750907,
            "mean_diff": 0.022775874024000303,
            "se": 0.07057758866658027,
            "incumbent_mean": 61.219908510538,
            "candidate_mean": 61.242684384562,
            "retail_diff": 0.06298774327999979,
            "arb_diff": -0.04021186925599988
          },
          "3": {
            "n": 48,
            "sum_d": -155.9638200195,
            "sum_d2": 11199.674193738938,
            "mean_diff": -3.24924625040625,
            "se": 2.1771000842283614,
            "incumbent_mean": 130.8342429047854,
            "candidate_mean": 127.58499665437917,
            "retail_diff": -3.271743822029167,
            "arb_diff": 0.022497571631249953
          },
          "4": {
            "n": 52,
            "sum_d": -150.95415024859994,
            "sum_d2": 13444.214483558753,
            "mean_diff": -2.9029644278576914,
            "se": 2.214548082756551,
            "incumbent_mean": 174.37579815333268,
            "candidate_mean": 171.47283372547503,
            "retail_diff": -1.943405610044231,
            "arb_diff": -0.9595588178269236
          }
        }
      }
    ]
  },
  "paired": {
    "seeds": "430000..430499",
    "n": 500,
    "complete": true,
    "missing_seeds": [],
    "overall": {
      "n": 500,
      "sum_d": -19.860491591400063,
      "sum_d2": 696.3231811251983,
      "mean_diff": -0.039720983182800124,
      "se": 0.05279879389497742,
      "incumbent_mean": 95.54201511346659,
      "candidate_mean": 95.5022941302838,
      "retail_diff": 0.011772989251399999,
      "arb_diff": -0.051493972433000065
    },
    "by_spread": {
      "1": {
        "n": 131,
        "sum_d": -15.17478246850002,
        "sum_d2": 109.467924472143,
        "mean_diff": -0.11583803411068717,
        "se": 0.07952815471899553,
        "incumbent_mean": 38.277936657049615,
        "candidate_mean": 38.162098622938935,
        "retail_diff": -0.03211553988167881,
        "arb_diff": -0.08372249421984751
      },
      "2": {
        "n": 120,
        "sum_d": -8.729082103200028,
        "sum_d2": 77.9359944996796,
        "mean_diff": -0.07274235086000023,
        "se": 0.07357470171844521,
        "incumbent_mean": 77.8558643979175,
        "candidate_mean": 77.7831220470575,
        "retail_diff": -0.05680472184583388,
        "arb_diff": -0.015937629013333333
      },
      "3": {
        "n": 133,
        "sum_d": 7.815459471599986,
        "sum_d2": 470.61894475171226,
        "mean_diff": 0.05876285316992471,
        "se": 0.1636477007192303,
        "incumbent_mean": 146.55140363646615,
        "candidate_mean": 146.61016648963607,
        "retail_diff": 0.10901398770676626,
        "arb_diff": -0.050251134541353465
      },
      "4": {
        "n": 116,
        "sum_d": -3.7720864913000014,
        "sum_d2": 38.30031740166342,
        "mean_diff": -0.03251798699396553,
        "se": 0.053496666335487074,
        "incumbent_mean": 120.02204692465259,
        "candidate_mean": 119.98952893765862,
        "retail_diff": 0.020787384540517893,
        "arb_diff": -0.05330537153534483
      }
    }
  },
  "failures": [],
  "check_values": [
    17.1160017503,
    20.0171113118,
    2.3903113616,
    241.4847522404
  ],
  "python_version": "3.12.3",
  "seconds_per_simulation": 0.2763795278945731,
  "scoreboard": {
    "incumbent_code_sha256": "bf0d179f3e47d28819f6fa7e0d25548c2ced43374c216d36460b00a26a26ffae",
    "incumbent_retained": true,
    "promotions": [],
    "candidate_code_sha256": "caa2006c0fa32051c1a6df8462948b3540b3619933ab342c3f6e3eaf2fc07878",
    "screen_paired_mean_diff": -0.039720983182800124,
    "screen_paired_se": 0.05279879389497742
  },
  "validation": {
    "simulator_commit": "b244530ee2a6247b5f930830eeca9dd950da0e7e",
    "serial": true,
    "sandbox": false,
    "default_config_and_variance": true,
    "steps": 2000,
    "candidate_variants": 3,
    "tuning_and_holdout_disjoint": true,
    "finalist_seeds_used": false,
    "overlay_unit_checks": [
      "N action priority",
      "covered SELL collateral",
      "linear reserve decay",
      "inactive spread identity",
      "market collateral validation"
    ],
    "evidence_note": "Metrics are local measurements; source URLs identify the unmodified simulator and opaque incumbent input. No promotion or finalist evidence is claimed."
  }
}
