# Merge 01, batch r2-fresh-b: ten fresh-mechanism items Inputs: the ten item results under `.imd/reads/artifacts/` (item-f-particle-filter, item-f-jump-param-online, item-f-competitor-replay, item-f-censored-nofill, item-f-info-probes, item-f-kalman-mid, item-f-spread-regime-online, item-f-cusum-jump, item-f-transition-table, item-f-arrival-rate-online). All ten exist and parse; none is missing or empty. All values below are copied from each item's `paired`, `approach`, `code_sha256`, `graft` and `next` fields. Nothing was re-run. How the merge was made: - `key` is the file name without `item-`, because only one result (arrival-rate-online) has its own `item` field. The rest have no key field. - `h_seeds`, `h_n`, `h_complete`, `b_mean`, `failures` and the diffs come from each result's `paired` object. `mechanism` is `approach` cut to 200 characters, and `next` is cut to 300. - Flag rules: n under 500, no code_sha256, any failures, or a b_mean different from the full rows' b_mean. All eight full 1000-seed rows (seeds 200000..200999) have b_mean 99.6959. Each `code_sha256` was also checked against the SHA-256 of the item's `code`, and all ten match. - Two rows are flagged: particle-filter (n 250, b_mean 85.11) and transition-table (n 150, b_mean 81.97). They are ranked but left out of `top`. - Rows are ranked by mechanism_diff, highest first. **Top (unflagged):** 1. **f-competitor-replay**: +27.12 (se 2.55) 2. **f-censored-nofill**: +22.17 (se 0.95) Both rows measure S1 against their own blind S0. Their standalone means are deeply negative (S1 -18.01 and -27.99, against B 99.70), so neither is a candidate to beat the current best as it stands. The censored-nofill result says its gain was on "the paired finalist score". Its seeds are 200000..200999, which are not the reserved finalist range 900000..903999. ## Ranked rows | # | key | mechanism_diff | se | retail_diff | arb_diff | reference_diff (se) | h_seeds | h_n | b_mean | flag | |---|---|---|---|---|---|---|---|---|---|---| | 1 | f-particle-filter | 34.06 | 4.87 | 22.8 | 11.26 | -68.02 (10.96) | "200000..200249 (250 of the 1000 requested; timing forced fewer, see seconds_per_simulation)" | 250 | 85.11 | n 250 under 500; b_mean 85.11 unequal to full rows' 99.6959 (partial holdout) | | 2 | f-competitor-replay | 27.1178261652066 | 2.5453271494017837 | -0.9973068428755002 | 28.1151330080911 | -117.7052176333529 (5.575313557927414) | [200000, 200999] | 1000 | 99.6958781523823 | | | 3 | f-censored-nofill | 22.166409933415736 | 0.9524552643600743 | -3.1556162885368026 | 25.322026221951184 | -127.68320512507285 (6.049782212564964) | "200000..200999" | 1000 | 99.69587815238216 | | | 4 | f-transition-table | 3.34350181598 | 0.502410333312321 | -1.2498001419933333 | 4.593301957973333 | -81.95250214139733 (14.41658676081984) | "200000..200149 (NOT the full 200000..200999: time ran out; 150 of 1000)" | 150 | 81.97175077223866 | n 150 under 500; b_mean 81.97175077223866 unequal to full rows' 99.6959 (partial holdout) | | 5 | f-arrival-rate-online | 1.3642 | 0.1472 | -1.2982 | 2.6624 | -93.6334 (5.5555) | "200000..200999" | 1000 | 99.6959 | | | 6 | f-spread-regime-online | 1.1039374189222 | 0.05246263457687871 | 1.0534200932704 | 0.050517325651800005 | -97.0690879291963 (5.687398517915508) | "200000..200999" | 1000 | 99.6958781523823 | | | 7 | f-cusum-jump | 0.9645 | 0.0805 | -0.0299 | 0.9945 | -99.4171 (5.6445) | "200000..200999" | 1000 | 99.6959 | | | 8 | f-jump-param-online | 0.26 | 0.0351 | -0.7705 | 1.0305 | -73.9135 (4.9088) | "200000..200999" | 1000 | 99.6959 | | | 9 | f-info-probes | -0.07858056646149998 | 0.0054625971273622115 | 0.000890145338 | -0.07947071179659995 | -111.2198878380359 (5.689324710489984) | [200000, 200999] | 1000 | 99.6958781523823 | | | 10 | f-kalman-mid | -1.010803627898 | 0.07644068338607703 | -0.3629052186138 | -0.6478984092818999 | -103.411138712604 (5.446887919168018) | "200000..200999" | 1000 | 99.69587815238229 | | ## Notes Reduced arbitrage loss (mechanism_arb_diff > 0): competitor-replay +28.12 and censored-nofill +25.32 (both almost all arb, retail slightly negative); arrival-rate-online +2.66, but its own note says most of that is a retuned arb_cost and the estimator alone gives arb +0.32 (diff +0.16, se 0.09); jump-param-online +1.03 and cusum-jump +0.99 (small, many SE). Flagged rows also cut arb: particle-filter +11.26, transition-table +4.59. Raised retail edge: spread-regime-online +1.05 (arb about 0), and the flagged particle-filter +22.8 (n 250). Hurt: kalman-mid (retail -0.36, arb -0.65); info-probes about 0 retail, arb -0.08. Caveats: every diff is S1 against the item's own blind S0, not against the current best, and every S1 sits 68 to 128 below reference B (reference_diff). The two top rows have the weakest S0s (-45.13, -50.15), so their large diffs partly measure repairing a weak baseline; they are graft candidates, not promotions. No row used finalist seeds 900000..903999. Results of jump-param-online (1 source), info-probes (2) and kalman-mid (2) cite sources that did not hold on re-read; their JSON lists no sources, so which claims rest on them cannot be told; their numbers are self-measured and none is in top. ## Top two: full code Each block below is copied unchanged from the item's `code` field. Its SHA-256 matches the stated `code_sha256`. ### f-competitor-replay (code_sha256 `835dba46a877aacea78aeb5aa3d5f7d094147c0984b3b573aab3a7f5c72e4259`) ~~~~python import math from orderbook_pm_challenge.types import CancelAll, PlaceOrder, Side class Strategy: SIZE = 12 RISK = 1 def __init__(self): self.previous = None self.mean = 50.0 self.variance = 4.0 self.spread = 2 def estimate(self, state, bid, ask): # At initialization the 2*s-1 tick gap identifies the ladder offset. if self.previous is None: self.spread = max(1, min(4, (ask-bid+1)//2)) self.mean = (bid+ask)*0.5 self.variance = max(0.1, (ask-bid)**2/12.0) lo, hi = float(bid), float(ask) if self.previous is not None: old_bid, old_ask = self.previous # A swept ask k is replayed as bid k-s; the first surviving ask # is k+1. The symmetric rule applies to a swept bid. up = ask > old_ask and bid >= ask-1-self.spread down = bid < old_bid and ask <= bid+1+self.spread if up and not down: lo = max(lo, ask-1.0) elif down and not up: hi = min(hi, bid+1.0) # Quote survival is also informative: predict then truncate. pp = min(0.999, max(0.001, self.mean/100.0)) diffusion = 0.7 * 140.0*pp*(1-pp)/math.sqrt(state.steps_remaining+10) variance = self.variance + max(0.08, diffusion)**2 sd = math.sqrt(variance) a, b = (lo-self.mean)/sd, (hi-self.mean)/sd mass = self.cdf(b)-self.cdf(a) if mass > 1e-8: pa = math.exp(-0.5*a*a)/math.sqrt(2*math.pi) pb = math.exp(-0.5*b*b)/math.sqrt(2*math.pi) shift = (pa-pb)/mass filtered = self.mean + sd*shift var = variance*(1+(a*pa-b*pb)/mass-shift*shift) # A small uniform contamination component allows jumps/retail sweeps. mix = 0.02 / (0.02 + 0.98*mass) self.mean = (1-mix)*filtered + mix*(lo+hi)*0.5 self.variance = max(0.02, (1-mix)*max(0.0,var)+mix*(hi-lo)**2/12) else: self.mean = (lo+hi)*0.5 self.variance = max(0.02, (hi-lo)**2/12) self.previous = (bid, ask) return self.mean @staticmethod def cdf(x): return 0.5 * (1.0 + math.erf(x / math.sqrt(2.0))) def on_step(self, state): bid = state.competitor_best_bid_ticks or 0 ask = state.competitor_best_ask_ticks or 100 p = self.estimate(state, bid, ask) / 100.0 p = min(0.9999, max(0.0001, p)) # Diffusion scale in ticks, larger near expiry and near probability 1/2. sd = max(0.12, 140.0 * p * (1.0-p) / math.sqrt(state.steps_remaining + 10)) actions = [CancelAll()] budget = max(0.0, state.cash) * 0.48 for side in (Side.BUY, Side.SELL): best = None # Only orders ahead of the competitor receive ordinary retail flow. ticks = range(max(1, bid), min(99, ask) + 1) for tick in ticks: x = tick / 100.0 distance = (p-x if side == Side.BUY else x-p) * 100.0 if distance < 0.0: continue if side == Side.BUY and tick < bid: continue if side == Side.SELL and tick > ask: continue flow = 0.12 if (side == Side.BUY and tick == bid) or (side == Side.SELL and tick == ask): flow *= 0.04 collateral = x if side == Side.BUY else 1.0-x q = min(self.SIZE / max(p, 0.05), budget / max(collateral, 0.01)) if side == Side.SELL: q = min(self.SIZE / max(p, 0.05), state.yes_inventory + budget / max(collateral, 0.01)) q = math.floor(max(0.0, q) * 100.0) / 100.0 if q < 0.01: continue # E[min(q, lognormal retail shares)], mean notional about $4.5. mu = math.log(4.5 / max(p, 0.05)) - 0.72 z = (math.log(q) - mu) / 1.2 volume = math.exp(mu+0.72)*self.cdf(z-1.2) + q*(1-self.cdf(z)) u = distance / sd adverse = sd * math.exp(-0.5*u*u) / math.sqrt(2*math.pi) - distance*self.cdf(-u) edge = flow*volume*distance - self.RISK*q*adverse if best is None or edge > best[0]: best = (edge, tick, q) if best is not None and best[0] > 0: actions.append(PlaceOrder(side, best[1], best[2])) return actions ~~~~ ### f-censored-nofill (code_sha256 `7f8b4120ccb6e9344d45f10dc0d93920d44c91d69b282b5399b30cf1e1dc332a`) ~~~~python from orderbook_pm_challenge.strategy import BaseStrategy from orderbook_pm_challenge.types import CancelAll, PlaceOrder, Side class Strategy(BaseStrategy): def __init__(self): self.strength, self.offset, self.qty = .10, 2, 4.0 self.refresh, self.decay = 6, .995 self.evidence, self.old = 0.0, {} def on_step(self, s): new = {o.order_id: o for o in s.own_orders} if self.old: for oid, o in new.items(): if oid in self.old and o.remaining_quantity >= self.old[oid].remaining_quantity - 1e-9: self.evidence += 1.0 if o.side == Side.BUY else -1.0 self.evidence *= self.decay bid = s.competitor_best_bid_ticks if s.competitor_best_bid_ticks is not None else 49 ask = s.competitor_best_ask_ticks if s.competitor_best_ask_ticks is not None else 51 mid = (bid + ask) / 2 + self.strength * self.evidence actions = [] if s.step % self.refresh == 0: actions = [CancelAll()] b = max(1, min(98, round(mid - self.offset))) a = max(2, min(99, round(mid + self.offset))) actions += [PlaceOrder(Side.BUY, b, self.qty), PlaceOrder(Side.SELL, a, self.qty)] self.old = new return actions ~~~~ ## Merged JSON object The same rows, top and notes as one JSON object (fields copied from each item's result; `top[].code` is each item's full `code`). ~~~~json { "rows": [ { "key": "f-particle-filter", "mechanism": "Particle filter (100 particles) over the latent score x. Each step: weight particles by exact hard/soft constraints on the true probability p=P(x,steps_left) (Poisson-mixture formula from the simulato", "code_sha256": "0b7a0692b324abb15f7fa1bd0bca909cd795c0e2af78e12e163f2aae2ea22ea0", "h_seeds": "200000..200249 (250 of the 1000 requested; timing forced fewer, see seconds_per_simulation)", "h_n": 250, "h_complete": false, "mechanism_diff": 34.06, "mechanism_se": 4.87, "mechanism_retail_diff": 22.8, "mechanism_arb_diff": 11.26, "reference_diff": -68.02, "reference_se": 10.96, "b_mean": 85.11, "failures": [], "graft": "Keep a cloud of score particles; each step weight them by P(x,steps_left) lying between competitor best bid and ask, and by survival of your own orders (surviving ask at k means p<=k/100); resample, reseed on the interval after jumps, propagate with diffusion plus jumps, and quote from the predictive p distribution.", "next": "Not competitive: S1 is 68 below reference B on seeds 200000..200249. Likely causes (not tested): fixed prior jump parameters mis-scale p dynamics; the predictive law ignores that the arbitrageur takes whole-size orders at any crossing so sizes are probably too large; retail rate/size fixed instead o", "flag": "n 250 under 500; b_mean 85.11 unequal to full rows' 99.6959 (partial holdout)" }, { "key": "f-competitor-replay", "mechanism": "Blind competitor-replacement replay. Read only pinned simulator/README/rules and fixture.H numbers. S0 estimates probability as the current competitor midpoint, evaluates normal adverse-selection cost", "code_sha256": "835dba46a877aacea78aeb5aa3d5f7d094147c0984b3b573aab3a7f5c72e4259", "h_seeds": [ 200000, 200999 ], "h_n": 1000, "h_complete": true, "mechanism_diff": 27.1178261652066, "mechanism_se": 2.5453271494017837, "mechanism_retail_diff": -0.9973068428755002, "mechanism_arb_diff": 28.1151330080911, "reference_diff": -117.7052176333529, "reference_se": 5.575313557927414, "b_mean": 99.6958781523823, "failures": [], "graft": "Replace only your probability estimator. Infer spread from the initial gap; an outward ask move implies the last consumed ask, replenished at k-spread on the bid; reverse for bids. Filter a diffusing belief through these crossing/survival intervals and use its fractional-tick posterior mean. Keep your existing risk, sizing, and cash controls; retail depletion can mimic crossings.", "next": "Graft the frozen replay estimator into a competitive quoting policy and measure it afresh on permitted independent seeds. Do not promote this standalone strategy: consult its negative or positive reference difference, not just the improvement over weak S0. Improve the observation likelihood to separ", "flag": null }, { "key": "f-censored-nofill", "mechanism": "Built a passive midpoint baseline and one censored-observation extension. S1 treats each unchanged resting bid with no fill as evidence against p below that bid, and each unchanged ask as evidence aga", "code_sha256": "7f8b4120ccb6e9344d45f10dc0d93920d44c91d69b282b5399b30cf1e1dc332a", "h_seeds": "200000..200999", "h_n": 1000, "h_complete": true, "mechanism_diff": 22.166409933415736, "mechanism_se": 0.9524552643600743, "mechanism_retail_diff": -3.1556162885368026, "mechanism_arb_diff": 25.322026221951184, "reference_diff": -127.68320512507285, "reference_se": 6.049782212564964, "b_mean": 99.69587815238216, "failures": [], "graft": "Keep a per-order snapshot keyed by order_id. On each callback, for every order still present at unchanged remaining quantity, add a small positive score for BUY or negative score for SELL, decay the score, and shift the quote midpoint by strength*score before placing passive orders.", "next": "The mechanism improved the paired finalist score, but its gain is below a 2-SE promotion threshold only if the network requires that threshold against the current best; test a smaller evidence gain or jointly tune quote offset in a fresh item.", "flag": null }, { "key": "f-transition-table", "mechanism": "Both strategies quote one tick inside the competitor's best bid/ask (the only way to get retail priority over the static ladder), around a probability estimate e tracked inside the competitor interval", "code_sha256": "f4a3432f5133a5c2bfa09fd96f4e0e1e618ee106eb6adafa6ec9431e1680b83e", "h_seeds": "200000..200149 (NOT the full 200000..200999: time ran out; 150 of 1000)", "h_n": 150, "h_complete": false, "mechanism_diff": 3.34350181598, "mechanism_se": 0.502410333312321, "mechanism_retail_diff": -1.2498001419933333, "mechanism_arb_diff": 4.593301957973333, "reference_diff": -81.95250214139733, "reference_se": 14.41658676081984, "b_mean": 81.97175077223866, "failures": [], "graft": "Add TABLE/LV/W and as_cost(): for a quote at tick k with estimate e, loss=E[(Δp-(k-e)/100)+] (asks; mirror for bids) from the quantile row for bucket int(e/5) and the steps-remaining bucket; choose size q maximising RB*(1-exp(-q/QS))*edge - q*loss. Only useful if e is accurate.", "next": "The estimator is the bottleneck: e from the competitor interval is off by several ticks, so arbitrage loss dominates any quoting. Fit the table on the posterior spread of e (not of true p), feed own fill side/size as a probability signal, and use per-regime (jump intensity, retail rate) inference be", "flag": "n 150 under 500; b_mean 81.97175077223866 unequal to full rows' 99.6959 (partial holdout)" }, { "key": "f-arrival-rate-online", "mechanism": "Blind build from the simulator only. S0: fair value tracked from hidden-competitor ladder sweeps (after an up-sweep p sits just under the new best ask, after a down-sweep just over the new best bid); ", "code_sha256": "1944aff8e9f20f37db2f2870eca053a8511db8596c45c022ad7035ca4ce6124b", "h_seeds": "200000..200999", "h_n": 1000, "h_complete": true, "mechanism_diff": 1.3642, "mechanism_se": 0.1472, "mechanism_retail_diff": -1.2982, "mechanism_arb_diff": 2.6624, "reference_diff": -93.6334, "reference_se": 5.5555, "b_mean": 99.6959, "failures": [], "graft": "Keep the last placed size and price per side. Each step, skip a side whose fill >= its size (could be arb); otherwise add a no-fill or partial-fill event (notional = fill*price) to a grid log-likelihood over (per-side rate r, log mean notional), using P(none)=e^-r/D and p(y)=(1-e^-r)f(y)/D with D=e^-r+(1-e^-r)F(size*price). Only valid when the quote is best on its side. Feed the argmax into the size rule.", "next": "Most of S1's holdout gain (+1.36) comes from the different arb_cost it was tuned to, not the estimator: S1 at S0's arb_cost 0.0008 on the same 1000 holdout seeds gives +0.16 +/- 0.09 (retail -0.16, arb +0.32), not significant. Retail rate/size knowledge is worth little to sizing in this baseline, wh", "flag": null }, { "key": "f-spread-regime-online", "mechanism": "S0 quotes one tick inside the hidden competitor around a probability estimate taken from which competitor side was last swept (ask-0.5 after an up-sweep, bid+0.5 after a down-sweep, else mid), with a ", "code_sha256": "acc7d6af0c1d2415d03bf89786468453177dadbad484905ae4d73dd10c624f33", "h_seeds": "200000..200999", "h_n": 1000, "h_complete": true, "mechanism_diff": 1.1039374189222, "mechanism_se": 0.05246263457687871, "mechanism_retail_diff": 1.0534200932704, "mechanism_arb_diff": 0.050517325651800005, "reference_diff": -97.0690879291963, "reference_se": 5.687398517915508, "b_mean": 99.6958781523823, "failures": [], "graft": "At step 0 compute spread=(competitor_best_ask_ticks-competitor_best_bid_ticks+1)//2 (initial ladder gap is 2*spread-1). Keep a per-spread table of constants (quote offset, size), e.g. stand aside or widen when spread<=2 and quote larger when spread=4, and look the constants up from it every step.", "next": "Note: S0 had 7 tuning variants, more than the brief's limit of 4. The baseline is weak (about 1.5 against B's about 100), so the mechanism's gain is small in absolute terms. The regime result still carries over: the spread is known exactly at step 0, and in spread 1-2 regimes S0's 1-tick-inside quot", "flag": null }, { "key": "f-cusum-jump", "mechanism": "Blind S0: fair = competitor ladder mid (arb keeps competitor bid<=p<=ask) minus inventory skew; 6-share bid/ask inside the competitor spread but at least EDGE ticks from fair. S1 adds a CUSUM on x_t=|", "code_sha256": "f6b217646905f5748af2875b01b00ac72b1ce5a76b3a29a13db057cf6a2981aa", "h_seeds": "200000..200999", "h_n": 1000, "h_complete": true, "mechanism_diff": 0.9645, "mechanism_se": 0.0805, "mechanism_retail_diff": -0.0299, "mechanism_arb_diff": 0.9945, "reference_diff": -99.4171, "reference_se": 5.6445, "b_mean": 99.6959, "failures": [], "graft": "Each on_step: mid=(comp_bid+comp_ask)/2; x=|mid-prev_mid|+|buy_filled-sell_filled|/size; S=max(0,S+x-1.0); if S>1.5: pull=8,S=0. While pull>0: decrement and return [CancelAll()] only (no new quotes). Keep prev_mid updated every step.", "next": "Mechanism gain is entirely arb-loss reduction (+0.99 arb, ~0 retail), paired SE 0.08, on a weak baseline (S0 ~-0.7 vs B ~99.7); graft onto the current best and measure paired on fresh seeds — gain may scale with quoted size. Try longer PULL (gain rose 3->8) and a one-sided pull in the jump direction", "flag": null }, { "key": "f-jump-param-online", "mechanism": "Own baseline S0 (143 lines): probability read from the competitor ladder (the arbitrageur leaves best ask >= p >= best bid, so the side that moved pins p within a tick; a fully filled own quote pushes", "code_sha256": "b1b93018ea12584b12f3d71ca1978e8376cd2f0b538b426c7b019403aa2a337d", "h_seeds": "200000..200999", "h_n": 1000, "h_complete": true, "mechanism_diff": 0.26, "mechanism_se": 0.0351, "mechanism_retail_diff": -0.7705, "mechanism_arb_diff": 1.0305, "reference_diff": -73.9135, "reference_se": 4.9088, "b_mean": 99.6959, "failures": [], "graft": "Keep the previous probability estimate p_prev. Each step: t+=1; J=(probit(p)-probit(p_prev))*sqrt(H*0.02^2+lam*H*sj^2); if |J|>0.08 (and 0.03
old_ask and bid >= ask-1-self.spread\n down = bid < old_bid and ask <= bid+1+self.spread\n if up and not down:\n lo = max(lo, ask-1.0)\n elif down and not up:\n hi = min(hi, bid+1.0)\n # Quote survival is also informative: predict then truncate.\n pp = min(0.999, max(0.001, self.mean/100.0))\n diffusion = 0.7 * 140.0*pp*(1-pp)/math.sqrt(state.steps_remaining+10)\n variance = self.variance + max(0.08, diffusion)**2\n sd = math.sqrt(variance)\n a, b = (lo-self.mean)/sd, (hi-self.mean)/sd\n mass = self.cdf(b)-self.cdf(a)\n if mass > 1e-8:\n pa = math.exp(-0.5*a*a)/math.sqrt(2*math.pi)\n pb = math.exp(-0.5*b*b)/math.sqrt(2*math.pi)\n shift = (pa-pb)/mass\n filtered = self.mean + sd*shift\n var = variance*(1+(a*pa-b*pb)/mass-shift*shift)\n # A small uniform contamination component allows jumps/retail sweeps.\n mix = 0.02 / (0.02 + 0.98*mass)\n self.mean = (1-mix)*filtered + mix*(lo+hi)*0.5\n self.variance = max(0.02, (1-mix)*max(0.0,var)+mix*(hi-lo)**2/12)\n else:\n self.mean = (lo+hi)*0.5\n self.variance = max(0.02, (hi-lo)**2/12)\n self.previous = (bid, ask)\n return self.mean\n\n @staticmethod\n def cdf(x):\n return 0.5 * (1.0 + math.erf(x / math.sqrt(2.0)))\n\n def on_step(self, state):\n bid = state.competitor_best_bid_ticks or 0\n ask = state.competitor_best_ask_ticks or 100\n p = self.estimate(state, bid, ask) / 100.0\n p = min(0.9999, max(0.0001, p))\n # Diffusion scale in ticks, larger near expiry and near probability 1/2.\n sd = max(0.12, 140.0 * p * (1.0-p) / math.sqrt(state.steps_remaining + 10))\n actions = [CancelAll()]\n budget = max(0.0, state.cash) * 0.48\n for side in (Side.BUY, Side.SELL):\n best = None\n # Only orders ahead of the competitor receive ordinary retail flow.\n ticks = range(max(1, bid), min(99, ask) + 1)\n for tick in ticks:\n x = tick / 100.0\n distance = (p-x if side == Side.BUY else x-p) * 100.0\n if distance < 0.0:\n continue\n if side == Side.BUY and tick < bid:\n continue\n if side == Side.SELL and tick > ask:\n continue\n flow = 0.12\n if (side == Side.BUY and tick == bid) or (side == Side.SELL and tick == ask):\n flow *= 0.04\n collateral = x if side == Side.BUY else 1.0-x\n q = min(self.SIZE / max(p, 0.05), budget / max(collateral, 0.01))\n if side == Side.SELL:\n q = min(self.SIZE / max(p, 0.05), state.yes_inventory + budget / max(collateral, 0.01))\n q = math.floor(max(0.0, q) * 100.0) / 100.0\n if q < 0.01:\n continue\n # E[min(q, lognormal retail shares)], mean notional about $4.5.\n mu = math.log(4.5 / max(p, 0.05)) - 0.72\n z = (math.log(q) - mu) / 1.2\n volume = math.exp(mu+0.72)*self.cdf(z-1.2) + q*(1-self.cdf(z))\n u = distance / sd\n adverse = sd * math.exp(-0.5*u*u) / math.sqrt(2*math.pi) - distance*self.cdf(-u)\n edge = flow*volume*distance - self.RISK*q*adverse\n if best is None or edge > best[0]:\n best = (edge, tick, q)\n if best is not None and best[0] > 0:\n actions.append(PlaceOrder(side, best[1], best[2]))\n return actions\n" }, { "key": "f-censored-nofill", "code_sha256": "7f8b4120ccb6e9344d45f10dc0d93920d44c91d69b282b5399b30cf1e1dc332a", "mechanism_diff": 22.166409933415736, "code": "from orderbook_pm_challenge.strategy import BaseStrategy\nfrom orderbook_pm_challenge.types import CancelAll, PlaceOrder, Side\n\nclass Strategy(BaseStrategy):\n def __init__(self):\n self.strength, self.offset, self.qty = .10, 2, 4.0\n self.refresh, self.decay = 6, .995\n self.evidence, self.old = 0.0, {}\n def on_step(self, s):\n new = {o.order_id: o for o in s.own_orders}\n if self.old:\n for oid, o in new.items():\n if oid in self.old and o.remaining_quantity >= self.old[oid].remaining_quantity - 1e-9:\n self.evidence += 1.0 if o.side == Side.BUY else -1.0\n self.evidence *= self.decay\n bid = s.competitor_best_bid_ticks if s.competitor_best_bid_ticks is not None else 49\n ask = s.competitor_best_ask_ticks if s.competitor_best_ask_ticks is not None else 51\n mid = (bid + ask) / 2 + self.strength * self.evidence\n actions = []\n if s.step % self.refresh == 0:\n actions = [CancelAll()]\n b = max(1, min(98, round(mid - self.offset)))\n a = max(2, min(99, round(mid + self.offset)))\n actions += [PlaceOrder(Side.BUY, b, self.qty), PlaceOrder(Side.SELL, a, self.qty)]\n self.old = new\n return actions\n" } ], "notes": "Reduced arbitrage loss (mechanism_arb_diff > 0): competitor-replay +28.12 and censored-nofill +25.32 (both almost all arb, retail slightly negative); arrival-rate-online +2.66, but its own note says most of that is a retuned arb_cost and the estimator alone gives arb +0.32 (diff +0.16, se 0.09); jump-param-online +1.03 and cusum-jump +0.99 (small, many SE). Flagged rows also cut arb: particle-filter +11.26, transition-table +4.59. Raised retail edge: spread-regime-online +1.05 (arb about 0), and the flagged particle-filter +22.8 (n 250). Hurt: kalman-mid (retail -0.36, arb -0.65); info-probes about 0 retail, arb -0.08. Caveats: every diff is S1 against the item's own blind S0, not against the current best, and every S1 sits 68 to 128 below reference B (reference_diff). The two top rows have the weakest S0s (-45.13, -50.15), so their large diffs partly measure repairing a weak baseline; they are graft candidates, not promotions. No row used finalist seeds 900000..903999. Results of jump-param-online (1 source), info-probes (2) and kalman-mid (2) cite sources that did not hold on re-read; their JSON lists no sources, so which claims rest on them cannot be told; their numbers are self-measured and none is in top." } ~~~~