{
  "key": "f-rival-inward-join",
  "mech": "rival inward join",
  "approach": "Blind overlay on N. On a higher rival bid or lower rival ask than the preceding callback, append a join at the new tick, sized at 0.5 times the smallest quantized PlaceOrder N emits on that side, rounded down to 0.01. Act only on spreads [2, 3, 4]. Skip first/missing quotes, absent N orders, or insufficient conservatively projected collateral. Keep N's actions; N continues managing resting orders. Freeze after tuning; screen only.",
  "tried": [
    "full_all: full smallest N order size; competitor spreads 1, 2, 3, 4.",
    "half_all: half smallest N order size; competitor spreads 1, 2, 3, 4.",
    "half_wide: half smallest N order size; competitor spreads 2, 3, 4, excluding the narrowest spread.",
    "All three variants and the tuning selection rule were fixed before tuning; no changes after holdout began.",
    "13 local synthetic mechanism/collateral tests passed. All three disabled variants matched every N action on all 10 check seeds, 2000 steps per seed.",
    "Pinned simulator b244530ee2a6247b5f930830eeca9dd950da0e7e remained byte-for-byte unchanged. Default ChallengeConfig and ParameterVariance; 2000 steps; serial SimulationEngine runs, no workers or sandbox.",
    "Each seed/strategy pair ran once: 40 check/disabled simulations, 800 tuning simulations, and 1000 holdout simulations. Timing is mean wall seconds over the 1800 tuning/holdout simulations.",
    "Incumbent JSON was accessed only programmatically to extract and hash its code. Its source, other strategies, leaderboards, and previous results were not inspected.",
    "Enabled selected-variant action audit on holdout: 999945 of 1000000 callbacks returned exactly the same ordered actions as N.",
    "On acted-spread holdout callbacks, 87829 inward sides had N PlaceOrders; 87824 of their minimum sizes became zero when halved and quantized. Minimum-size counts: {'0.01': 87824, '116.08': 1, '152.33': 1, '19.79': 1, '78.34': 1, '3000.0': 1}. This audit only observed actions during the required runs; it did not rerun any simulation."
  ],
  "next": "Retain N. The frozen half-size variant produced exactly zero total, retail, and arbitrage edge differences on every holdout seed. Rounding suppressed 87824 of 87829 audited inward opportunities on acted spreads; rare action changes had no observed score effect. Full size lost 2.816665 edge (SE 0.320571) on tuning and was not run on holdout. No promotion; finalist seeds were untouched.",
  "spreads_acted": [
    2,
    3,
    4
  ],
  "off_equals_n": {
    "passed": true,
    "seeds": {
      "start": 310000,
      "end": 310009,
      "inclusive": true
    },
    "variant": "half_wide",
    "switch": "_ri_enabled = False",
    "steps_per_seed": 2000,
    "compared_steps": 20000,
    "mismatching_steps": 0,
    "method": "Compare every returned action, in order and with every dataclass field, against the corresponding N action at every step in independently executed simulations.",
    "all_tested_variants_passed": true
  },
  "code": "from orderbook_pm_challenge.types import (\n    CancelAll as _RICancelAll,\n    CancelOrder as _RICancelOrder,\n    PlaceOrder as _RIPlaceOrder,\n    Side as _RISide,\n)\nfrom orderbook_pm_challenge.utils import quantize_down as _ri_quantize_down\n\n\nclass Strategy(_N):\n    \"\"\"Join a rival quote only on the callback where that side moves inward.\"\"\"\n\n    _ri_enabled = True\n    _ri_size = 0.5\n    _ri_spreads = (2, 3, 4)\n\n    def on_step(self, state):\n        actions = super().on_step(state)\n        if not self._ri_enabled:\n            return actions\n\n        quotes = (state.competitor_best_bid_ticks,\n                  state.competitor_best_ask_ticks)\n        previous = getattr(self, '_ri_previous_quotes', None)\n        self._ri_previous_quotes = quotes\n        if previous is None or self.s not in self._ri_spreads:\n            return actions\n\n        inward = (\n            quotes[0] is not None and previous[0] is not None\n            and quotes[0] > previous[0],\n            quotes[1] is not None and previous[1] is not None\n            and quotes[1] < previous[1],\n        )\n        if not any(inward):\n            return actions\n\n        actions = list(actions)\n        additions = []\n        for index, side in enumerate((_RISide.BUY, _RISide.SELL)):\n            sizes = [_ri_quantize_down(a.quantity, 0.01) for a in actions\n                     if isinstance(a, _RIPlaceOrder) and a.side == side]\n            if inward[index] and sizes:\n                quantity = _ri_quantize_down(min(sizes) * self._ri_size, 0.01)\n                if quantity > 0.0:\n                    additions.append((side, quotes[index], quantity))\n        if not additions:\n            return actions\n\n        # StepState does not expose each order's reserved YES. Upper-bound\n        # existing collateral and YES use, then replay N's action sequence.\n        # This may skip affordable joins but cannot spend N's collateral.\n        projected = {}\n        for order in state.own_orders:\n            price = order.price_ticks / 100.0\n            cash = order.remaining_quantity * (\n                price if order.side == _RISide.BUY else 1.0 - price\n            )\n            projected[order.order_id] = (\n                order.side, order.remaining_quantity, cash\n            )\n        for index, action in enumerate(actions):\n            if isinstance(action, _RICancelAll):\n                projected.clear()\n            elif isinstance(action, _RICancelOrder):\n                projected.pop(action.order_id, None)\n            elif isinstance(action, _RIPlaceOrder):\n                quantity = _ri_quantize_down(action.quantity, 0.01)\n                price = action.price_ticks / 100.0\n                if action.side == _RISide.BUY:\n                    cash = price * quantity\n                else:\n                    available_yes = max(0.0, state.yes_inventory - sum(\n                        q for side, q, _ in projected.values()\n                        if side == _RISide.SELL\n                    ))\n                    cash = (1.0 - price) * max(0.0, quantity - available_yes)\n                key = action.client_order_id or ('ri-new', index)\n                projected[key] = (action.side, quantity, cash)\n\n        free_cash = state.cash - sum(c for _, _, c in projected.values())\n        available_yes = max(0.0, state.yes_inventory - sum(\n            q for side, q, _ in projected.values() if side == _RISide.SELL\n        ))\n        for side, tick, quantity in additions:\n            price = tick / 100.0\n            covered = min(quantity, available_yes) if side == _RISide.SELL else 0.0\n            cash = (price * quantity if side == _RISide.BUY else\n                    (1.0 - price) * (quantity - covered))\n            if cash + 1e-7 <= free_cash:\n                actions.append(_RIPlaceOrder(side, tick, quantity))\n                free_cash -= cash\n                available_yes -= covered\n        return actions\n",
  "code_sha256": "86893787265873fb1d77a7caa6b41e2943c3bd44232bb243875635b7bfc325e2",
  "assembled_sha256": "937f39152473e966b0459d6755cf58e15ce0bd100a1cef2f55b5d8b526aa7cd4",
  "tuning": {
    "seeds": {
      "start": 320000,
      "end": 320199,
      "inclusive": true
    },
    "incumbent": "N",
    "incumbent_code_sha256": "bf0d179f3e47d28819f6fa7e0d25548c2ced43374c216d36460b00a26a26ffae",
    "selected": "half_wide",
    "selection_rule": "Largest paired mean total-edge difference over all 200 tuning seeds; tie prefers half_wide, half_all, full_all.",
    "frozen_at": "2026-11-06T22:10:31.087933+00:00",
    "variants": {
      "full_all": {
        "size_scale": 1.0,
        "spreads_acted": [
          1,
          2,
          3,
          4
        ],
        "code_sha256": "c144bcec55a846b4b84ae162245dbc4c81ef680d0e51e6b23a044ffbc32a241d",
        "assembled_sha256": "985e1ee28435e31736cd1b12f8f1a126f35db3bd24fe8e576c9969c95578d40b",
        "n": 200,
        "complete": true,
        "missing_seeds": [],
        "overall": {
          "n": 200,
          "sum_d": -563.3330546658,
          "sum_d2": 5676.792273307595,
          "mean_diff": -2.816665273329,
          "se": 0.32057077005847184,
          "incumbent_mean": 98.47071831456549,
          "candidate_mean": 95.6540530412365,
          "retail_diff": -0.0016128962804993457,
          "arb_diff": -2.8150523770605003
        },
        "by_spread": {
          "1": {
            "n": 50,
            "sum_d": -44.526658735000055,
            "sum_d2": 122.17587456138907,
            "mean_diff": -0.8905331747000012,
            "se": 0.1835293534875596,
            "incumbent_mean": 25.711261479664,
            "candidate_mean": 24.820728304964,
            "retail_diff": 0.02992115755999898,
            "arb_diff": -0.9204543323100002
          },
          "2": {
            "n": 50,
            "sum_d": -159.9388974679,
            "sum_d2": 954.1535348183132,
            "mean_diff": -3.198777949358,
            "se": 0.4250063703500314,
            "incumbent_mean": 61.219908510538,
            "candidate_mean": 58.02113056118,
            "retail_diff": -0.08615392135200008,
            "arb_diff": -3.1126240280179998
          },
          "3": {
            "n": 48,
            "sum_d": -220.1129267765,
            "sum_d2": 2305.5489571122193,
            "mean_diff": -4.585685974510416,
            "se": 0.7579894189321603,
            "incumbent_mean": 130.8342429047854,
            "candidate_mean": 126.248556930275,
            "retail_diff": -0.4117267612354141,
            "arb_diff": -4.17395921326875
          },
          "4": {
            "n": 52,
            "sum_d": -138.75457168639997,
            "sum_d2": 2294.9139068156733,
            "mean_diff": -2.6683571478153842,
            "se": 0.8519047847716431,
            "incumbent_mean": 174.37579815333268,
            "candidate_mean": 171.7074410055173,
            "retail_diff": 0.4279219898615396,
            "arb_diff": -3.096279137669232
          }
        }
      },
      "half_all": {
        "size_scale": 0.5,
        "spreads_acted": [
          1,
          2,
          3,
          4
        ],
        "code_sha256": "cccc52661c5a3e949e46220824b0b2561e9345a9fcf8c8d5db78e94fe8ff300a",
        "assembled_sha256": "386a8cc52cba737ef465e987edcf5a3eddd93601e681ab59671394124b5185e3",
        "n": 200,
        "complete": true,
        "missing_seeds": [],
        "overall": {
          "n": 200,
          "sum_d": 0.0,
          "sum_d2": 0.0,
          "mean_diff": 0.0,
          "se": 0.0,
          "incumbent_mean": 98.47071831456549,
          "candidate_mean": 98.47071831456549,
          "retail_diff": 0.0,
          "arb_diff": 0.0
        },
        "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": 0.0,
            "sum_d2": 0.0,
            "mean_diff": 0.0,
            "se": 0.0,
            "incumbent_mean": 61.219908510538,
            "candidate_mean": 61.219908510538,
            "retail_diff": 0.0,
            "arb_diff": 0.0
          },
          "3": {
            "n": 48,
            "sum_d": 0.0,
            "sum_d2": 0.0,
            "mean_diff": 0.0,
            "se": 0.0,
            "incumbent_mean": 130.8342429047854,
            "candidate_mean": 130.8342429047854,
            "retail_diff": 0.0,
            "arb_diff": 0.0
          },
          "4": {
            "n": 52,
            "sum_d": 0.0,
            "sum_d2": 0.0,
            "mean_diff": 0.0,
            "se": 0.0,
            "incumbent_mean": 174.37579815333268,
            "candidate_mean": 174.37579815333268,
            "retail_diff": 0.0,
            "arb_diff": 0.0
          }
        }
      },
      "half_wide": {
        "size_scale": 0.5,
        "spreads_acted": [
          2,
          3,
          4
        ],
        "code_sha256": "86893787265873fb1d77a7caa6b41e2943c3bd44232bb243875635b7bfc325e2",
        "assembled_sha256": "937f39152473e966b0459d6755cf58e15ce0bd100a1cef2f55b5d8b526aa7cd4",
        "n": 200,
        "complete": true,
        "missing_seeds": [],
        "overall": {
          "n": 200,
          "sum_d": 0.0,
          "sum_d2": 0.0,
          "mean_diff": 0.0,
          "se": 0.0,
          "incumbent_mean": 98.47071831456549,
          "candidate_mean": 98.47071831456549,
          "retail_diff": 0.0,
          "arb_diff": 0.0
        },
        "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": 0.0,
            "sum_d2": 0.0,
            "mean_diff": 0.0,
            "se": 0.0,
            "incumbent_mean": 61.219908510538,
            "candidate_mean": 61.219908510538,
            "retail_diff": 0.0,
            "arb_diff": 0.0
          },
          "3": {
            "n": 48,
            "sum_d": 0.0,
            "sum_d2": 0.0,
            "mean_diff": 0.0,
            "se": 0.0,
            "incumbent_mean": 130.8342429047854,
            "candidate_mean": 130.8342429047854,
            "retail_diff": 0.0,
            "arb_diff": 0.0
          },
          "4": {
            "n": 52,
            "sum_d": 0.0,
            "sum_d2": 0.0,
            "mean_diff": 0.0,
            "se": 0.0,
            "incumbent_mean": 174.37579815333268,
            "candidate_mean": 174.37579815333268,
            "retail_diff": 0.0,
            "arb_diff": 0.0
          }
        }
      }
    }
  },
  "paired": {
    "seeds": {
      "start": 430000,
      "end": 430499,
      "inclusive": true
    },
    "n": 500,
    "complete": true,
    "missing_seeds": [],
    "overall": {
      "n": 500,
      "sum_d": 0.0,
      "sum_d2": 0.0,
      "mean_diff": 0.0,
      "se": 0.0,
      "incumbent_mean": 95.54201511346659,
      "candidate_mean": 95.54201511346659,
      "retail_diff": 0.0,
      "arb_diff": 0.0
    },
    "by_spread": {
      "1": {
        "n": 131,
        "sum_d": 0.0,
        "sum_d2": 0.0,
        "mean_diff": 0.0,
        "se": 0.0,
        "incumbent_mean": 38.277936657049615,
        "candidate_mean": 38.277936657049615,
        "retail_diff": 0.0,
        "arb_diff": 0.0
      },
      "2": {
        "n": 120,
        "sum_d": 0.0,
        "sum_d2": 0.0,
        "mean_diff": 0.0,
        "se": 0.0,
        "incumbent_mean": 77.8558643979175,
        "candidate_mean": 77.8558643979175,
        "retail_diff": 0.0,
        "arb_diff": 0.0
      },
      "3": {
        "n": 133,
        "sum_d": 0.0,
        "sum_d2": 0.0,
        "mean_diff": 0.0,
        "se": 0.0,
        "incumbent_mean": 146.55140363646615,
        "candidate_mean": 146.55140363646615,
        "retail_diff": 0.0,
        "arb_diff": 0.0
      },
      "4": {
        "n": 116,
        "sum_d": 0.0,
        "sum_d2": 0.0,
        "mean_diff": 0.0,
        "se": 0.0,
        "incumbent_mean": 120.02204692465259,
        "candidate_mean": 120.02204692465259,
        "retail_diff": 0.0,
        "arb_diff": 0.0
      }
    }
  },
  "failures": [],
  "check_values": {
    "310000": 17.1160017503,
    "310001": 20.0171113118,
    "310002": 2.3903113616,
    "310003": 241.4847522404
  },
  "python_version": "3.13.5",
  "seconds_per_simulation": 0.6142535263500435
}
