Skip to content

Instantly share code, notes, and snippets.

@yongkangc
Created March 3, 2026 15:38
Show Gist options
  • Select an option

  • Save yongkangc/96725452900da7faf2e53c39701bb3e5 to your computer and use it in GitHub Desktop.

Select an option

Save yongkangc/96725452900da7faf2e53c39701bb3e5 to your computer and use it in GitHub Desktop.
CexLead Sweep v3 — ETH 15m — 14d train/13d test — realistic execution
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CexLead Sweep v3 — ETH 15m — 14d Train / 13d Test</title>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: #0d1117;
color: #c9d1d9;
padding: 20px;
}
h1 { color: #58a6ff; margin-bottom: 10px; font-size: 24px; }
h2 { color: #8b949e; margin: 30px 0 15px; font-size: 18px; }
.summary {
background: #161b22;
border: 1px solid #30363d;
border-radius: 6px;
padding: 20px;
margin-bottom: 30px;
}
.summary p { margin: 8px 0; line-height: 1.6; }
.highlight { color: #7ee787; font-weight: bold; }
.warn { color: #f0883e; }
.chart-container {
background: #161b22;
border: 1px solid #30363d;
border-radius: 6px;
padding: 15px;
margin-bottom: 20px;
}
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 1200px) { .grid { grid-template-columns: 1fr; } }
table {
width: 100%;
border-collapse: collapse;
font-size: 12px;
margin-top: 20px;
}
th, td {
padding: 8px 12px;
text-align: right;
border-bottom: 1px solid #30363d;
}
th {
background: #21262d;
color: #8b949e;
font-weight: 600;
position: sticky;
top: 0;
}
td:first-child, th:first-child { text-align: left; }
tr:hover { background: #21262d; }
.table-container {
max-height: 600px;
overflow-y: auto;
background: #161b22;
border: 1px solid #30363d;
border-radius: 6px;
}
</style>
</head>
<body>
<h1>⚡ CexLead Signal Sweep v3 — ETH 15m</h1>
<p style="color: #8b949e; margin-bottom: 20px;">14-day train (Feb 5-18) / 13-day test (Feb 19 – Mar 3) • Realistic execution (taker at best ask/bid)</p>
<div class="summary" id="summary"></div>
<h2>3D Surface: Test Sharpe by Threshold & Distance</h2>
<div class="chart-container" id="surface3d" style="height: 600px;"></div>
<h2>Heatmaps (Test Period)</h2>
<div class="grid">
<div class="chart-container" id="heatmap-sharpe" style="height: 400px;"></div>
<div class="chart-container" id="heatmap-pnl" style="height: 400px;"></div>
<div class="chart-container" id="heatmap-avgpnl" style="height: 400px;"></div>
<div class="chart-container" id="heatmap-winrate" style="height: 400px;"></div>
<div class="chart-container" id="heatmap-trades" style="height: 400px;"></div>
<div class="chart-container" id="heatmap-flatrate" style="height: 400px;"></div>
</div>
<h2>Full Results Table (Test Period)</h2>
<div class="table-container" id="results-table"></div>
<script>
const csvData = `cex_ret_threshold_bps,distance_filter,split,trade_count,win_rate,lose_rate,flat_rate,avg_pnl,total_pnl,sharpe,trades_per_day,max_daily_loss,max_daily_gain
1.0,0.1,train,15895,0.5947153192827933,0.30393205410506446,0.10135262661214219,0.09154576910978392,1455.1200000000154,74.67414483886124,1135.357142857143,62.39999999999999,153.89999999999998
1.0,0.1,test,8899,0.5880436004045398,0.3235194965726486,0.08843690302281156,0.0957152489043714,851.7700000000011,31.20540230343408,684.5384615384615,0.0,117.34999999999991
1.0,0.15,train,22866,0.595556721770314,0.3023265984431033,0.1021166797865827,0.09069316889705296,2073.790000000013,82.14255977660179,1633.2857142857142,93.04999999999997,210.40000000000023
1.0,0.15,test,12610,0.5917525773195876,0.3198255352894528,0.08842188739095956,0.09622759714512281,1213.4299999999987,30.555768769504002,970.0,0.0,177.14999999999995
1.0,0.2,train,29621,0.5895817156746902,0.30707943688599304,0.1033388474393167,0.08782249080044507,2601.3899999999835,84.31803322608191,2115.785714285714,117.84999999999995,252.90000000000026
1.0,0.2,test,16497,0.584045584045584,0.3244226222949627,0.09153179365945323,0.09124477177668666,1505.2649999999999,30.620906058067916,1269.0,0.0,220.4150000000003
1.0,0.25,train,35617,0.5834573377881349,0.31021703119296967,0.10632563101889547,0.08402883454530034,2992.8549999999623,83.69857690138191,2544.0714285714284,136.80000000000007,285.9000000000003
1.0,0.25,test,19690,0.5804977145759269,0.32427628237684103,0.0952260030472321,0.0890995429151854,1754.3700000000006,30.107534237697603,1514.6153846153845,0.0,256.61500000000024
1.0,0.3,train,41400,0.5745893719806763,0.31473429951690823,0.11067632850241546,0.07963671497584418,3296.959999999949,85.48552640611202,2957.1428571428573,145.90000000000006,315.5000000000007
1.0,0.3,test,22644,0.5745009715597951,0.32710651828298887,0.09839251015721603,0.08495451333686607,1923.7099999999953,29.253359608684292,1741.8461538461538,0.0,281.8500000000001
1.0,0.4,train,52621,0.5523650253700993,0.3273978069591988,0.1202371676707018,0.06967883544592353,3666.569999999942,76.09378272736464,3758.6428571428573,145.81000000000003,356.9200000000001
1.0,0.4,test,29099,0.5457575861713461,0.3430014777140108,0.11124093611464311,0.07101395236949706,2066.434999999995,27.76714585860397,2238.3846153846152,0.0,313.5500000000004
1.0,0.5,train,71009,0.44450703431959326,0.4219746792660085,0.13351828641439817,0.0452741905955551,3214.8749999997717,63.5817035745915,5072.071428571428,102.45000000000422,338.9799999999966
1.0,0.5,test,38181,0.45176920457819336,0.4191613629815877,0.12906943244021896,0.04808687567114681,1836.0050000000565,26.075339897791334,2937.0,0.0,289.2049999999989
1.5,0.1,train,6774,0.6359610274579274,0.273398287570121,0.09064068497195157,0.12224756421612101,828.1050000000038,56.2361571364754,483.85714285714283,31.59999999999999,102.35000000000011
1.5,0.1,test,3270,0.6587155963302752,0.26788990825688075,0.07339449541284404,0.1473883792048931,481.9600000000004,30.949095158862853,251.53846153846155,0.0,78.59999999999995
1.5,0.15,train,9755,0.6409021014864172,0.2685802152742183,0.09051768323936443,0.12198001025115349,1189.9150000000022,58.71998435954638,696.7857142857143,42.70000000000002,140.19999999999987
1.5,0.15,test,4674,0.6604621309370988,0.26658108686350024,0.07295678219940094,0.14736628155755227,688.7899999999993,30.67156449041657,359.53846153846155,0.0,113.7999999999999
1.5,0.2,train,12661,0.6330463628465366,0.27430692678303453,0.09264671037042888,0.1182217044467265,1496.8050000000042,62.29152290192208,904.3571428571429,56.6,167.95
1.5,0.2,test,6099,0.6553533366125595,0.2698803082472537,0.07476635514018691,0.14201672405312338,866.1599999999995,31.186042473245497,469.15384615384613,0.0,138.90000000000003
1.5,0.25,train,15223,0.6289167706759509,0.27563555146817315,0.09544767785587598,0.11409117782303115,1736.8100000000031,62.45853388973668,1087.357142857143,68.80000000000004,196.55000000000004
1.5,0.25,test,7297,0.6542414690968892,0.2675071947375634,0.07825133616554748,0.13860422091270386,1011.3950000000001,30.51280271621059,561.3076923076923,0.0,162.25000000000003
1.5,0.3,train,17742,0.6219141021305377,0.2791680757524518,0.09891782211701049,0.1084835418780295,1924.7149999999995,62.39588055768734,1267.2857142857142,77.10000000000004,217.05000000000024
1.5,0.3,test,8358,0.6465661641541038,0.27183536731275426,0.0815984685331419,0.13372577171572142,1117.6799999999996,30.000760499690113,642.9230769230769,0.0,179.9350000000001
1.5,0.4,train,22659,0.6006884681583476,0.28889183106050575,0.11041970078114656,0.09697735998940826,2197.4100000000017,59.12657092420645,1618.5,81.1,239.9
1.5,0.4,test,10817,0.6156975131737080,0.2883424239622816,0.09596006286401035,0.11438291578071544,1237.2799999999988,28.92029303462066,832.0769230769231,0.0,205.5350000000003
1.5,0.5,train,31047,0.480561728991529,0.3909556478886849,0.12848262311978614,0.06542532289754428,2031.2600000000575,57.78680801346099,2217.6428571428573,73.53500000000028,237.25999999999866
1.5,0.5,test,14501,0.5052754982415005,0.3729397972553617,0.12178470450313772,0.08116681608165086,1177.000000000019,28.81463884150374,1115.4615384615386,0.0,195.9450000000002
2.0,0.1,train,3023,0.6768111147866358,0.24478994376447238,0.07839894144889183,0.15164571617598394,458.42499999999944,56.17483865510525,215.92857142857142,13.699999999999998,55.74999999999998
2.0,0.1,test,1389,0.7170626349172786,0.22030237580273578,0.0626349892799856,0.16931316054715566,235.18599999999978,31.25892498236232,106.84615384615384,0.0,45.13500000000001
2.0,0.15,train,4367,0.6800091829494836,0.24237097780904742,0.0776199392414689,0.14964553696122274,653.40149999999987,57.91046785932765,311.92857142857144,21.35,71.65000000000003
2.0,0.15,test,1964,0.7168024439918534,0.22148676171079428,0.06171079428734939,0.1740642566191449,341.8261999999999,31.1632432127654,151.07692307692307,0.0,63.11000000000003
2.0,0.2,train,5710,0.6698774517543859,0.24991226482456141,0.08021028341905519,0.14296402538525396,816.5249999999988,62.37206614295538,407.85714285714283,30.55000000000002,89.95000000000003
2.0,0.2,test,2593,0.7092944854028808,0.22484110683303895,0.0658644077640803,0.16789408027034544,435.30699999999985,30.36200631618866,199.46153846153845,0.0,79.84499999999998
2.0,0.25,train,6883,0.6641756210958565,0.2537556294927765,0.08206874901136696,0.13617645244223024,937.31699999999887,62.66574181178649,491.6428571428571,36.3,102.55000000000001
2.0,0.25,test,3124,0.7054417413572343,0.22599231754160051,0.06856593110116517,0.16114056972477585,503.4031999999998,30.27127078168968,240.3076923076923,0.0,94.10999999999996
2.0,0.3,train,8049,0.6546153404149584,0.2598149459559572,0.08556971362908437,0.12952552052424488,1042.4699999999996,62.89698161131654,574.9285714285714,40.2,117.55
2.0,0.3,test,3598,0.6948304613674264,0.2321845470261256,0.0729850416231480,0.1544302973318506,555.6441999999995,30.35655044839684,276.7692307692308,0.0,103.1099999999999
2.0,0.4,train,10340,0.6369438105419922,0.2696324951644562,0.0934236942935516,0.11601093810444877,1199.4729000000001,59.22259377626903,738.5714285714286,41.1,128.31000000000012
2.0,0.4,test,4713,0.6751539317639297,0.24238615116293657,0.08245993714313367,0.13875974962310626,654.0102000000004,28.80626987610612,362.53846153846155,0.0,121.38999999999997
2.0,0.5,train,14450,0.5313494809688581,0.3519377162629758,0.11671280276816609,0.08175916263840895,1181.4200000000435,57.42108497655403,1032.1428571428571,42.34999999999974,140.6699999999991
2.0,0.5,test,6534,0.5617614608784511,0.3313463118147533,0.10689222730679556,0.11094012180654285,724.7231999999946,28.75655903261523,502.6153846153846,0.0,141.97999999999968
2.5,0.1,train,1482,0.6977057489878543,0.23549257759784075,0.06680167597765363,0.16453169636978492,243.83599999999988,50.86855903648127,105.85714285714286,5.050000000000001,33.3
2.5,0.1,test,656,0.7484756097560976,0.1951219512195122,0.05640243902439024,0.18280563414634162,119.92049999999992,31.33006109649979,50.46153846153846,0.0,20.75
2.5,0.15,train,2138,0.6999065481758654,0.2310103835360149,0.06908306828811974,0.16214995322732407,346.72059999999976,50.96107549809266,152.71428571428572,9.999999999999995,43.4
2.5,0.15,test,932,0.7489270386266094,0.19206008583690986,0.05901287553648069,0.18571116309012904,173.08280000000002,31.01878422571067,71.69230769230769,0.0,29.85
2.5,0.2,train,2818,0.692692689140525,0.23704754436479419,0.07025977649468035,0.15629140312595312,440.4291999999998,55.08802619792648,201.28571428571428,15.949999999999998,52.65
2.5,0.2,test,1234,0.7398054474708171,0.1985413098544851,0.06165324267469879,0.17929570502431469,221.2307000000001,31.013893972587875,94.92307692307692,0.0,40.04999999999999
2.5,0.25,train,3411,0.6856640868954265,0.24186163882145993,0.07247427428311356,0.14844946789504533,506.41850000000005,54.32959574959096,243.64285714285714,19.299999999999994,62.05
2.5,0.25,test,1491,0.7345406438630449,0.20120053654594233,0.06425838308101273,0.17210066398389658,256.56209000000014,31.078421040315374,114.69230769230769,0.0,47.54999999999999
2.5,0.3,train,4001,0.6745813546613346,0.24818795301174706,0.0772307023269183,0.14140234566358362,565.7507999999988,55.56892591679912,285.7857142857143,22.45000000000002,70.65000000000002
2.5,0.3,test,1719,0.7245026177894708,0.2071553228621292,0.0683420593484,0.16371809192553783,281.43199999999985,31.29927820972247,132.23076923076923,0.0,54.38
2.5,0.4,train,5208,0.6559140168970045,0.25787249615975423,0.08621348694324117,0.1259891897080453,656.0397000000003,53.63959310028629,372.0,22.700000000000017,79.3
2.5,0.4,test,2307,0.7043952535110533,0.21285652579107066,0.08274821869787402,0.14700628176637168,339.14749999999993,29.24788932102632,177.46153846153845,0.0,66.25
2.5,0.5,train,7436,0.5574770306616461,0.32477676708984395,0.11774620224851002,0.09664403125840256,718.640200000002,53.18168584682912,531.1428571428571,23.06500000000016,95.88999999999997
2.5,0.5,test,3281,0.5966473331910393,0.2914964340140201,0.11185623279494058,0.1266055445352015,415.45759000000176,29.18217679266377,252.38461538461536,0.0,83.8
3.0,0.1,train,833,0.7070948379351741,0.2291117647058824,0.0637933973589435,0.16883145378152493,140.6726000000001,44.49875135929131,59.5,2.050000000000002,23.300000000000004
3.0,0.1,test,368,0.7635869565217391,0.1847826086956522,0.05163043478260869,0.19364565217391303,71.26159999999998,31.60139393952574,28.307692307692307,0.0,15.6
3.0,0.15,train,1181,0.7052497037256563,0.23369178662997459,0.06105850964436954,0.16485427518204045,194.69289999999998,44.21118700730327,84.35714285714286,3.8499999999999996,32.3
3.0,0.15,test,532,0.7537593984962406,0.18609022556390976,0.0601503759398496,0.19261428571428558,102.47080000000001,31.04098691653423,40.92307692307692,0.0,21.799999999999994
3.0,0.2,train,1557,0.6954399486192679,0.2408477199743094,0.06371233200642261,0.15817048490110459,246.27259999999992,47.10498505855929,111.21428571428571,5.399999999999998,38.2
3.0,0.2,test,718,0.7395543175487465,0.19637883008356545,0.06406685236768802,0.18263704735376032,131.16540000000002,30.74689892656737,55.23076923076923,0.0,28.05
3.0,0.25,train,1907,0.6870476664395908,0.24540115888306765,0.0675511746773416,0.14947099999999987,285.14100000000007,47.165695076621955,136.21428571428572,7.4,44.2
3.0,0.25,test,874,0.7300228310502284,0.20137299771689498,0.06860457123287672,0.17413165331924876,152.17105999999997,30.757461509174445,67.23076923076923,0.0,33.85
3.0,0.3,train,2247,0.6755228749443702,0.25211838005340007,0.07235874500222965,0.14150538050289267,317.86179999999984,48.72024792556527,160.5,8.7,51.3
3.0,0.3,test,1007,0.7200596822244291,0.2065541212512413,0.07338619652432962,0.16644825223435917,167.61340000000004,30.86082606459963,77.46153846153847,0.0,38.9
3.0,0.4,train,2935,0.6593866212203389,0.2612948517940717,0.0793185269855894,0.12829608177343794,376.54900000000004,46.66970879648048,209.64285714285714,8.5,56.1
3.0,0.4,test,1364,0.7007331378299121,0.21334310850439883,0.08592375366568916,0.1490395014662757,203.2898900000001,28.55788193695666,104.92307692307692,0.0,45.45
3.0,0.5,train,4282,0.5745445119103224,0.30313404016814577,0.12232144866153198,0.10393095701074272,445.23679999999823,48.22682282606626,305.85714285714283,10.509999999999766,64.89999999999996
3.0,0.5,test,1938,0.6191434468524252,0.26006192003095974,0.12079463316661507,0.13109896285862777,254.07459000000122,28.63046887878946,149.07692307692307,0.0,55.65000000000001
3.5,0.1,train,506,0.6838932806324111,0.2549407114624506,0.06116600790513834,0.1501461264822133,75.99394999999999,35.37691893584832,36.142857142857146,0.6500000000000001,17.0
3.5,0.1,test,212,0.7688679245283019,0.17924528301886793,0.051886792452830186,0.20125943396226415,42.66700000000001,31.21809055632553,16.307692307692307,0.0,9.649999999999999
3.5,0.15,train,730,0.6931506849315068,0.24383561643835616,0.0630136986301370,0.14863328767123284,108.50230000000001,37.23376780665498,52.142857142857146,1.0999999999999996,22.650000000000002
3.5,0.15,test,321,0.7539252336448598,0.18691588785046728,0.05919003115264798,0.19403894080996888,62.28650000000001,30.50614193310619,24.692307692307693,0.0,14.15
3.5,0.2,train,965,0.6766839378238342,0.2559585492227979,0.0673575129533679,0.13978295336787566,134.89075000000003,37.51867753498587,68.92857142857143,2.45,28.449999999999996
3.5,0.2,test,433,0.7413394919168591,0.1916859122401847,0.06697459584295612,0.18398729561200932,79.67449999999999,31.152155929858927,33.30769230769231,0.0,17.35
3.5,0.25,train,1183,0.66864750211327,0.25948436178359255,0.07186813610313861,0.13308814878274744,157.4653,39.02406652451303,84.5,3.0,32.1
3.5,0.25,test,540,0.7240740740740741,0.2055555555555556,0.0703703703703703,0.1693092592592593,91.42699999999995,30.17426645556965,41.53846153846154,0.0,20.65
3.5,0.3,train,1403,0.6579472558802566,0.26657162509622235,0.07548102902352029,0.1251604918745545,175.6002499999999,40.36200024012649,100.21428571428571,3.2,36.9
3.5,0.3,test,643,0.7107309486780715,0.21151322702764976,0.07775580329427871,0.1608299379782267,103.41364999999993,30.07654633113028,49.46153846153846,0.0,24.7
3.5,0.4,train,1859,0.6541151156536848,0.26250672404519633,0.08337816030111888,0.11750661915007499,218.42080499999992,39.21571055972474,132.78571428571428,3.4000000000000004,40.85
3.5,0.4,test,894,0.6879194630872483,0.22260178970917225,0.08947874720357942,0.1424620805369127,127.36097999999997,28.13915048979823,68.76923076923077,0.0,30.450000000000003
3.5,0.5,train,2749,0.5838486722444525,0.28556202255365586,0.13058930520189159,0.09773527791924328,268.6406799999997,41.119679908355644,196.35714285714286,4.049999999999967,48.549999999999976
3.5,0.5,test,1275,0.6243137254901961,0.2470588235294118,0.1286274509803921,0.13115294117647062,167.22000000000045,28.96024063933889,98.07692307692308,0.0,40.599999999999994
4.0,0.1,train,310,0.680645161290323,0.2645161290322581,0.05483870967741936,0.14443548387096777,44.77499999999999,27.59687295426766,22.142857142857142,0.0,13.4
4.0,0.1,test,132,0.7878787878787878,0.1590909090909091,0.05303030303030303,0.21333333333333335,28.159999999999997,28.79714988809878,10.153846153846153,0.0,7.050000000000001
4.0,0.15,train,453,0.6930022573363431,0.24282560706401768,0.0641721356996394,0.14476269315673298,65.57750000000002,29.18098217168696,32.357142857142854,0.0,18.400000000000006
4.0,0.15,test,198,0.7676767676767676,0.16666666666666666,0.0656565656565657,0.20303030303030303,40.19999999999998,28.56199133968219,15.23076923076923,0.0,10.25
4.0,0.2,train,614,0.6807817589576547,0.2557003257328990,0.0635179153094463,0.13609446254071657,83.5699999999999,31.01858591766282,43.857142857142854,0.0,22.6
4.0,0.2,test,272,0.7536764705882353,0.17647058823529413,0.06985294117647059,0.18825735294117645,51.206,28.653855299440826,20.923076923076923,0.0,12.299999999999999
4.0,0.25,train,766,0.6697127937336815,0.26109660574412534,0.06919060052219321,0.12695143603133159,97.24450000000002,31.99078096619003,54.714285714285715,0.0,26.599999999999994
4.0,0.25,test,352,0.7329545454545454,0.19318181818181818,0.0738636363636364,0.17053409090909086,60.02799999999999,28.89929406426398,27.076923076923077,0.0,14.549999999999999
4.0,0.3,train,911,0.6586168935236004,0.2634467617012074,0.07793634477519209,0.12064984632271108,109.91219999999986,33.32437206971893,65.07142857142857,0.0,30.15
4.0,0.3,test,420,0.7190476190476191,0.20238095238095238,0.07857142857142857,0.15926190476190476,66.89,29.42698119432168,32.30769230769231,0.0,17.95
4.0,0.4,train,1238,0.6526655896607431,0.2617931502422616,0.0855412600969953,0.1109936187398064,137.37809999999982,33.28082422555949,88.42857142857143,0.0,35.8
4.0,0.4,test,594,0.6936026936026936,0.20875420875420875,0.09764309764309764,0.13957239057239052,82.90600000000006,28.23847413666193,45.69230769230769,0.0,22.700000000000003
4.0,0.5,train,1877,0.5920085242408098,0.26851358550878,0.13947789021041023,0.09228237612148099,173.2158000000005,36.042788037626666,134.07142857142858,0.25000000000001243,41.7
4.0,0.5,test,891,0.6261503928170595,0.23232323232323232,0.1415263748597082,0.12476430976430971,111.14200000000038,29.12377697841878,68.53846153846153,0.0,30.35
4.5,0.1,train,216,0.6574074074074074,0.2962962962962963,0.046296296296296294,0.1357175925925926,29.314999999999998,22.18933109063303,15.428571428571429,0.0,11.6
4.5,0.1,test,87,0.7816091954022988,0.16091954022988506,0.057471264367816095,0.2167816091954023,18.860000000000003,27.37168476990648,6.6923076923076925,0.0,4.900000000000001
4.5,0.15,train,317,0.6971608832807571,0.24290220820189273,0.05993690851735015,0.14339116719242904,45.43499999999999,24.47389685050251,22.642857142857142,0.0,15.55
4.5,0.15,test,132,0.7651515151515151,0.16666666666666666,0.06818181818181818,0.2018939393939394,26.64999999999999,27.07082680684376,10.153846153846153,0.0,7.25
4.5,0.2,train,424,0.6768867924528302,0.25943396226415094,0.06367924528301887,0.1316580188679245,55.822999999999986,24.98117085773193,30.285714285714285,0.0,18.0
4.5,0.2,test,179,0.754189944134078,0.17877094972067039,0.06703910614525139,0.19195530726256983,34.36000000000001,27.04896679693285,13.76923076923077,0.0,9.1
4.5,0.25,train,538,0.6691449814126395,0.2602230483271375,0.07063197026022306,0.12282341263940517,66.08699999999996,26.10972073629298,38.42857142857143,0.0,20.05
4.5,0.25,test,237,0.7341772151898734,0.18987341772151898,0.07594936708860759,0.17156118143459917,40.68000000000001,27.42303424839247,18.23076923076923,0.0,11.05
4.5,0.3,train,650,0.653846153846154,0.2676923076923077,0.0784615384615385,0.11684769230769235,75.95100000000001,27.7206605440761,46.42857142857143,0.0,23.15
4.5,0.3,test,297,0.7171717171717171,0.20202020202020202,0.0808080808080808,0.1590707070707071,47.24399999999999,27.98299645166714,22.846153846153847,0.0,13.25
4.5,0.4,train,889,0.6501687288527559,0.2598425196850394,0.0899887514622047,0.10784926882001149,95.87700000000007,28.173619073152105,63.5,0.0,28.450000000000003
4.5,0.4,test,433,0.6974596003696858,0.2078521939953810,0.0946882056349332,0.14217782909930712,61.55100000000001,27.98912393519181,33.30769230769231,0.0,16.65
4.5,0.5,train,1368,0.5877192982456141,0.2660818713450292,0.14619883040935672,0.08704678362573104,119.11199999999996,31.016411050989055,97.71428571428571,0.0,33.1
4.5,0.5,test,673,0.6254086222883735,0.22436848931200595,0.150222488399821,0.12252897474738484,82.44200000000038,29.15912050115682,51.76923076923077,0.0,24.149999999999984
5.0,0.1,train,146,0.6232876712328767,0.3287671232876712,0.0479452054794521,0.11219178082191782,16.380000000000003,16.26889579116313,10.428571428571429,0.0,9.100000000000001
5.0,0.1,test,66,0.7575757575757576,0.1818181818181818,0.0606060606060606,0.20454545454545456,13.5,24.78115167025227,5.076923076923077,0.0,3.75
5.0,0.15,train,220,0.668181818181818,0.2772727272727273,0.054545454545454536,0.13363636363636367,29.399999999999995,18.78098133085649,15.714285714285714,0.0,12.0
5.0,0.15,test,96,0.7395833333333334,0.1875,0.072916666666667,0.19687500000000001,18.900000000000006,24.17691393476152,7.384615384615385,0.0,5.2
5.0,0.2,train,295,0.6576271186440678,0.2779661016949153,0.06440677966101694,0.12474576271186445,36.799999999999976,19.52584085508011,21.071428571428573,0.0,14.55
5.0,0.2,test,136,0.7279411764705882,0.19117647058823528,0.0808823529411765,0.17867647058823534,24.299999999999997,23.85406952095839,10.461538461538462,0.0,6.6
5.0,0.25,train,389,0.6452442159383033,0.2828277634961439,0.07193802056555269,0.11360411311053982,44.19199999999998,20.4773055316656,27.785714285714285,0.0,16.65
5.0,0.25,test,183,0.7049180327868853,0.20218579234972678,0.09289617486338798,0.16371584699453555,29.96000000000001,24.3215456656295,14.076923076923077,0.0,8.35
5.0,0.3,train,470,0.6382978723404255,0.2808510638297872,0.08085106382978723,0.10674468085106389,50.16999999999998,21.58181963556636,33.57142857142857,0.0,19.0
5.0,0.3,test,228,0.6929824561403509,0.2061403508771930,0.10087719298245614,0.15175438596491224,34.59999999999999,24.98426927631946,17.53846153846154,0.0,10.15
5.0,0.4,train,660,0.6333333333333333,0.2727272727272727,0.0939393939393940,0.10119696969696978,66.78999999999999,23.16393889227685,47.142857142857146,0.0,24.049999999999997
5.0,0.4,test,329,0.6838905775075988,0.21276595744680851,0.10334346504559271,0.14051671732522798,46.229999999999976,25.413266003403867,25.307692307692307,0.0,13.049999999999999
5.0,0.5,train,1021,0.5778648383937316,0.2664054848188051,0.15572969678746326,0.08050539667973544,82.19600000000008,26.12689379695755,72.92857142857143,0.0,27.15
5.0,0.5,test,519,0.6127167630057804,0.2254335260115607,0.16185174097665895,0.12023122543352604,62.39000000000001,27.63355339455766,39.923076923076925,0.0,19.75
5.5,0.1,train,115,0.5913043478260869,0.36521739130434783,0.043478260869565216,0.08782608695652174,10.099999999999996,11.88655693972879,8.214285714285714,0.0,8.05
5.5,0.1,test,49,0.7346938775510204,0.20408163265306123,0.061224489795918366,0.19081632653061227,9.35,20.83855687932048,3.769230769230769,0.0,3.1
5.5,0.15,train,169,0.627218934911243,0.3195266272189349,0.05325443786982249,0.1,16.900000000000006,13.6227825831291,12.071428571428571,0.0,9.3
5.5,0.15,test,73,0.7260273972602740,0.19178082191780821,0.08219178082191781,0.18630136986301372,13.6,20.48765098990883,5.615384615384615,0.0,4.4
5.5,0.2,train,229,0.6288209606986899,0.3100436681222707,0.06113537117903930,0.10039301310044,22.989999999999995,14.87556553393549,16.357142857142858,0.0,11.700000000000001
5.5,0.2,test,103,0.7281553398058253,0.18446601941747572,0.08737864077669903,0.17864077669902914,18.4,21.1287584001555,7.923076923076923,0.0,5.5
5.5,0.25,train,304,0.6118421052631579,0.3223684210526316,0.06578947368421052,0.0946710526315789,28.779999999999973,14.87556553393549,21.714285714285715,0.0,14.15
5.5,0.25,test,140,0.7142857142857143,0.2,0.0857142857142857,0.16071428571428573,22.499999999999996,21.36753583282055,10.76923076923077,0.0,6.9
5.5,0.3,train,374,0.6096256684491979,0.31283422459893046,0.0775401069518717,0.09010695187165774,33.70000000000001,16.046131896236706,26.714285714285715,0.0,16.15
5.5,0.3,test,174,0.6954022988505747,0.20689655172413793,0.09770114942528736,0.15086206896551726,26.25,22.18107078825854,13.384615384615385,0.0,8.35
5.5,0.4,train,542,0.6182656826568266,0.28228782287822874,0.09944649446494465,0.09227859778597785,50.01499999999998,19.29133093019896,38.714285714285715,0.0,21.300000000000004
5.5,0.4,test,257,0.6614785992217899,0.22178988326848252,0.11673151750972762,0.13379766536964982,34.385000000000005,23.07668633687606,19.76923076923077,0.0,10.55
5.5,0.5,train,852,0.5704225352112676,0.26760563380281693,0.16197183098591548,0.07552816901408447,64.35000000000002,22.0695889073954,60.857142857142854,0.0,23.00000000000001
5.5,0.5,test,421,0.6009501187648456,0.2161520190023753,0.1828978622327791,0.11463895486935862,48.26299999999997,25.51167687403965,32.38461538461538,0.0,17.35
6.0,0.1,train,85,0.5647058823529412,0.4,0.03529411764705882,0.06529411764705883,5.549999999999998,7.656879655761697,6.071428571428571,0.0,6.65
6.0,0.1,test,41,0.6829268292682927,0.24390243902439024,0.07317073170731707,0.16829268292682928,6.9,15.877497088046695,3.1538461538461537,0.0,2.95
6.0,0.15,train,127,0.5905511811023622,0.3622047244094488,0.0472440944881890,0.08700787401574804,11.049999999999997,9.90068523605688,9.071428571428571,0.0,7.95
6.0,0.15,test,60,0.6666666666666666,0.25,0.08333333333333333,0.16000000000000003,9.599999999999998,15.02295093109737,4.615384615384615,0.0,3.85
6.0,0.2,train,174,0.5862068965517241,0.3620689655172414,0.05172413793103448,0.08793103448275864,15.299999999999997,10.738413668152918,12.428571428571429,0.0,10.0
6.0,0.2,test,84,0.6666666666666666,0.23809523809523808,0.09523809523809523,0.15476190476190477,13.000000000000002,15.40254971612295,6.461538461538462,0.0,5.05
6.0,0.25,train,229,0.5808715596330275,0.35807860262008734,0.0610498034068852,0.08253275109170298,18.899999999999984,10.98115765227618,16.357142857142858,0.0,12.1
6.0,0.25,test,111,0.6576576576576577,0.24324324324324326,0.09909909909909909,0.1387387387387387,15.4,15.604206188016785,8.538461538461538,0.0,6.0
6.0,0.3,train,282,0.5780141843971631,0.35460992907801416,0.06737588652482269,0.07765957446808512,21.9,11.54107979456422,20.142857142857142,0.0,13.750000000000002
6.0,0.3,test,141,0.652482269503546,0.2482269503546099,0.09929078014184398,0.1297163120567376,18.3,16.70430936831109,10.846153846153847,0.0,7.0
6.0,0.4,train,421,0.5914489311163896,0.29453681710213775,0.11401425178147267,0.08193586698337284,34.495000000000005,16.37161078619282,30.071428571428573,0.0,18.0
6.0,0.4,test,210,0.6380952380952381,0.22857142857142856,0.13333333333333333,0.12523809523809529,26.3,20.98695814737428,16.153846153846153,0.0,9.7
6.0,0.5,train,680,0.5529411764705883,0.27205882352941174,0.175,0.0665441176470589,45.250000000000014,18.30377893012266,48.57142857142857,0.0,19.350000000000016
6.0,0.5,test,348,0.5862068965517241,0.21264367816091956,0.2011494252873563,0.10776149425287355,37.500000000000014,23.68595195499315,26.76923076923077,0.0,15.099999999999994
6.5,0.1,train,61,0.524590163934426,0.4426229508196721,0.03278688524590164,0.04016393442622951,2.4499999999999993,4.186413050098779,4.357142857142857,0.0,5.5
6.5,0.1,test,33,0.696969696969697,0.24242424242424243,0.06060606060606061,0.16818181818181818,5.55,14.50195903598679,2.5384615384615383,0.0,2.4
6.5,0.15,train,92,0.5543478260869565,0.40217391304347827,0.0434782608695652,0.06304347826086956,5.800000000000001,6.143684831312078,6.571428571428571,0.0,6.5
6.5,0.15,test,47,0.6808510638297872,0.25531914893617025,0.06382978723404256,0.14893617021276598,6.999999999999999,14.00091133411285,3.6153846153846154,0.0,3.3
6.5,0.2,train,131,0.5648854961832062,0.3893129770992366,0.0458015267175572,0.07328244274809159,9.6,7.693037287668555,9.357142857142858,0.0,8.450000000000001
6.5,0.2,test,69,0.6521739130434783,0.2608695652173913,0.08695652173913043,0.14057971014492757,9.699999999999998,14.47316024989614,5.3076923076923075,0.0,4.35
6.5,0.25,train,174,0.5574712643678161,0.3850574712643678,0.0574712643678161,0.06781609195402298,11.8,8.015078095227566,12.428571428571429,0.0,10.05
6.5,0.25,test,92,0.6630434782608695,0.25,0.08695652173913043,0.14021739130434783,12.899999999999999,14.95614779780073,7.076923076923077,0.0,5.1
6.5,0.3,train,221,0.556561085972850,0.3755656108597285,0.06787330316742083,0.0656108597285068,14.5,8.695413667883287,15.785714285714286,0.0,11.5
6.5,0.3,test,113,0.6460176991150443,0.2566371681415929,0.09734513274336283,0.12787610619469024,14.45,15.49199166665631,8.692307692307692,0.0,5.9
6.5,0.4,train,342,0.5760233918128655,0.29239766081871343,0.13157894736842105,0.07076023391812869,24.200000000000017,13.41591746684447,24.428571428571427,0.0,14.850000000000009
6.5,0.4,test,173,0.6300578034682081,0.23121387283236994,0.1387283236994220,0.11624277456647398,20.11,18.52867149161025,13.307692307692308,0.0,8.1
6.5,0.5,train,565,0.5451327433628318,0.27256637168141593,0.18230088495575222,0.06053097345132746,34.200000000000045,15.85988587455095,40.357142857142854,0.0,17.40000000000001
6.5,0.5,test,291,0.5841924398625429,0.20962199312714776,0.20618556701030927,0.10175257731958759,29.610000000000017,22.23561252877987,22.384615384615383,0.0,13.3
7.0,0.1,train,49,0.4693877551020408,0.48979591836734693,0.0408163265306123,0.0,0.0,0.0,3.5,0.0,4.5
7.0,0.1,test,27,0.6296296296296297,0.2962962962962963,0.07407407407407407,0.12407407407407407,3.35,9.98019440430833,2.076923076923077,0.0,2.1
7.0,0.15,train,71,0.5070422535211268,0.4507042253521127,0.04225352112676057,0.02816901408450703,2.0,2.3308971006994695,5.071428571428571,0.0,5.5
7.0,0.15,test,41,0.6341463414634146,0.2926829268292683,0.07317073170731707,0.12073170731707317,4.95,10.20282315946247,3.1538461538461537,0.0,2.95
7.0,0.2,train,104,0.5096153846153846,0.4423076923076923,0.0480769230769231,0.03221153846153847,3.3499999999999996,3.026809398652604,7.428571428571429,0.0,7.15
7.0,0.2,test,57,0.6140350877192983,0.2982456140350877,0.08771929824561403,0.11140350877192982,6.35,10.34908099700011,4.384615384615385,0.0,3.85
7.0,0.25,train,142,0.5070422535211268,0.43661971830985913,0.05633802816901408,0.02816901408450703,4.0,3.224920992195905,10.142857142857142,0.0,8.65
7.0,0.25,test,76,0.6315789473684211,0.27631578947368424,0.09210526315789473,0.11710526315789472,8.899999999999999,11.366892161779867,5.846153846153846,0.0,4.599999999999999
7.0,0.3,train,183,0.5191256830601093,0.4207650273224044,0.06010928961748633,0.0327868852459016,6.0,3.867282003988078,13.071428571428571,0.0,9.85
7.0,0.3,test,91,0.6263736263736264,0.26373626373626374,0.1098901098901099,0.1114285714285714,10.14,12.084426315025568,7.0,0.0,5.299999999999999
7.0,0.4,train,288,0.5486111111111112,0.2951388888888889,0.15625,0.05,14.4,8.91098102019987,20.571428571428573,0.0,12.700000000000001
7.0,0.4,test,148,0.6081081081081081,0.22972972972972974,0.16216216216216217,0.1020945945945946,15.11,15.99330766003687,11.384615384615385,0.0,7.3
7.0,0.5,train,480,0.525,0.28125,0.19375,0.04875,23.4,11.833915666413627,34.285714285714285,0.0,15.700000000000003
7.0,0.5,test,254,0.5590551181102362,0.21653543307086614,0.22440944881889764,0.08740157480314964,22.200000000000006,19.413152413823627,19.53846153846154,0.0,12.1
7.5,0.1,train,37,0.4594594594594595,0.4864864864864865,0.05405405405405406,0.0,0.0,0.0,2.642857142857143,0.0,3.9
7.5,0.1,test,22,0.5909090909090909,0.36363636363636365,0.04545454545454545,0.09545454545454546,2.1,6.261254068436887,1.6923076923076923,0.0,1.8
7.5,0.15,train,54,0.4814814814814815,0.46296296296296297,0.05555555555555555,0.01666666666666667,0.9,1.4089426282195912,3.8571428571428568,0.0,4.55
7.5,0.15,test,32,0.59375,0.375,0.03125,0.0890625,2.85,6.35889046285426,2.4615384615384617,0.0,2.5
7.5,0.2,train,81,0.4938271604938272,0.4444444444444444,0.061728395061728392,0.02469135802469136,2.0,2.0152227574938683,5.785714285714286,0.0,5.75
7.5,0.2,test,46,0.5652173913043478,0.3695652173913043,0.0652173913043478,0.08152173913043478,3.75,6.251028823992085,3.5384615384615383,0.0,3.3
7.5,0.25,train,110,0.4909090909090909,0.4454545454545455,0.0636363636363636,0.02272727272727272,2.5,2.126656584730135,7.857142857142857,0.0,7.0
7.5,0.25,test,61,0.5737704918032787,0.3606557377049180,0.0655737704918033,0.0901639344262295,5.500000000000001,6.981877737645814,4.6923076923076925,0.0,3.9
7.5,0.3,train,146,0.4931506849315068,0.4315068493150685,0.07534246575342465,0.02568493150684931,3.7499999999999996,2.518698095866149,10.428571428571429,0.0,8.35
7.5,0.3,test,74,0.5945945945945946,0.3378378378378378,0.06756756756756757,0.10472972972972972,7.750000000000001,8.328653892119954,5.6923076923076925,0.0,4.45
7.5,0.4,train,237,0.5232067510548523,0.30379746835443037,0.17299578059071728,0.03860759493670886,9.149999999999999,6.0073972096929,16.928571428571427,0.0,10.750000000000007
7.5,0.4,test,124,0.5887096774193549,0.23387096774193547,0.17741935483870966,0.09895161290322581,12.27,12.933139929096887,9.538461538461538,0.0,6.4
7.5,0.5,train,407,0.5134398782343988,0.28255528255528256,0.20393120393120393,0.04189189189189189,17.050000000000008,9.139619376584086,29.071428571428573,0.0,13.85
7.5,0.5,test,221,0.5384615384615384,0.2172619047619048,0.24434389140271493,0.07557919621749408,16.70299999999999,16.5556809424509,17.0,0.0,10.8
8.0,0.1,train,30,0.43333333333333335,0.5,0.06666666666666667,0.0,0.0,0.0,2.142857142857143,0.0,3.15
8.0,0.1,test,17,0.5882352941176471,0.35294117647058826,0.058823529411764705,0.11176470588235295,1.9,5.72295478621696,1.3076923076923077,0.0,1.5
8.0,0.15,train,43,0.4651162790697674,0.46511627906976744,0.06976744186046512,0.01627906976744186,0.7,1.3180614063478015,3.0714285714285716,0.0,3.7
8.0,0.15,test,25,0.56,0.4,0.04,0.076,1.9,4.91055903497428,1.9230769230769231,0.0,2.0
8.0,0.2,train,65,0.4615384615384615,0.4769230769230769,0.06153846153846154,0.00461538461538462,0.3,0.5296442952527977,4.642857142857143,0.0,4.85
8.0,0.2,test,35,0.5428571428571428,0.4,0.05714285714285714,0.0642857142857143,2.25,4.36893831234618,2.6923076923076925,0.0,2.6
8.0,0.25,train,88,0.46590909090909,0.45454545454545453,0.07954545454545454,0.0034090909090909,0.3,0.4831949698316987,6.285714285714286,0.0,5.8
8.0,0.25,test,49,0.5510204081632653,0.36734693877551017,0.08163265306122448,0.0785714285714286,3.85,5.43377073730788,3.769230769230769,0.0,3.15
8.0,0.3,train,117,0.4615384615384615,0.4529914529914530,0.08547008547008547,0.0,0.0,0.0,8.357142857142858,0.0,6.65
8.0,0.3,test,61,0.5737704918032787,0.34426229508196724,0.08196721311475410,0.09672131147540984,5.9,6.82963817498988,4.6923076923076925,0.0,3.7
8.0,0.4,train,197,0.5025380710659898,0.3096446700507614,0.18781725888324872,0.03350254314720813,6.6,4.800037700174988,14.071428571428571,0.0,9.350000000000003
8.0,0.4,test,104,0.5769230769230769,0.25,0.17307692307692307,0.08942307692307694,9.3,10.60913001089025,8.0,0.0,5.55
8.0,0.5,train,345,0.49855072463768117,0.28115942028985507,0.2202898550724638,0.03565217391304348,12.3,6.943631696682437,24.642857142857142,0.0,12.500000000000002
8.0,0.5,test,191,0.5287958115183246,0.2251308900523560,0.24607329842931937,0.06675392670157069,12.75,13.853259610266034,14.692307692307692,0.0,9.5`;
// Parse CSV
function parseCSV(csv) {
const lines = csv.trim().split('\n');
const headers = lines[0].split(',');
return lines.slice(1).map(line => {
const values = line.split(',');
const obj = {};
headers.forEach((h, i) => {
const v = values[i];
obj[h] = isNaN(v) ? v : parseFloat(v);
});
return obj;
});
}
const data = parseCSV(csvData);
const testData = data.filter(d => d.split === 'test');
const trainData = data.filter(d => d.split === 'train');
// Get unique values
const thresholds = [...new Set(data.map(d => d.cex_ret_threshold_bps))].sort((a,b) => a-b);
const distances = [...new Set(data.map(d => d.distance_filter))].sort((a,b) => a-b);
// Create 2D arrays for heatmaps
function createGrid(data, metric) {
const grid = [];
for (let t of thresholds) {
const row = [];
for (let d of distances) {
const point = data.find(x => x.cex_ret_threshold_bps === t && x.distance_filter === d);
row.push(point ? point[metric] : 0);
}
grid.push(row);
}
return grid;
}
// Find best combos
const bestSharpe = testData.reduce((a, b) => a.sharpe > b.sharpe ? a : b);
const bestPnl = testData.reduce((a, b) => a.total_pnl > b.total_pnl ? a : b);
// Summary
document.getElementById('summary').innerHTML = `
<p><strong>Best TEST Sharpe:</strong> <span class="highlight">${bestSharpe.sharpe.toFixed(2)}</span> @ threshold=${bestSharpe.cex_ret_threshold_bps} bps, distance=${bestSharpe.distance_filter}</p>
<p style="margin-left: 20px;">Trades: ${bestSharpe.trade_count} (${bestSharpe.trades_per_day.toFixed(1)}/day) | Win rate: ${(bestSharpe.win_rate*100).toFixed(1)}% | Avg P&L: $${bestSharpe.avg_pnl.toFixed(4)} | Total: <span class="highlight">$${bestSharpe.total_pnl.toFixed(2)}</span></p>
<p><strong>Best TEST P&L:</strong> <span class="highlight">$${bestPnl.total_pnl.toFixed(2)}</span> @ threshold=${bestPnl.cex_ret_threshold_bps} bps, distance=${bestPnl.distance_filter}</p>
<p style="margin-left: 20px;">Sharpe: ${bestPnl.sharpe.toFixed(2)} | Trades: ${bestPnl.trade_count} (${bestPnl.trades_per_day.toFixed(1)}/day) | Win rate: ${(bestPnl.win_rate*100).toFixed(1)}%</p>
<p class="warn" style="margin-top: 15px;"><strong>Key Insight:</strong> Lower thresholds (1.0-1.5 bps) dominate — more signals = higher total P&L and Sharpe. Win rate improves at higher thresholds but trade count drops significantly.</p>
`;
// 3D Surface
const sharpeGrid = createGrid(testData, 'sharpe');
Plotly.newPlot('surface3d', [{
type: 'surface',
x: distances,
y: thresholds,
z: sharpeGrid,
colorscale: 'Viridis',
colorbar: { title: 'Sharpe' }
}], {
title: 'Test Sharpe by Threshold & Distance',
scene: {
xaxis: { title: 'Distance Filter' },
yaxis: { title: 'Threshold (bps)' },
zaxis: { title: 'Sharpe' }
},
paper_bgcolor: '#0d1117',
plot_bgcolor: '#0d1117',
font: { color: '#c9d1d9' },
margin: { t: 50, b: 30, l: 30, r: 30 }
});
// Heatmap function
function createHeatmap(containerId, metric, title, colorscale = 'Viridis', fmt = '.2f') {
const grid = createGrid(testData, metric);
const annotations = [];
for (let i = 0; i < thresholds.length; i++) {
for (let j = 0; j < distances.length; j++) {
const val = grid[i][j];
let text = '';
if (metric === 'win_rate' || metric === 'lose_rate' || metric === 'flat_rate') {
text = (val * 100).toFixed(1) + '%';
} else if (metric === 'sharpe') {
text = val.toFixed(1);
} else if (metric === 'total_pnl' || metric === 'avg_pnl') {
text = '$' + val.toFixed(metric === 'avg_pnl' ? 3 : 0);
} else {
text = val.toFixed(1);
}
annotations.push({
x: distances[j],
y: thresholds[i],
text: text,
showarrow: false,
font: { color: val > (Math.max(...grid.flat()) * 0.6) ? '#000' : '#fff', size: 10 }
});
}
}
Plotly.newPlot(containerId, [{
type: 'heatmap',
x: distances,
y: thresholds,
z: grid,
colorscale: colorscale,
colorbar: { title: title.split(':')[0] }
}], {
title: title,
xaxis: { title: 'Distance Filter' },
yaxis: { title: 'Threshold (bps)' },
annotations: annotations,
paper_bgcolor: '#0d1117',
plot_bgcolor: '#0d1117',
font: { color: '#c9d1d9' },
margin: { t: 50, b: 50, l: 60, r: 30 }
});
}
createHeatmap('heatmap-sharpe', 'sharpe', 'Test Sharpe');
createHeatmap('heatmap-pnl', 'total_pnl', 'Test Total P&L ($)', 'Greens');
createHeatmap('heatmap-avgpnl', 'avg_pnl', 'Test Avg P&L per Trade ($)', 'Blues');
createHeatmap('heatmap-winrate', 'win_rate', 'Test Win Rate', 'RdYlGn');
createHeatmap('heatmap-trades', 'trades_per_day', 'Test Trades/Day', 'Oranges');
createHeatmap('heatmap-flatrate', 'flat_rate', 'Test Flat Rate', 'Purples');
// Results table
let tableHtml = '<table><thead><tr>';
tableHtml += '<th>Thresh</th><th>Dist</th><th>Trades</th><th>Win%</th><th>Flat%</th><th>Avg P&L</th><th>Total P&L</th><th>Sharpe</th><th>Trades/Day</th>';
tableHtml += '</tr></thead><tbody>';
testData.sort((a, b) => b.sharpe - a.sharpe).forEach(r => {
const isBest = r === bestSharpe;
tableHtml += `<tr style="${isBest ? 'background: #1f6feb33;' : ''}">
<td>${r.cex_ret_threshold_bps}</td>
<td>${r.distance_filter}</td>
<td>${r.trade_count}</td>
<td>${(r.win_rate * 100).toFixed(1)}%</td>
<td>${(r.flat_rate * 100).toFixed(1)}%</td>
<td>$${r.avg_pnl.toFixed(4)}</td>
<td>$${r.total_pnl.toFixed(2)}</td>
<td style="color: ${r.sharpe > 25 ? '#7ee787' : '#c9d1d9'};">${r.sharpe.toFixed(2)}</td>
<td>${r.trades_per_day.toFixed(1)}</td>
</tr>`;
});
tableHtml += '</tbody></table>';
document.getElementById('results-table').innerHTML = tableHtml;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment