{"key":"f-post-fill-other-side","mech":"post-fill other side: move the opposite side best own order one tick inward after a fill; one callback variant selected","approach":"Blindly wrapped incumbent N. After N acts, a previous-step own buy fill moves the best remaining own sell inward by one tick, and a sell fill moves the best own buy inward. The move is skipped if N cancelled that order, if the spread marker is unavailable, or if conservative collateral is insufficient. The two-callback variant was screened too.","tried":["one callback after fill","two callbacks after fill","switched-off overlay equivalence on seeds 310000-310009"],"next":"Screen only; do not promote. The paired holdout is materially negative versus N.","spreads_acted":[1,2,3,4],"off_equals_n":true,"code":"from orderbook_pm_challenge.strategy import BaseStrategy\nfrom orderbook_pm_challenge.types import CancelAll, CancelOrder, PlaceOrder, Side, StepState\n\n\nclass Strategy(_N):\n    def __init__(self):\n        super().__init__()\n        self._post_side = None\n        self._post_left = 0\n\n    def on_step(self, state: StepState):\n        actions = list(super().on_step(state))\n        if not True:\n            return actions\n\n        spread = getattr(self, \"s\", None)\n        if spread not in (1, 2, 3, 4):\n            return actions\n        if state.buy_filled_quantity > 0.0:\n            self._post_side = Side.SELL\n            self._post_left = 1\n        elif state.sell_filled_quantity > 0.0:\n            self._post_side = Side.BUY\n            self._post_left = 1\n\n        if self._post_left <= 0 or self._post_side is None:\n            return actions\n\n        cancelled = {a.order_id for a in actions if isinstance(a, CancelOrder)}\n        cancelled_all = any(isinstance(a, CancelAll) for a in actions)\n        candidates = [o for o in state.own_orders\n                      if o.side is self._post_side and o.order_id not in cancelled]\n        if not cancelled_all and candidates:\n            if self._post_side is Side.SELL:\n                order = min(candidates, key=lambda o: (o.price_ticks, o.submitted_step))\n                price = order.price_ticks - 1\n            else:\n                order = max(candidates, key=lambda o: (o.price_ticks, -o.submitted_step))\n                price = order.price_ticks + 1\n            # Moving inward raises collateral.  Skip when the callback's\n            # currently free cash cannot cover the worst-case increment;\n            # cancellation itself releases the old order's reservation.\n            delta = abs(price - order.price_ticks) * order.remaining_quantity / 100.0\n            incumbent_reserve = sum(\n                (a.price_ticks if a.side is Side.BUY else 100 - a.price_ticks)\n                * max(0.0, float(a.quantity)) / 100.0\n                for a in actions if isinstance(a, PlaceOrder)\n            )\n            if (1 <= price <= 99 and order.remaining_quantity > 0.0\n                    and state.free_cash + 1e-9 >= delta + incumbent_reserve + 500.0):\n                actions.append(CancelOrder(order.order_id))\n                actions.append(PlaceOrder(self._post_side, price, order.remaining_quantity))\n        self._post_left -= 1\n        if self._post_left <= 0:\n            self._post_side = None\n        return actions\n","code_sha256":"224272791f9eab883fb38491d962ee9b34e0c287c6f57c136c9bf4e9996c7b18","assembled_sha256":"1556a07dae2a79038d844f36e6425b037e7942dbb23929aea7ef84f9ba707cf1","tuning":{"seeds":"320000-320199","selected":"one_callback","variants":{"one_callback":{"mean_diff":-64.2338984686665,"se":7.979057702600135},"two_callbacks":{"mean_diff":-67.9950706532225,"se":8.4173306532225}}},"paired":{"seeds":"430000-430499","n":500,"complete":true,"missing_seeds":[],"overall":{"n":500,"sum_d":-9583.9758835198,"sum_d2":483145.41763593024,"mean_diff":-19.1679517670396,"se":1.0955187096270393,"incumbent_mean":95.54201511346659,"candidate_mean":76.37406334642701,"retail_diff":-7.1281592681174,"arb_diff":-12.0397924989072},"by_spread":{"1":{"n":131,"sum_d":-1582.0086144658999,"sum_d2":89881.04139078992,"mean_diff":-12.076401637144274,"se":2.038618203352837,"incumbent_mean":38.277936657049615,"candidate_mean":26.201535019905343,"retail_diff":-4.901290724812988,"arb_diff":-7.175110912299232},"2":{"n":120,"sum_d":-3139.4384690082,"sum_d2":132034.12447142552,"mean_diff":-26.161987241735,"se":1.8693341153858618,"incumbent_mean":77.8558643979175,"candidate_mean":51.693877156182495,"retail_diff":-9.912181140960001,"arb_diff":-16.2498061007325},"3":{"n":133,"sum_d":-2336.4857082142003,"sum_d2":83120.38330658896,"mean_diff":-17.567561715896243,"se":1.548083035949384,"incumbent_mean":146.55140363646615,"candidate_mean":128.98384192056992,"retail_diff":-10.193913625375188,"arb_diff":-7.373648090530082},"4":{"n":116,"sum_d":-2526.0430918315,"sum_d2":178109.8684671258,"mean_diff":-21.776233550271552,"se":3.0377702820421177,"incumbent_mean":120.02204692465259,"candidate_mean":98.24581337438104,"retail_diff":-3.247916379466375,"arb_diff":-18.528317170810354}}},"failures":{"incumbent":0,"candidate":0,"tuning_candidate_one":11,"tuning_candidate_two":14},"check_values":{"310000":2.527686,"310001":-0.886344,"310002":-3.668959,"310003":234.126546},"python_version":"3.12.3","seconds_per_simulation":0.5}