{"approach": "Ported the demand file's per-run compound-Poisson posterior over retail BUY flow (fills of surviving front asks, and bids while an own ask at tick<=5 survives) onto the base, active only if self.s == 4; the base has no spread-4 rule of its own. Only one use of it is kept: once the posterior has at least 64 observations and fitted flow (rate times mean notional) is under 0.45 dollars a step, each ordinary quote is capped at the size the base's own rule gives with the run's fitted rate and mean size in place of the priors. All other sizes stay the base's. Why: in thin-retail runs the priors overstate demand, so quotes are too big and the arbitrageur takes the surplus. The other parts of the mechanism did not hold up on spread 4: stock sizing lost and whole-posterior sizing failed on the unused half. The trade is less arbitrage loss for some retail edge (see diff), the same direction the demand file took. Behaviour-preserving speedups (posterior arithmetic deferred to its 16-step refresh, reused immutable probe orders, list sums, inlined cdf) offset the estimator's cost; they apply to all spreads and results stay identical. The 0.45 threshold was set by hand near the lowest flow quartile boundary seen on tuning part A (0.42) and checked on part B. Method notes: per-seed runs use the simulator's _run_single_simulation (what run_batch's workers call) with its two linear scans (_best_order, competitor_best_quotes) replaced by equivalent loops to save time; on 8 seeds that were run on both, the results were exactly equal to the unpatched engine, and the timing used the unpatched engine. This machine gave about 3 runs a second, so tuning used only the first 300 of each half of the 2043 spread-4 tuning seeds (A = even positions, B = odd positions), and unseen scoring is on the full spread-4 set. SCORER CHECK INCOMPLETE: the 4000-run command needs far more than this machine allowed. Two attempts (4000 runs, then 2000 runs) hit the 10-minute command limit with no output, and the machine gave about 3 runs a second, so the required unseen and identity runs took priority. base_mean_edge is therefore the CLI's mean over only 200 runs from seed 4000, not 4000 runs, and must NOT be compared with the author's 98.4694596619638: the author's figure was not reproduced. TIMING: over 200 spread-4 unseen runs in one process, alternating, with the unpatched engine, this file took 145.2658611133229 s against the base's 144.19885997008532 s, 0.74% slower, so on spread-4 runs it misses the no-slower rule by that margin; timing on other spreads was not measured. ", "blocked": null, "spread": 4, "base_mean_edge": 113.9414113871885, "base_unseen": {"mean_edge": 163.47813945343543, "retail_edge": 191.20763318061364, "arb_edge": -27.729493727194825}, "holdout": {"mean_edge": 164.06906427645012, "retail_edge": 189.9601391984835, "arb_edge": -25.891074922055996, "failures": 0}, "diff": {"mean": 0.5909248230146836, "standard_error": 0.19743783993870737, "retail": -1.2474939821301518, "arb": 1.8384188051388293}, "others_identical": {"runs": 900, "identical": true}, "seconds": {"base": 144.19885997008532, "yours": 145.2658611133229}, "code": "\"\"\"Crossing-cover base with isolated spread overrides; spread 4 adds a per-run retail demand posterior.\"\"\"\nimport math\nfrom orderbook_pm_challenge.strategy import BaseStrategy\nfrom orderbook_pm_challenge.types import CancelOrder, PlaceOrder, Side\n\nP = dict(lam_r=0.25, m=5.0, sig_n=1.2, lam_j=0.0019, sig_j=0.35, sig=0.02,\n         qmax=3000.0, rmin=2, kA=0.7, kL=0.15, pL=0.05,\n         ammo=1.0, ydem=0.4, W=200.0, fy=0.6, ammo_q=60.0, ammo_pmax=0.05, ammo_maxpay=0.02,\n         fb=0.9, fu=0.7, xu=0.1, sticky=1.0, min_ahead=2.0, keep_hi=1.5, keep_lo=0.7, Hu=300.0, bins=8.0, filt=1.0, uni=0.01, jumpinfo=1.0, dmin=0.0, kLb=0.08, kLf=0.08, pinf=1.0, pre=0.0, H1=100.0,\n         ydf=0.6, Wf=2000.0, g_hi=0.15, g_lo=0.15, qf=400.0, pmaxf=0.05, pre_gap=1.0,\n         ydf1=0.6, g1=5.0, f1=0.6, a1=100.0, nb1=0.0, gs=1.0, p1t=1.0, m1=1.0, zd=1.0, pfl=0.0005)\nSQ2 = math.sqrt(2.0)\nSQ2PI = math.sqrt(2.0 * math.pi)\ndef cdf(x): return 0.5 * (1.0 + math.erf(x / SQ2))\ndef pdf(x): return math.exp(-0.5 * x * x) / SQ2PI\ndef inv(p):\n    p = min(max(p, 1e-9), 1 - 1e-9)\n    t = math.sqrt(-2.0 * math.log(min(p, 1 - p)))\n    x = t - (2.515517 + 0.802853 * t + 0.010328 * t * t) / (1 + 1.432788 * t + 0.189269 * t * t + 0.001308 * t ** 3)\n    x = -x if p < 0.5 else x\n    for _ in range(2):\n        d = math.exp(-0.5 * x * x) / SQ2PI\n        if d < 1e-12:\n            break\n        x -= (0.5 * (1.0 + math.erf(x / SQ2)) - p) / d\n    return x\ndef lpm(k):\n    return pdf(k) + k * cdf(k)\ndef fl(q):\n    return math.floor(q * 100 + 1e-9) / 100\n\n# Conditional compound-Poisson likelihood for front-ask retail demand.\n# Bins contain total BUY notional in one step, including multiple arrivals.\n# A surviving front ask excludes arbitrage. Conditioning on V < quoted\n# capacity, INCLUDING zero-fill steps, removes partial-fill selection bias.\n# CDF table generated offline by FFT convolution of LogNormal(-.72,1.2).\n# Quantities and numerical convolution are discretized, not exact inference.\nDEMAND_RATE = [0.0825, 0.0935, 0.1045, 0.11549999999999999, 0.1265, 0.1375, 0.1485, 0.15949999999999998, 0.17049999999999998]\nDEMAND_MEAN = [2.8453333333333335, 3.2560000000000002, 3.666666666666667, 4.077333333333334, 4.488, 4.898666666666667, 5.309333333333333, 5.720000000000001, 6.1306666666666665]\nDEMAND_BINS = [0.05, 0.1, 0.2, 0.4, 0.8, 1.6, 3.2, 6.4, 12.8, 25.6, 51.2, 102.4, 204.8]\nDEMAND_CDF = [[0.92105888795, 0.92196113275, 0.924969202738, 0.932357807565, 0.945624667991, 0.963044967501, 0.979774193119, 0.991444400227, 0.997284251979, 0.999362623017, 0.999889869489, 0.999986021068, 0.999998701659], [0.920990592034, 0.921680317133, 0.924116873963, 0.930474227014, 0.942608055188, 0.959538272415, 0.976821491766, 0.989663227695, 0.996524794859, 0.999134577171, 0.999841266784, 0.999978600843, 0.999997887215], [0.920945012846, 0.921485151702, 0.92348952474, 0.929003887314, 0.940110233753, 0.956459487114, 0.974070049074, 0.987897259483, 0.99572208432, 0.998877738246, 0.999783052142, 0.999969162137, 0.99999678734], [0.920913751033, 0.921344787913, 0.923015908505, 0.927834183187, 0.938016424137, 0.953740992626, 0.971509510561, 0.986161548487, 0.994887167467, 0.998595033334, 0.999715353125, 0.999957581514, 0.999995364165], [0.920892286499, 0.921241004804, 0.922650360076, 0.926888826178, 0.936242509662, 0.951327643403, 0.969126878904, 0.984465721977, 0.99402899512, 0.998289236206, 0.999638392601, 0.999943764683, 0.999993582937], [0.920875459017, 0.921163058236, 0.922363381432, 0.926114128789, 0.934725532927, 0.949174359247, 0.966908468941, 0.982815715266, 0.993154809394, 0.99796292452, 0.999552457759, 0.999927641925, 0.999991411996], [0.920863935648, 0.92110328027, 0.92213405742, 0.925471903383, 0.933417637455, 0.947244128395, 0.964840878478, 0.981214974808, 0.992270479813, 0.997618465854, 0.999457877851, 0.999909164149, 0.999988822676], [0.920854888191, 0.921055988959, 0.921949132384, 0.924933659885, 0.932281742864, 0.945506399904, 0.962911468045, 0.979665200306, 0.991380757461, 0.997258018363, 0.999355008083, 0.999888299565, 0.999985789148], [0.920847052834, 0.921018315954, 0.921797428174, 0.924478933961, 0.931288674603, 0.943935630405, 0.961108570736, 0.978166924312, 0.990489488325, 0.996883539619, 0.999244217885, 0.999865030849, 0.999982288256], [0.911015393227, 0.91202676244, 0.915398852192, 0.923683802715, 0.938573205914, 0.958164698941, 0.977045025765, 0.990270372821, 0.99690960856, 0.999275188478, 0.999874909321, 0.999984137561, 0.999998527586], [0.910938837773, 0.911711980722, 0.914443340761, 0.92157134034, 0.935185781023, 0.954216200139, 0.9737067051, 0.988248324346, 0.996045399111, 0.999015661953, 0.999819663444, 0.999975713709, 0.999997603736], [0.910887746387, 0.911493210227, 0.913740065925, 0.919922528256, 0.932381833873, 0.950751675304, 0.970598418574, 0.986244861081, 0.995132202668, 0.99872333238, 0.999753475247, 0.999964996232, 0.99999635597], [0.91085270389, 0.911335870128, 0.913209140571, 0.91861095414, 0.930031998285, 0.947694131152, 0.96770782133, 0.984276965071, 0.994182646727, 0.998401542246, 0.999676486805, 0.99995184415, 0.999994741251], [0.910828643526, 0.911219535232, 0.91279936534, 0.917551004111, 0.928041559719, 0.94498092456, 0.965019717212, 0.982355432861, 0.993206954014, 0.998053461537, 0.999588949514, 0.999936149582, 0.999992720063], [0.910809781001, 0.911132161761, 0.912477669161, 0.916682440875, 0.926339682127, 0.942560940358, 0.962518245592, 0.980486863234, 0.992213386966, 0.997682037669, 0.999491188774, 0.999917832576, 0.999990256392], [0.910796864047, 0.91106515429, 0.912220604318, 0.915962426656, 0.924872550884, 0.940392273583, 0.960187955834, 0.978675033418, 0.9912086336, 0.997289978664, 0.999383578573, 0.999896836658, 0.999987317608], [0.910786722433, 0.911012143639, 0.912013310526, 0.915359005735, 0.923598489015, 0.938440375567, 0.958014329781, 0.97692174727, 0.990198099766, 0.996879753344, 0.999266523042, 0.999873125058, 0.9999838743], [0.910777939504, 0.910969914546, 0.911843256686, 0.914849227461, 0.922484718874, 0.936676391159, 0.955984002912, 0.975227495313, 0.989186154422, 0.996453601066, 0.999140443007, 0.999846677505, 0.99997990008], [0.901081414622, 0.902199415354, 0.905927255918, 0.915088709511, 0.931567794602, 0.953296025539, 0.974308790694, 0.989088636586, 0.996531994403, 0.999187169072, 0.999859883387, 0.999982249395, 0.999998353287], [0.900996788476, 0.901851442981, 0.904870896674, 0.912752344413, 0.927816630714, 0.948911636334, 0.970586818571, 0.986824984063, 0.995562217264, 0.998895905894, 0.999797955478, 0.999972818528, 0.999997319839], [0.900940310933, 0.901609606607, 0.904093419216, 0.910928987821, 0.924712608966, 0.945067029715, 0.967124082228, 0.984583618901, 0.994537732949, 0.998567789553, 0.999723743198, 0.999960817458, 0.999995923888], [0.900901574204, 0.9014356781, 0.903506487786, 0.90947869185, 0.922111943958, 0.941675765478, 0.963906106167, 0.982383430016, 0.993472774438, 0.998206584149, 0.999637402547, 0.9999460874, 0.999994117201], [0.900874977369, 0.901307078282, 0.903053492688, 0.908306707177, 0.91990946569, 0.938667676578, 0.960915389766, 0.980236353468, 0.992378854321, 0.997815862377, 0.999539213179, 0.999928506641, 0.99999185547], [0.900854126337, 0.901210493391, 0.902697870177, 0.907346383142, 0.918026577442, 0.935985612129, 0.958133818397, 0.978149619512, 0.991265267558, 0.997398947779, 0.999429538708, 0.999907984771, 0.999989098292], [0.900839847669, 0.901136421686, 0.902413697149, 0.90655033071, 0.916403602673, 0.933582786883, 0.955543835134, 0.976127304679, 0.990139528354, 0.996958894844, 0.999308798077, 0.999884457729, 0.999985809043], [0.900828636919, 0.901077822453, 0.902184545019, 0.905883203054, 0.914994346605, 0.931420674118, 0.95312900087, 0.97417128754, 0.989007701572, 0.996498488588, 0.999177444748, 0.999857883589, 0.999981954693], [0.900818928088, 0.901031141439, 0.901996560421, 0.905319617381, 0.913762493352, 0.929467130002, 0.950874222813, 0.972281989775, 0.987874680808, 0.996020255134, 0.999035951481, 0.999828238979, 0.999977505591], [0.891255757962, 0.892477938773, 0.896553397947, 0.906571831841, 0.924608220065, 0.948439102628, 0.97156565953, 0.987899230706, 0.996151403653, 0.999098562208, 0.999844791432, 0.99998035656, 0.999998178761], [0.891163246829, 0.892097538306, 0.895398487266, 0.904016464283, 0.920500293587, 0.943624690215, 0.967462023842, 0.985393267467, 0.995075245531, 0.998775305423, 0.999776142454, 0.999969915277, 0.999997035521], [0.89110150707, 0.891833166273, 0.894548501709, 0.902022428121, 0.917102162082, 0.939405606846, 0.963647242268, 0.982913615703, 0.993938675182, 0.998411105239, 0.999693855328, 0.999956625776, 0.999995491092], [0.891059161123, 0.891643030807, 0.893906845678, 0.900436507561, 0.914255787845, 0.935685896328, 0.960104569481, 0.980481047699, 0.992757556081, 0.99801015369, 0.99959809939, 0.999940311204, 0.999993492013], [0.891030086188, 0.891502448161, 0.893411620959, 0.899155005029, 0.911845686879, 0.932387843667, 0.956814096025, 0.978108608422, 0.991544708476, 0.997576432764, 0.999489182284, 0.999920835766, 0.999990989154], [0.891007292413, 0.891396863746, 0.893022850195, 0.89810499087, 0.909785618713, 0.929448262997, 0.953755375997, 0.975804127023, 0.990310471826, 0.997113648576, 0.999367505846, 0.999898098372, 0.999987937691], [0.890991683367, 0.891315890329, 0.892712191124, 0.897234622142, 0.908010140111, 0.926815502609, 0.95090868949, 0.973571947532, 0.989063193972, 0.996625208155, 0.99923353421, 0.99987202717, 0.999984296973], [0.890979428087, 0.891251831094, 0.892461682597, 0.896505234275, 0.90646861638, 0.924447077939, 0.948255635164, 0.971413993627, 0.987809602799, 0.996114218284, 0.999087770576, 0.999842574898, 0.999980030318], [0.890968814662, 0.891200800596, 0.89225617915, 0.895889065656, 0.905121257434, 0.922307579854, 0.945779362161, 0.969330591281, 0.986555117979, 0.99558349686, 0.998930740192, 0.999809714928, 0.999975104775], [0.881537242096, 0.882861192393, 0.887276272726, 0.898132479461, 0.917694267994, 0.943594082249, 0.968815802614, 0.986702194611, 0.995767830544, 0.999009365295, 0.999829633201, 0.999978459043, 0.999998004007], [0.881437028584, 0.882449113693, 0.886025069079, 0.89536293197, 0.913236459787, 0.938355467807, 0.964332510753, 0.983953235334, 0.994584480265, 0.998653856968, 0.999754223941, 0.999967003937, 0.999996750782], [0.881370148485, 0.882162727389, 0.885104241895, 0.893202019128, 0.909550098159, 0.933767460298, 0.960168098636, 0.981234934238, 0.993335029571, 0.99825327492, 0.99966381097, 0.999952421149, 0.99999505758], [0.881324276914, 0.881956760056, 0.884409121484, 0.891483521104, 0.906463059504, 0.92972452195, 0.956303413006, 0.978569922279, 0.992036997367, 0.997812245536, 0.999558576371, 0.9999345155, 0.999992865684], [0.881292781279, 0.881804471972, 0.883872640944, 0.890094976505, 0.903849686343, 0.926141368064, 0.952716032491, 0.975972321873, 0.990704529173, 0.99733516677, 0.999438855515, 0.999913136864, 0.99999012111], [0.881268089758, 0.881690096398, 0.88345148707, 0.888957309016, 0.90161621033, 0.922948779972, 0.949383103889, 0.973450527947, 0.989349020694, 0.996826133831, 0.999305088475, 0.999888173242, 0.999986774583], [0.881251181151, 0.881602381081, 0.883114953749, 0.888014317635, 0.899691515761, 0.92009025422, 0.946282688752, 0.971009119894, 0.987979660618, 0.996288912423, 0.999157784814, 0.999859544788, 0.99998278139], [0.881237905535, 0.88153298828, 0.882843582411, 0.88722409227, 0.898020605, 0.917519369134, 0.943394383223, 0.968650036737, 0.986603843611, 0.995726936711, 0.998997497898, 0.999827198723, 0.999978101161], [0.88122640847, 0.881477709026, 0.882620965169, 0.886556544958, 0.896560277004, 0.915197473935, 0.940699549414, 0.966373481837, 0.985227516633, 0.995143321396, 0.998824806026, 0.999791105011, 0.999972697614], [0.871924698753, 0.873348048187, 0.878094885015, 0.889769967952, 0.910825723789, 0.938761113188, 0.966059389, 0.985497567972, 0.995381269397, 0.998919575735, 0.999814408437, 0.999976556834, 0.999997829025], [0.871816962417, 0.872905028606, 0.876749609515, 0.886790986402, 0.906024820292, 0.933104071993, 0.961198467328, 0.982504948584, 0.994089917952, 0.998531556959, 0.999732199504, 0.999964084484, 0.999996465623], [0.871745061817, 0.872597140714, 0.875759579532, 0.884466938598, 0.902056024025, 0.928152640826, 0.956686848999, 0.979547657241, 0.992726796504, 0.998094294081, 0.999633609453, 0.999948203539, 0.999994623352], [0.87169574682, 0.872375710342, 0.87501223402, 0.882618860809, 0.898733291352, 0.923791638162, 0.952502835833, 0.976650157688, 0.991311104231, 0.997612854369, 0.999518832523, 0.999928700225, 0.999992238213], [0.871661886924, 0.872211989578, 0.874435455254, 0.881125709529, 0.895920930878, 0.919928190071, 0.948621392742, 0.973827617497, 0.989858329356, 0.997092058497, 0.999388231555, 0.999905409838, 0.999989251337], [0.871635341905, 0.872089027728, 0.87398267067, 0.879902392113, 0.893517761212, 0.916487048674, 0.945017184454, 0.971088963718, 0.988380935355, 0.996536397367, 0.999242284875, 0.999878209241, 0.999985608964], [0.871617164037, 0.871994727652, 0.873620864696, 0.878888443863, 0.891447087415, 0.913406874352, 0.94166599955, 0.96843897866, 0.986888958717, 0.995950001547, 0.99908154773, 0.999847010388, 0.999981262286], [0.871602891875, 0.871920125611, 0.873329115902, 0.878038780246, 0.88964962499, 0.910637329561, 0.938545392352, 0.965879586774, 0.985390464414, 0.99533663824, 0.998906624085, 0.999811754803, 0.999976167212], [0.871590531773, 0.871860696643, 0.873089783159, 0.877321038588, 0.888078824382, 0.908136545779, 0.935634909809, 0.963410841873, 0.983891927668, 0.994699724008, 0.998718145867, 0.999772408883, 0.999970284092], [0.8624169724, 0.863937390277, 0.869008249778, 0.881483618668, 0.904002372588, 0.93394034102, 0.963296586465, 0.984285390699, 0.994991714626, 0.998829190931, 0.999799116882, 0.999974649922, 0.999997653816], [0.862301889791, 0.863464154837, 0.867571086725, 0.878299873356, 0.898865066929, 0.927870602558, 0.958060079789, 0.981048468276, 0.993591555222, 0.998408401823, 0.999710068708, 0.999961156897, 0.999996180042], [0.862225086521, 0.863135269465, 0.866513465537, 0.875816372004, 0.8946195484, 0.922561196377, 0.953203688763, 0.977851867426, 0.992113976556, 0.997934158218, 0.999603250104, 0.999943972908, 0.999994188406], [0.862172408921, 0.862898738711, 0.865715113563, 0.87384166343, 0.891066018656, 0.917887238395, 0.948703034425, 0.974721857621, 0.990579882833, 0.997411974886, 0.999478866877, 0.999922865318, 0.999991609598], [0.862136240257, 0.86272385346, 0.865098978201, 0.872246301028, 0.888058890995, 0.913748248102, 0.944530367456, 0.971674618492, 0.989006122225, 0.996847102076, 0.99933730908, 0.999897654595, 0.999988379831], [0.862107885246, 0.862592506788, 0.864615302748, 0.870939304182, 0.885489684771, 0.910062953373, 0.940657796989, 0.968719575024, 0.987406237264, 0.996244433051, 0.999179093323, 0.999868206233, 0.999984440828], [0.86208846791, 0.862491776464, 0.86422881567, 0.869856037386, 0.883276218061, 0.906765194853, 0.937058785332, 0.965861679699, 0.985791118956, 0.995608469492, 0.999004820794, 0.999834423777, 0.999979739653], [0.862073222594, 0.862412087425, 0.863917166664, 0.868948311637, 0.881354994696, 0.903800740852, 0.933708806646, 0.963102812338, 0.984169505847, 0.994943317331, 0.998815146505, 0.999796242874, 0.999974228459], [0.862060019713, 0.862348606131, 0.863661510057, 0.868181540363, 0.879676178266, 0.901124529261, 0.930585565403, 0.960442850252, 0.982548402175, 0.99425270008, 0.998610756596, 0.999753626198, 0.999967864194], [0.853012920103, 0.8546281148, 0.860015392079, 0.873272758699, 0.897223999292, 0.929131908149, 0.960527561505, 0.983065702936, 0.994599160733, 0.998738208281, 0.999783758278, 0.999972738295, 0.999997478378], [0.852890664809, 0.854125376379, 0.8584884895, 0.869888845399, 0.891756892388, 0.922655156231, 0.954917532562, 0.979583855603, 0.993089388837, 0.998284387991, 0.999687831118, 0.999958221154, 0.999995894039], [0.852809074725, 0.853775989183, 0.857364861859, 0.867249512461, 0.887240281902, 0.916993172144, 0.949718811092, 0.976147647478, 0.991496570487, 0.997772862833, 0.999572732251, 0.999939729216, 0.999993752742], [0.852753113987, 0.853524714623, 0.856516701731, 0.865151074059, 0.883460779525, 0.91201131374, 0.944904202643, 0.972785125538, 0.989843339557, 0.997209601805, 0.999438678463, 0.999917010716, 0.999990979836], [0.852714691119, 0.85333892858, 0.855862135668, 0.863455856842, 0.880263040906, 0.907601478717, 0.940443144439, 0.969513447569, 0.988147921229, 0.996600291671, 0.999286086768, 0.999889871038, 0.999987506588], [0.852684568891, 0.853199395161, 0.855348296815, 0.862067118628, 0.87753139889, 0.903676377023, 0.936305117745, 0.966342501804, 0.986424948141, 0.995950234801, 0.999115512092, 0.999858164076, 0.999983270169], [0.85266394138, 0.853092386508, 0.854937710281, 0.860916144551, 0.875178275843, 0.90016504681, 0.932461206399, 0.963277377855, 0.984686172274, 0.995264310293, 0.99892760184, 0.999821784759, 0.999978213482], [0.85264774591, 0.853007730665, 0.854606630317, 0.859951710001, 0.873136038234, 0.897009384443, 0.928884767028, 0.960319880736, 0.982941008781, 0.99454696854, 0.99872306252, 0.999780662672, 0.99997228489], [0.852633720168, 0.852940292796, 0.854335034922, 0.859137054511, 0.871351623679, 0.894161158616, 0.925551635118, 0.957469684274, 0.981196991434, 0.993802245109, 0.998502635096, 0.999734756609, 0.999965437903], [0.843711411394, 0.845419129782, 0.851115346983, 0.86513672082, 0.89049038859, 0.924335953846, 0.957752479339, 0.981838545053, 0.99420360231, 0.99864662518, 0.999768332365, 0.999970821942, 0.999997302711], [0.843582154083, 0.844887589288, 0.849500817159, 0.861557161829, 0.884699990237, 0.917457826732, 0.951771008281, 0.978111171887, 0.992583415701, 0.998159511892, 0.999665486294, 0.999955277233, 0.999995607612], [0.843495891092, 0.844518187601, 0.848312741368, 0.858765560661, 0.879917837048, 0.911448610603, 0.946232406922, 0.974435080048, 0.990874579238, 0.997610403433, 0.999542055216, 0.999935472427, 0.999993316357], [0.843436725345, 0.844252519821, 0.847415951356, 0.856546246048, 0.875917114905, 0.906163852985, 0.941106531766, 0.970840064652, 0.989101481009, 0.997005729859, 0.999398266306, 0.999911136357, 0.999990348925], [0.843396101918, 0.844056092249, 0.846723864987, 0.854753491639, 0.8725328585, 0.901487816668, 0.936359908659, 0.967344226952, 0.987283740064, 0.996351621478, 0.99923456329, 0.999882059072, 0.999986631604], [0.84336425453, 0.843908566828, 0.846180578011, 0.853284918156, 0.869642325888, 0.897327201302, 0.931959319957, 0.96395788324, 0.985437089961, 0.995653796585, 0.999051539455, 0.999848082632, 0.999982096983], [0.843342445645, 0.843795429212, 0.845746463916, 0.852067821394, 0.867152634025, 0.893606260585, 0.927873419944, 0.960686226948, 0.983574149863, 0.994917518053, 0.998849888695, 0.99980909314, 0.999976683767], [0.843325322633, 0.843705924736, 0.845396414373, 0.851048008916, 0.864992085454, 0.890263041598, 0.924073411289, 0.957530957974, 0.981705014312, 0.99414758651, 0.998630369493, 0.999765013933, 0.999970336494], [0.843310493614, 0.843634624433, 0.845109258803, 0.85018659556, 0.863104451923, 0.887246168453, 0.920533234786, 0.954491519679, 0.979837746907, 0.993348354707, 0.998393778244, 0.999715799769, 0.999963005203]]\nDEMAND_LOG = []\nDEMAND_FLOW = [r*m for r in DEMAND_RATE for m in DEMAND_MEAN]\nDEMAND_RATEJ = [r for r in DEMAND_RATE for m in DEMAND_MEAN]\n\nNODES = [(-2.2, .06), (-1.3, .17), (-0.6, .27), (0.6, .27), (1.3, .17), (2.2, .06)]\nPROBE = 0.01\nPROBE_B = [PlaceOrder(side=Side.BUY, price_ticks=t, quantity=PROBE) if t else None for t in range(100)]\nPROBE_S = [PlaceOrder(side=Side.SELL, price_ticks=t, quantity=PROBE) if t else None for t in range(100)]\n\n\nclass Strategy(BaseStrategy):\n    def __init__(self):\n        self.n = 0\n        self.ahead = set()     # main orders placed strictly ahead of any competitor order at their tick\n        self.res = {}          # order id -> uncovered quantity at placement\n        self.bc = None         # belief: sub-tick grid centres (ticks)\n        self.bw = None         # belief: weights\n        self.st = 0.5          # last one-step sd in ticks\n        self.pcb = self.pca = None\n        self.pb = set()\n        self.pa = set()\n        self.tb = 0\n        self.s = None          # competitor spread parameter\n        self.flow_notional = 0.0\n        self.flow_exposure = 0\n        self.last_ask_tick = None\n        self.last_quote_exposed = False\n        self.last_flow_ca = None\n        self.last_flow_cap = 0.0\n        self.last_flow_correction = 1.0\n        self.params = P.copy()\n\n    def _oid(self, tag):\n        self.n += 1\n        return tag + str(self.n)\n\n    def _demand_update(self, prev, now):\n        tick, front, cutoff = prev\n        # One surviving order proves the arbitrageur did not sweep this tick.\n        for oid in front:\n            if oid in now:\n                break\n        else:\n            return\n        spent = sum([q-now.get(oid,0.0) for oid,q in front.items()])*tick/100.0\n        k = 0\n        for b in DEMAND_BINS:\n            if spent < b:\n                break\n            k += 1\n        if k > cutoff:\n            return\n        key = cutoff * 16 + k\n        pend = self.dpend\n        pend[key] = pend.get(key, 0) + 1\n        self.dcount += 1\n        if self.dcount % 16 == 0:\n            post = self.dpost\n            for key, n in pend.items():\n                post = [v+n*d for v,d in zip(post, DEMAND_LOG[key >> 4][key & 15])]\n            pend.clear()\n            self.dpost = post\n            mx = max(self.dpost)\n            exp = math.exp\n            weights = [exp(v-mx) for v in self.dpost]\n            z = sum(weights)\n            self.drate = sum([w*r for w,r in zip(weights,DEMAND_RATEJ)])/z\n            self.dmean = sum([w*f for w,f in zip(weights,DEMAND_FLOW)])/z/self.drate\n\n    def _demand_snapshot(self, state, actions, out, q1, amt, qam):\n        ahead = self.ahead\n        ra = {}\n        rb = {}\n        for o in state.own_orders:\n            if o.order_id in ahead:\n                (ra if o.side is Side.SELL else rb)[o.order_id] = (o.price_ticks,o.remaining_quantity)\n        for a in actions:\n            ra.pop(a.order_id,None)\n            rb.pop(a.order_id,None)\n        for a in out:\n            c = a.client_order_id\n            if c is not None and c in ahead:\n                (ra if a.side is Side.SELL else rb)[c] = (a.price_ticks,a.quantity)\n        self.dprev = None\n        if ra:\n            tick = min([v[0] for v in ra.values()])\n            front = {oid:q for oid,(t,q) in ra.items() if t==tick}\n            cap = sum(front.values())*tick/100.0\n            k = -1\n            cap -= .01*tick/100.0\n            for b in DEMAND_BINS:\n                if b >= cap:\n                    break\n                k += 1\n            if k >= 0:\n                self.dprev = (tick,front,k)\n        self.dbprev = None\n        if rb:\n            tick = max([v[0] for v in rb.values()])\n            # Do not mistake flow left over after anonymous stock bids for\n            # complete front-of-book retail flow.\n            if tick==1 and (q1>=.01 or (amt==1 and qam>=.01)):\n                return\n            for o in state.own_orders:\n                if o.side is Side.BUY and o.price_ticks>=tick and o.remaining_quantity>PROBE+1e-9 and o.order_id not in ahead:\n                    return\n            front = {oid:q for oid,(t,q) in rb.items() if t==tick}\n            cap = sum(front.values())*.05\n            k = -1\n            cap -= .0005\n            for b in DEMAND_BINS:\n                if b >= cap:\n                    break\n                k += 1\n            if k>=0:\n                self.dbprev = (5.,front,k)\n\n    def _demand_init(self):\n        if not DEMAND_LOG:\n            # DEMAND_LOG[cutoff][bin][run type]: log likelihood of one step's demand, conditional on the cutoff\n            table = []\n            for row in DEMAND_CDF:\n                masses = [row[0]] + [max(1e-14, row[i]-row[i-1]) for i in range(1,len(row))]\n                table.append([[math.log(max(1e-14, mass)/max(row[k],1e-14))\n                               for mass in masses[:k+1]] for k in range(len(row))])\n            for c in range(len(DEMAND_BINS)):\n                DEMAND_LOG.append([[t[c][k] for t in table] for k in range(c+1)])\n        self.dpost = [0.0]*len(DEMAND_FLOW)\n        self.dpend = {}\n        self.dprev = None\n        self.dbprev = None\n        self.dcount = 0\n        self.drate = sum(DEMAND_RATE)/len(DEMAND_RATE)\n        self.dmean = sum(DEMAND_MEAN)/len(DEMAND_MEAN)\n\n    def on_step(self, state):\n        H = max(1, state.steps_remaining)\n        cb = state.competitor_best_bid_ticks or 0\n        ca = state.competitor_best_ask_ticks or 100\n        if self.s is None:\n            self.s = max(1, (ca - cb + 1) // 2)\n            if self.s == 1:\n                self.params.update({'dmin': 0.3, 'pfl': 1e-06})\n            if self.s == 3:\n                self.params.update({'flow_prior': 200, 'flow_level': 0.6, 'flow_strength': 1.0, 'flow_safety': 2.0, 'flow_exposure_min': 5.0})\n            if self.s == 4:\n                self._demand_init()\n        P = self.params\n        if self.s == 4:\n            if self.dprev is not None or self.dbprev is not None:\n                now = {o.order_id:o.remaining_quantity for o in state.own_orders}\n                if self.dprev is not None:\n                    self._demand_update(self.dprev, now)\n                # A surviving ask certifies p <= .05; then SELL share conversion is exactly .05.\n                if self.dbprev is not None and any([o.side is Side.SELL and o.price_ticks <= 5 for o in state.own_orders]):\n                    self._demand_update(self.dbprev, now)\n        if self.s == 3 and self.last_quote_exposed and ca <= self.last_flow_ca + 1:\n            self.flow_exposure += 1\n            self.flow_notional += min(self.last_flow_cap, state.sell_filled_quantity * self.last_ask_tick / 100.0) * self.last_flow_correction\n        lo, hi = cb, ca\n        for o in state.own_orders:\n            if o.side is Side.BUY:\n                lo = max(lo, o.price_ticks)\n            else:\n                hi = min(hi, o.price_ticks)\n        if P['pinf'] > 0:\n            sb = set()\n            sa = set()\n            bids = []\n            asks = []\n            for o in state.own_orders:\n                if o.remaining_quantity <= PROBE + 1e-9:\n                    (sb if o.side is Side.BUY else sa).add(o.price_ticks)\n                else:\n                    (bids if o.side is Side.BUY else asks).append(o)\n            ea = self.pa - sa\n            eb = self.pb - sb\n            if sa and ea:\n                lo = max(lo, min(max(ea), hi))\n            if eb and (sb or min(eb) <= P['p1t']):\n                hi = min(hi, max(min(eb), lo))\n        if P['jumpinfo'] > 0 and self.pcb is not None:\n            if ca > self.pca + 1:\n                lo = max(lo, ca - 1)\n            if cb < self.pcb - 1:\n                hi = min(hi, cb + 1)\n        self.pcb, self.pca = cb, ca\n        if lo > hi:\n            lo, hi = hi, lo\n        # sub-tick belief over p_(t-1): predict with one-step noise, truncate to [lo, hi]\n        wid = max(hi - lo, 1e-6)\n        nb = max(2, min(48, int(round(wid * P['bins']))))\n        cs = [lo + (i + 0.5) * wid / nb for i in range(nb)]\n        if self.bc is None or P['filt'] <= 0:\n            ws = [1.0 / nb] * nb\n        else:\n            sg = max(self.st, 0.6 * wid / nb)\n            k = -0.5 / (sg * sg)\n            ws = []\n            uni = P['uni'] * sg\n            prior = list(zip(self.bc, self.bw))\n            exp = math.exp\n            for c in cs:\n                t = uni\n                for ci, wi in prior:\n                    d = c - ci\n                    d2 = d * d * k\n                    if d2 > -12.5:\n                        t += wi * exp(d2)\n                ws.append(t)\n            tot = sum(ws)\n            ws = [w / tot for w in ws]\n        self.bc, self.bw = cs, ws\n        mean_t = sum([c * w for c, w in zip(cs, ws)])\n        var_t = max(sum([c * c * w for c, w in zip(cs, ws)]) - mean_t * mean_t, 0.0)\n        phat = min(max(mean_t / 100.0, 0.002), 0.998)\n        var = P['sig'] ** 2 + P['lam_j'] * P['sig_j'] ** 2\n        sd = math.sqrt(H * var)\n        self.tb = self.tb + 1 if hi <= 1 else 0\n        if self.tb > 0 and P['zd'] > 0:\n            # below the last tick there is no probe: the score keeps walking away from it\n            phat = min(phat, max(P['pfl'], cdf(inv(0.01) - P['zd'] * 0.02 * math.sqrt(self.tb) / sd)))\n        z = inv(phat)\n        Z = z * sd\n        sp = pdf(z) / sd * P['sig']\n        self.st = sp * 100.0\n        s = math.sqrt(sp * sp + var_t / 1e4 + 1e-8)\n        sd1 = math.sqrt(max(1.0, H - 1.0) * var)\n        erf = math.erf\n        sj = P['sig_j']\n        jp = [(0.5 * (1.0 + erf((Z + n * sj) / sd1 / SQ2)), w) for n, w in NODES]\n        lj = P['lam_j']\n\n        def AB(x):\n            k = (x - phat) / s\n            a = s * (math.exp(-0.5 * k * k) / SQ2PI + k * (0.5 * (1.0 + math.erf(k / SQ2))))\n            b = a - (x - phat)\n            ja = sum([w * (x - p) if x > p else 0.0 for p, w in jp])\n            jb = sum([w * (p - x) if p > x else 0.0 for p, w in jp])\n            return (1 - lj) * a + lj * ja, (1 - lj) * b + lj * jb\n\n        if H == 1:\n            def AB(x):\n                return (1 - phat) * x, phat * (1 - x)\n        rho = P['lam_r'] * 0.5\n        mu = math.log(P['m']) - 0.5 * P['sig_n'] ** 2\n        kA = P['kL'] if phat < P['pL'] else P['kA']\n\n        def qsize(loss, gain, px):\n            loss *= kA\n            if gain <= 0:\n                return 0.0\n            if self.s == 4 and self.dcount >= 64 and self.drate * self.dmean < 0.45:\n                # this run's retail is confidently thin: no bigger than its fitted arrival rate and mean size justify\n                tail = loss / (rho * gain)\n                old = 0.0 if tail >= 1.0 else min(P['qmax'], math.exp(mu + P['sig_n'] * inv(1 - max(tail, 1e-6))) / px)\n                tail = loss / (self.drate * gain)\n                if tail >= 1.0:\n                    return 0.0\n                return min(old, P['qmax'], math.exp(math.log(self.dmean) - 0.72 + 1.2 * inv(1 - max(tail, 1e-6))) / px)\n            tail = loss / (rho * gain)\n            if tail >= 1.0:\n                return 0.0\n            return min(P['qmax'], math.exp(mu + P['sig_n'] * inv(1 - max(tail, 1e-6))) / px)\n\n        ptk = phat * 100\n        def qbid(t):\n            if not 1 <= t <= 99:\n                return 0.0\n            a, b = AB(t / 100.0)\n            if phat * 100 - t < P['dmin']:\n                return 0.0\n            if P['nb1'] > 0 and self.s == 1 and t == 1 and ptk < 1.0:\n                return 0.0\n            if phat < P['pL']:\n                ytg = P['ydem'] * min(H, P['W']) / max(ca - 1, ptk + 1) * 100.0\n                a *= (P['kLb'] if state.yes_inventory < ytg else P['kLf']) / P['kL']\n            return qsize(a, b, max(phat, 0.05))\n\n        def qask(t):\n            if not 1 <= t <= 99:\n                return 0.0\n            a, b = AB(t / 100.0)\n            if t - phat * 100 < P['dmin']:\n                return 0.0\n            return qsize(b, a, t / 100.0)\n\n        sticky = P['sticky'] > 0\n        def top(orders, comp, step):\n            if sticky and sum([o.remaining_quantity for o in orders if o.price_ticks == comp and o.order_id in self.ahead]) >= P['min_ahead']:\n                return comp\n            return comp + step\n        bid_t = top(bids, cb, 1)\n        ask_t = top(asks, ca, -1)\n        qb = qbid(bid_t)\n        qa = qask(ask_t)\n\n        Y = state.yes_inventory\n        if ask_t == 1 and H > P['H1'] and P['pre'] > 0:\n            qa = qa if Y >= P['a1'] > 0 else 0.0          # let the competitor's 2-tick ask erode instead of fronting it for nothing\n        # ammunition: hold YES so that low asks are covered\n        ptick = phat * 100\n        amt = 0\n        qam = 0.0\n        if P['ammo'] > 0 and ask_t >= 2 and phat < max(P['ammo_pmax'], P['pmaxf']):\n            wealth = state.cash + Y * phat\n            x = max(ask_t, ptick + 1) / 100.0\n            capw = P['fy'] * wealth / max(phat, 0.005)\n            target = min(P['ydem'] * min(H, P['W']) / x, capw)\n            full = min(P['ydf'] * min(H, P['Wf']) / x, capw) if phat < P['pmaxf'] else 0.0\n            t = max(1, min(99, int(math.ceil(ptick + 1e-9))))\n            g = t - ptick\n            if Y < full and g <= P['g_hi'] and bid_t <= t < ask_t:\n                amt, qam = t, min(P['qf'], full - Y)     # a tick p has just crossed: nearly free\n            elif Y < target and phat < P['ammo_pmax'] and bid_t <= t < ask_t and t / 100.0 - phat < P['ammo_maxpay']:\n                amt, qam = t, min(P['ammo_q'], target - Y)\n            elif Y < full and t >= 2 and 1.0 - g <= P['g_lo']:\n                amt, qam = t - 1, min(P['qf'], full - Y)  # rest just under p: filled only on the crossing, or by retail\n\n        if P['pre'] > 0 and ca == 2 and phat < 0.01 and H > P['H1'] and Y < P['pre'] and not qam and 1.0 - ptick < P['pre_gap']:\n            amt, qam = 1, min(P['ammo_q'], P['pre'] - Y)\n        q1 = 0.0\n        if P['ydf1'] > 0 and P['m1'] < ptick < P['g1'] + 1.0 and amt != 1:\n            stock_rate = P['ydf1']\n            if self.s == 3:\n                flow = (self.flow_notional + P['flow_prior'] * P['flow_level']) / (P['flow_prior'] + self.flow_exposure)\n                scale = max(0.5, min(2.0, flow / P['flow_level']))\n                stock_rate *= 1.0 + P['flow_strength'] * (scale - 1.0)\n            q1 = max(0.0, stock_rate * min(H, P['Wf']) / (self.s / 100.0) - Y)\n\n        # Bridge expected retail demand until another tick crossing is available.\n        if 0.02 < phat < 0.1:\n            ct = max(2, min(99, int(math.floor(ptick))))\n            wealth = state.cash + Y * phat\n            goal = min(1 * qa, 0.3 * max(wealth, 0.0) / phat)\n            if Y < goal and ct < ask_t:\n                amt, qam = ct, min(3000.0, goal - Y)\n        # order management\n        actions = []\n        free = state.free_cash - 2.0\n        keep_ask = 0.0\n        new_b = []\n        new_a = []\n        def cancel(o):\n            nonlocal free\n            actions.append(CancelOrder(o.order_id))\n            x = o.price_ticks / 100.0\n            if o.side is Side.BUY:\n                free += x * o.remaining_quantity\n            else:\n                free += (1 - x) * min(self.res.get(o.order_id, 0.0), o.remaining_quantity)\n            self.ahead.discard(o.order_id)\n            self.res.pop(o.order_id, None)\n        for o in state.own_orders:\n            if o.remaining_quantity <= PROBE + 1e-9:\n                cancel(o)\n        kept_ids = set()\n        def manage(orders, t, q, comp):\n            kept = 0.0\n            for o in orders:\n                if o.price_ticks == t and q > 0 and kept + o.remaining_quantity <= max(q * P['keep_hi'], 1.0):\n                    kept += o.remaining_quantity\n                    kept_ids.add(o.order_id)\n                else:\n                    cancel(o)\n            return kept\n        kb = manage(bids, bid_t, qb, cb)\n        ka = manage(asks, ask_t, qa, ca)\n        add_b = (qb - kb) if (kb < qb * P['keep_lo'] and bid_t != cb) else 0.0\n        add_a = (qa - ka) if (ka < qa * P['keep_lo'] and ask_t != ca) else 0.0\n\n        budget = P['fb'] * max(free, 0.0)\n        cost = add_b * bid_t / 100.0 + qam * amt / 100.0\n        if cost > budget:\n            f = budget / cost\n            add_b *= f\n            qam *= f\n            cost = budget\n        out = []\n        q1 = min(q1, P['f1'] * max(budget - cost, 0.0) * 100.0)\n        if q1 >= 0.01:\n            out.append(PlaceOrder(side=Side.BUY, price_ticks=1, quantity=fl(q1)))\n            free -= fl(q1) / 100.0 + 1e-6\n        if amt and qam >= 0.01:\n            q = fl(qam)\n            out.append(PlaceOrder(side=Side.BUY, price_ticks=amt, quantity=q))\n            free -= q * amt / 100.0 + 1e-6\n        if bid_t >= 1 and add_b >= 0.01:\n            q = fl(add_b)\n            oid = self._oid('b')\n            out.append(PlaceOrder(side=Side.BUY, price_ticks=bid_t, quantity=q, client_order_id=oid))\n            free -= q * bid_t / 100.0 + 1e-6\n            if bid_t > cb:\n                self.ahead.add(oid)\n        if ask_t <= 99 and add_a >= 0.01:\n            x = ask_t / 100.0\n            covk = sum(o.remaining_quantity - min(self.res.get(o.order_id, 0.0), o.remaining_quantity)\n                       for o in asks if o.order_id in kept_ids)\n            cov = max(0.0, Y - covk - 0.1)\n            unc = max(0.0, add_a - cov)\n            if unc > 0:\n                ub = max(0.0, free - (1 - P['fu']) * max(state.cash, 0.0)) if x >= P['xu'] else 0.0\n                if H < P['Hu'] and phat < 0.05:\n                    ub = max(0.0, free * (1 - H / P['Hu']))\n                unc = min(unc, ub / (1 - x))\n            q = fl(min(add_a, cov + unc))\n            if q >= 0.01:\n                oid = self._oid('a')\n                out.append(PlaceOrder(side=Side.SELL, price_ticks=ask_t, quantity=q, client_order_id=oid))\n                r = max(0.0, q - cov)\n                self.res[oid] = r\n                free -= r * (1 - x) + 1e-6\n                if ask_t < ca:\n                    self.ahead.add(oid)\n\n        # probes: tiny orders that the arbitrageur removes when p crosses them\n        f = int(math.floor(ptick + 1e-9))\n        r = max(int(P['rmin']), int(math.ceil(2.0 * s * 100)))\n        self.pb = set()\n        self.pa = set()\n        if free > 1.0:\n            for t in range(f, f + r + 1):\n                if cb < t < ca and 1 <= t <= 99:\n                    out.append(PROBE_B[t])\n                    self.pb.add(t)\n            for t in range(f + 1 - r, f + 2):\n                if cb < t < ca and 1 <= t <= 99:\n                    out.append(PROBE_S[t])\n                    self.pa.add(t)\n        if self.s == 3:\n            self.last_ask_tick = ask_t\n            self.last_flow_ca = ca\n            exposed_qty = ka + sum(o.quantity for o in out if o.side is Side.SELL and o.price_ticks == ask_t and o.quantity > PROBE)\n            self.last_flow_cap = exposed_qty * ask_t / 100.0\n            self.last_quote_exposed = ask_t / 100.0 > phat + max(0.005, P['flow_safety'] * self.st / 100.0) and self.last_flow_cap >= P['flow_exposure_min']\n            if self.last_quote_exposed:\n                logcap = math.log(self.last_flow_cap)\n                mu_flow = math.log(P['m']) - 0.5 * P['sig_n'] ** 2\n                clipped = P['m'] * cdf((logcap - mu_flow - P['sig_n'] ** 2) / P['sig_n']) + self.last_flow_cap * (1.0 - cdf((logcap - mu_flow) / P['sig_n']))\n                self.last_flow_correction = min(3.0, P['m'] / max(clipped, 0.01))\n        if self.s == 4:\n            self._demand_snapshot(state, actions, out, q1, amt, qam)\n        return actions + out\n", "code_sha256": "82050f4ad84aac8df65dc1154b7d5ac30053d16c9d028f477aa1d50d5da5ef33", "tried": ["Verbatim demand graft at s==4 (posterior sizing, stock, near-price target): part A 300 seeds mean +1.274812949576001 se 0.9029830479433238 retail -1.480418146218334 arb +2.755231095797333; part B 300 seeds mean -1.0791068147179994 se 1.3438314545861416 retail -1.5526588164169999 arb +0.47355200172266676. Rejected: lost on part B.", "Stock only (tick-1 stock 1.25 x fitted flow, near-price target .3+.5 x flow, own-bid gate): part A 300 seeds mean -0.1924383136340008 se 0.13535886791188245. Rejected, spread 4 stock sizing does not pay.", "Base's lognormal rule with fitted rate and mean, both ways (qs2): part A 300 seeds mean +1.0379682220830002 se 0.9805305089731766 retail -1.7930033660889997 arb +2.830971588176667. Not kept alone. Combined with stock: +0.9342280950409997 se 0.9946360367708087.", "qs2 with 0.85 loss factor to hold retail: part A 280 seeds mean +1.3569413068921419 se 0.961062635702969 retail -0.05; part B 300 seeds mean -0.8284193164136665 se 0.7294315033468177. Rejected: lost on part B.", "qs2 size only allowed up: part A 279 seeds mean -0.08305059040394379 se 0.217118292705503. Rejected.", "qs2 size only allowed down: part A 276 seeds mean +1.3954642653623182 se 1.0036140073753563; part B 300 seeds mean -0.529836695887001 se 0.743923040860674. Rejected: lost on part B; by true-flow quartile the gain sat in the thinnest quarter.", "KEPT: size down only when posterior is confident (>=64 observations) and fitted flow < 0.45: part A 300 seeds mean +0.3923329087306663 se 0.4905585670040766 retail -1.2627471876363336 arb +1.6550800963656667; part B 300 seeds mean +0.31040315320933354 se 0.3021050747687596 retail -1.1145426831003344 arb +1.4249458363013334. Thinnest true-flow quartile gains +1.91 on A and +1.60 on B, others about 0 to -0.22.", "Speed: first form of the frozen rule was 9.5% slower than the base over 60 tuning runs; behaviour-preserving rewrites brought it to +0.5% over 40 runs and +0.74% over the final 200 runs."], "next": "Sharpen the low-flow cut: the three upper true-flow quartiles lose 0 to 0.22 from misclassified runs, so try a tighter threshold or a posterior-probability test instead of a point estimate; the whole gain trades retail for arbitrage, so also check whether it holds with retail kept level. Stock sizing is a dead end on spread 4. The estimator's tables add about 23 KB, so a stacked file should share them. On this machine a full spread-4 evaluation of 2009 runs takes about 12 minutes per strategy: budget for it."}