{"key":"f-quote-age","approach":"For spreads 1\u20134, track each step\u2019s competitor quote and cancel an N order when the relevant best quote has moved closer to its price by at least an age-dependent threshold: 3 ticks through age 99, 2 through age 199, then 1 tick.","tried":"Tuned two age schedules on seeds 310000\u2013310199. Selected the gentler schedule (mean difference -0.031632995868, SE 0.106988545407; 0 failures); the alternative threshold max(1, 2 - age//60) scored -0.354510292818 (SE 0.374947497748; 0 failures). Applied to all four spreads.","next":"If continuing, test a smaller spread subset only with a new tuning/holdout split; this overlay\u2019s measured tuning effect is near zero.","spreads_acted":[1,2,3,4],"off_equals_n":true,"code":"from orderbook_pm_challenge.strategy import BaseStrategy\nfrom orderbook_pm_challenge.types import CancelOrder, CancelAll, Side\n\nclass Strategy(BaseStrategy):\n    def __init__(self):\n        self.n = _N()\n        self.spread = None\n        self.history = {}\n\n    def on_step(self, state):\n        cb = state.competitor_best_bid_ticks\n        ca = state.competitor_best_ask_ticks\n        if self.spread is None:\n            self.spread = max(1, ((ca or 100) - (cb or 0) + 1) // 2)\n        self.history[state.step] = (cb, ca)\n        actions = list(self.n.on_step(state))\n        if self.spread not in (1, 2, 3, 4):\n            return actions\n        canceled = {a.order_id for a in actions if isinstance(a, CancelOrder)}\n        cancel_all = any(isinstance(a, CancelAll) for a in actions)\n        for order in state.own_orders:\n            base = self.history.get(order.submitted_step)\n            if base is None:\n                continue\n            age = max(0, state.step - order.submitted_step)\n            if order.side is Side.BUY and cb is not None and base[0] is not None:\n                drift = abs(base[0] - order.price_ticks) - abs(cb - order.price_ticks)\n            elif order.side is Side.SELL and ca is not None and base[1] is not None:\n                drift = abs(base[1] - order.price_ticks) - abs(ca - order.price_ticks)\n            else:\n                continue\n            limit = max(1, 3 - age // 100)\n            if drift >= limit and not cancel_all and order.order_id not in canceled:\n                actions.append(CancelOrder(order.order_id))\n        return actions\n","code_sha256":"35cb7a9112227f249caa8f5b4e6101e4362421c9ff685a620e60ab8f62795e9d","assembled_sha256":"cbeaebbee7e0357ddece0f85fa65ab890082e72d6c36cbd7a5e1c2521de3fc3a","tuning":{"n":200,"mean_diff":-0.03163299586800074,"se":0.1069885454072102},"paired":{"incumbent_mean":104.4137531881468,"mean_diff":0.11318337429079979,"se":0.16642112417107266,"sum_d":56.591687145399895,"sum_d2":6916.55488541364,"retail_diff":0.09398898731520024,"arb_diff":0.019194386980400005,"first_seed":410000,"last_seed":410499,"n":500,"complete":true,"failures":0},"by_spread":{"1":{"runs":115,"incumbent_mean":28.495154459731303,"mean_diff":-0.2541400437878268,"se":0.1390246458974571,"sum_d":-29.22610503560008,"sum_d2":260.8156655217288,"retail_diff":-0.19561658228260814,"arb_diff":-0.058523461486087},"2":{"runs":116,"incumbent_mean":97.76626247947759,"mean_diff":0.06250483192241374,"se":0.11832119145960329,"sum_d":7.250560502999994,"sum_d2":187.21191907350737,"retail_diff":-0.061351642995689765,"arb_diff":0.12385647491896558},"3":{"runs":138,"incumbent_mean":128.4054514027384,"mean_diff":-0.06119003765217422,"se":0.03675006345750325,"sum_d":-8.444225196000042,"sum_d2":26.050525262738212,"retail_diff":-0.05227187954347845,"arb_diff":-0.008918158106521737},"4":{"runs":131,"incumbent_mean":151.67248160310686,"mean_diff":0.6642095944580154,"se":0.6122972985893271,"sum_d":87.01145687400003,"sum_d2":6442.476775555665,"retail_diff":0.6398527525541992,"arb_diff":0.024356841902290077}},"seconds_per_simulation":0.9881571235656739}
