Skip to content

Instantly share code, notes, and snippets.

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

  • Save yongkangc/6622bff9acf5817944648f6a8837cccf to your computer and use it in GitHub Desktop.

Select an option

Save yongkangc/6622bff9acf5817944648f6a8837cccf to your computer and use it in GitHub Desktop.
CexLead Exit Horizon Sweep — ETH 15m — 400ms to 5000ms (3bps/d≤0.20)
<!DOCTYPE html>
<html>
<head>
<title>CexLead Exit Horizon Sweep — ETH 15m</title>
<script src="https://cdn.plot.ly/plotly-2.27.0.min.js"></script>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
background: #0d1117;
color: #c9d1d9;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
padding: 20px;
}
h1 {
color: #f0f6fc;
margin-bottom: 5px;
font-size: 24px;
}
.subtitle {
color: #8b949e;
margin-bottom: 20px;
font-size: 14px;
}
.summary {
background: #161b22;
border: 1px solid #30363d;
border-radius: 8px;
padding: 16px;
margin-bottom: 20px;
font-size: 14px;
line-height: 1.6;
}
.summary .highlight {
color: #58a6ff;
font-weight: bold;
}
.chart-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
margin-bottom: 24px;
}
.chart-container {
background: #161b22;
border: 1px solid #30363d;
border-radius: 8px;
padding: 8px;
}
.chart-full {
grid-column: 1 / -1;
}
table {
width: 100%;
border-collapse: collapse;
font-size: 13px;
background: #161b22;
border-radius: 8px;
overflow: hidden;
}
th {
background: #21262d;
color: #f0f6fc;
padding: 10px 12px;
text-align: right;
border-bottom: 1px solid #30363d;
}
th:first-child { text-align: left; }
td {
padding: 8px 12px;
text-align: right;
border-bottom: 1px solid #21262d;
}
td:first-child { text-align: left; }
tr:hover { background: #1c2128; }
.table-container {
border: 1px solid #30363d;
border-radius: 8px;
overflow: hidden;
}
</style>
</head>
<body>
<h1>⚡ CexLead Exit Horizon Sweep — ETH 15m</h1>
<div class="subtitle">
Fixed: 3.0 bps threshold | dist ≤ 0.20 | 200ms lookback | Sweep: forward_horizon 400ms–5000ms<br>
Train: Feb 5–18 (14d) | Test: Feb 19–Mar 3 (13d)
</div>
<div class="summary">
<strong>Key Findings:</strong><br>
📈 Test Sharpe peaks at <span class="highlight">5000ms = 35.56</span>
(Train peak: 600ms = 60.25)<br>
💰 Test total P&L peaks at <span class="highlight">3000ms = $700.39</span>
(more trades at shorter horizons offset lower avg P&L)<br>
📊 Flat rate at 400ms: <span class="highlight">14.6%</span> → drops to 5.9% at 5000ms<br>
🔍 Edge does NOT decay up to 5s — avg P&L per trade increases monotonically. Longer horizons = fewer trades but higher quality.
</div>
<div class="chart-grid">
<div class="chart-container chart-full">
<div id="chart-sharpe"></div>
</div>
<div class="chart-container">
<div id="chart-avgpnl"></div>
</div>
<div class="chart-container">
<div id="chart-winrate"></div>
</div>
<div class="chart-container">
<div id="chart-flatrate"></div>
</div>
<div class="chart-container">
<div id="chart-totalpnl"></div>
</div>
<div class="chart-container chart-full">
<div id="chart-tradesperday"></div>
</div>
</div>
<h2 style="color: #f0f6fc; margin-bottom: 12px; font-size: 18px;">Full Results Table</h2>
<div class="table-container">
<table>
<thead>
<tr>
<th style="text-align:left">Horizon (ms)</th>
<th>Period</th>
<th>Trades</th>
<th>Win %</th>
<th>Lose %</th>
<th>Flat %</th>
<th>Avg P&L</th>
<th>Total P&L</th>
<th>Sharpe</th>
<th>Trades/Day</th>
</tr>
</thead>
<tbody>
<tr>
<td>400</td>
<td>test</td>
<td>5330</td>
<td>46.5%</td>
<td>38.9%</td>
<td>14.6%</td>
<td>$0.0567</td>
<td>$302.38</td>
<td>31.77</td>
<td>444.2</td>
</tr><tr>
<td>500</td>
<td>test</td>
<td>5236</td>
<td>51.7%</td>
<td>34.8%</td>
<td>13.5%</td>
<td>$0.0782</td>
<td>$409.62</td>
<td>32.32</td>
<td>436.3</td>
</tr><tr>
<td>600</td>
<td>test</td>
<td>5137</td>
<td>54.8%</td>
<td>32.4%</td>
<td>12.8%</td>
<td>$0.0902</td>
<td>$463.33</td>
<td>31.99</td>
<td>428.1</td>
</tr><tr>
<td>700</td>
<td>test</td>
<td>5049</td>
<td>57.5%</td>
<td>30.6%</td>
<td>11.9%</td>
<td>$0.1012</td>
<td>$510.79</td>
<td>32.21</td>
<td>420.8</td>
</tr><tr>
<td>800</td>
<td>test</td>
<td>4978</td>
<td>59.9%</td>
<td>28.9%</td>
<td>11.1%</td>
<td>$0.1094</td>
<td>$544.62</td>
<td>32.79</td>
<td>414.8</td>
</tr><tr>
<td>900</td>
<td>test</td>
<td>4919</td>
<td>61.3%</td>
<td>27.8%</td>
<td>10.9%</td>
<td>$0.1158</td>
<td>$569.75</td>
<td>32.99</td>
<td>409.9</td>
</tr><tr>
<td>1000</td>
<td>test</td>
<td>4856</td>
<td>62.1%</td>
<td>27.4%</td>
<td>10.4%</td>
<td>$0.1203</td>
<td>$584.01</td>
<td>32.63</td>
<td>404.7</td>
</tr><tr>
<td>2000</td>
<td>test</td>
<td>4473</td>
<td>66.3%</td>
<td>25.4%</td>
<td>8.4%</td>
<td>$0.1445</td>
<td>$646.52</td>
<td>33.44</td>
<td>372.8</td>
</tr><tr>
<td>3000</td>
<td>test</td>
<td>4233</td>
<td>68.1%</td>
<td>24.1%</td>
<td>7.7%</td>
<td>$0.1655</td>
<td>$700.39</td>
<td>33.57</td>
<td>352.8</td>
</tr><tr>
<td>4000</td>
<td>test</td>
<td>4037</td>
<td>68.1%</td>
<td>25.4%</td>
<td>6.5%</td>
<td>$0.1717</td>
<td>$693.20</td>
<td>34.82</td>
<td>336.4</td>
</tr><tr>
<td>5000</td>
<td>test</td>
<td>3897</td>
<td>67.8%</td>
<td>26.3%</td>
<td>5.9%</td>
<td>$0.1760</td>
<td>$686.02</td>
<td>35.56</td>
<td>324.8</td>
</tr><tr>
<td>400</td>
<td>train</td>
<td>17799</td>
<td>27.2%</td>
<td>52.7%</td>
<td>20.1%</td>
<td>$-0.0061</td>
<td>$-108.55</td>
<td>-4.36</td>
<td>1271.4</td>
</tr><tr>
<td>500</td>
<td>train</td>
<td>16987</td>
<td>35.0%</td>
<td>44.2%</td>
<td>20.8%</td>
<td>$0.0117</td>
<td>$199.54</td>
<td>15.14</td>
<td>1213.4</td>
</tr><tr>
<td>600</td>
<td>train</td>
<td>16299</td>
<td>44.4%</td>
<td>35.6%</td>
<td>20.1%</td>
<td>$0.0383</td>
<td>$624.92</td>
<td>60.25</td>
<td>1164.2</td>
</tr><tr>
<td>700</td>
<td>train</td>
<td>15726</td>
<td>50.6%</td>
<td>30.0%</td>
<td>19.4%</td>
<td>$0.0577</td>
<td>$908.15</td>
<td>51.28</td>
<td>1123.3</td>
</tr><tr>
<td>800</td>
<td>train</td>
<td>15266</td>
<td>54.9%</td>
<td>26.7%</td>
<td>18.4%</td>
<td>$0.0722</td>
<td>$1102.38</td>
<td>43.60</td>
<td>1090.4</td>
</tr><tr>
<td>900</td>
<td>train</td>
<td>14927</td>
<td>58.1%</td>
<td>24.4%</td>
<td>17.4%</td>
<td>$0.0820</td>
<td>$1224.36</td>
<td>40.42</td>
<td>1066.2</td>
</tr><tr>
<td>1000</td>
<td>train</td>
<td>14604</td>
<td>60.4%</td>
<td>22.8%</td>
<td>16.8%</td>
<td>$0.0892</td>
<td>$1302.52</td>
<td>37.82</td>
<td>1043.1</td>
</tr><tr>
<td>2000</td>
<td>train</td>
<td>12333</td>
<td>67.5%</td>
<td>20.4%</td>
<td>12.1%</td>
<td>$0.1221</td>
<td>$1505.31</td>
<td>33.32</td>
<td>880.9</td>
</tr><tr>
<td>3000</td>
<td>train</td>
<td>11096</td>
<td>68.2%</td>
<td>21.8%</td>
<td>10.0%</td>
<td>$0.1359</td>
<td>$1507.78</td>
<td>33.56</td>
<td>792.6</td>
</tr><tr>
<td>4000</td>
<td>train</td>
<td>10223</td>
<td>68.2%</td>
<td>22.9%</td>
<td>8.9%</td>
<td>$0.1445</td>
<td>$1476.96</td>
<td>34.57</td>
<td>730.2</td>
</tr><tr>
<td>5000</td>
<td>train</td>
<td>9551</td>
<td>67.2%</td>
<td>24.4%</td>
<td>8.3%</td>
<td>$0.1457</td>
<td>$1391.37</td>
<td>37.80</td>
<td>682.2</td>
</tr>
</tbody>
</table>
</div>
<script>
const layout_base = {
paper_bgcolor: '#161b22',
plot_bgcolor: '#0d1117',
font: { color: '#c9d1d9', size: 12 },
legend: { x: 0.02, y: 0.98, bgcolor: 'rgba(22,27,34,0.8)', bordercolor: '#30363d', borderwidth: 1 },
xaxis: {
title: 'Exit Horizon (ms)',
gridcolor: '#21262d',
zerolinecolor: '#30363d',
tickvals: [400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000]
},
yaxis: { gridcolor: '#21262d', zerolinecolor: '#30363d' },
margin: { l: 60, r: 20, t: 40, b: 50 },
hovermode: 'x unified'
};
// Sharpe
Plotly.newPlot('chart-sharpe', [
{
x: [400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000],
y: [-4.359017168800899, 15.144516445811927, 60.24948318601022, 51.27507398524947, 43.60356589286634, 40.41828995952227, 37.81834009579262, 33.322450835757934, 33.55946430227118, 34.56870622580876, 37.79874319705775],
name: 'Train',
type: 'scatter',
mode: 'lines+markers',
line: {color: '#636EFA', width: 2},
marker: {size: 6}
},
{
x: [400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000],
y: [31.765519445023823, 32.31865684345708, 31.98562547945588, 32.20805232112774, 32.78637436914834, 32.99439918437492, 32.63349403430381, 33.438304961549214, 33.56909307912826, 34.8188045379092, 35.55663368736387],
name: 'Test',
type: 'scatter',
mode: 'lines+markers',
line: {color: '#EF553B', width: 2},
marker: {size: 6}
}
], {
...layout_base,
title: { text: 'Sharpe Ratio (√365) vs Exit Horizon', font: { size: 16, color: '#f0f6fc' } },
yaxis: { ...layout_base.yaxis, title: 'Sharpe' },
height: 400
});
// Avg P&L
Plotly.newPlot('chart-avgpnl', [
{
x: [400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000],
y: [-0.0060989381425922, 0.0117469241184435, 0.0383410025154917, 0.0577486328373394, 0.0722114502816717, 0.0820231794734374, 0.0891889208436044, 0.1220550555420416, 0.1358845529920692, 0.1444742247872444, 0.1456779394827766],
name: 'Train',
type: 'scatter',
mode: 'lines+markers',
line: {color: '#636EFA', width: 2},
marker: {size: 6}
},
{
x: [400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000],
y: [0.0567317073170731, 0.0782324293353705, 0.0901946661475569, 0.1011655773420479, 0.1094063881076737, 0.115827403943891, 0.1202666803953871, 0.1445394589760787, 0.1654594849988188, 0.1717116670795145, 0.1760392609699769],
name: 'Test',
type: 'scatter',
mode: 'lines+markers',
line: {color: '#EF553B', width: 2},
marker: {size: 6}
}
], {
...layout_base,
title: { text: 'Avg P&L per Trade ($)', font: { size: 14, color: '#f0f6fc' } },
yaxis: { ...layout_base.yaxis, title: 'Avg P&L ($)' },
height: 320
});
// Win Rate
Plotly.newPlot('chart-winrate', [
{
x: [400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000],
y: [27.198157199842687, 34.962029787484546, 44.36468494999693, 50.59773623298995, 54.92597930040613, 58.13626314731695, 60.41495480690222, 67.45317441011919, 68.24981975486662, 68.23828621735302, 67.2495026698775],
name: 'Train',
type: 'scatter',
mode: 'lines+markers',
line: {color: '#636EFA', width: 2},
marker: {size: 6}
},
{
x: [400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000],
y: [46.510318949343336, 51.69977081741788, 54.77905392252287, 57.4965339671222, 59.92366412213741, 61.2726163854442, 62.1499176276771, 66.26425217974514, 68.10772501771794, 68.09512013871687, 67.8470618424429],
name: 'Test',
type: 'scatter',
mode: 'lines+markers',
line: {color: '#EF553B', width: 2},
marker: {size: 6}
}
], {
...layout_base,
title: { text: 'Win Rate (%)', font: { size: 14, color: '#f0f6fc' } },
yaxis: { ...layout_base.yaxis, title: 'Win Rate (%)' },
height: 320
});
// Flat Rate
Plotly.newPlot('chart-flatrate', [
{
x: [400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000],
y: [20.085398056070566, 20.815918054983225, 20.07485121786613, 19.36919750731273, 18.35451329752391, 17.418101426944464, 16.78992056970693, 12.113840914619315, 9.99459264599856, 8.852587303139979, 8.344675950162287],
name: 'Train',
type: 'scatter',
mode: 'lines+markers',
line: {color: '#636EFA', width: 2},
marker: {size: 6}
},
{
x: [400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000],
y: [14.559099437148218, 13.521772345301756, 12.828499124002334, 11.863735393147158, 11.128967456809963, 10.937182354137018, 10.440691927512356, 8.361278783813995, 7.7486416253248285, 6.4899677978697055, 5.876315114190403],
name: 'Test',
type: 'scatter',
mode: 'lines+markers',
line: {color: '#EF553B', width: 2},
marker: {size: 6}
}
], {
...layout_base,
title: { text: 'Flat Rate (%) — OB unchanged', font: { size: 14, color: '#f0f6fc' } },
yaxis: { ...layout_base.yaxis, title: 'Flat Rate (%)' },
height: 320
});
// Total P&L
Plotly.newPlot('chart-totalpnl', [
{
x: [400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000],
y: [-108.55499999999998, 199.545, 624.92, 908.155, 1102.38, 1224.36, 1302.515, 1505.305, 1507.775, 1476.96, 1391.37],
name: 'Train',
type: 'scatter',
mode: 'lines+markers',
line: {color: '#636EFA', width: 2},
marker: {size: 6}
},
{
x: [400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000],
y: [302.38, 409.625, 463.33, 510.785, 544.625, 569.755, 584.015, 646.525, 700.39, 693.2, 686.025],
name: 'Test',
type: 'scatter',
mode: 'lines+markers',
line: {color: '#EF553B', width: 2},
marker: {size: 6}
}
], {
...layout_base,
title: { text: 'Total P&L ($)', font: { size: 14, color: '#f0f6fc' } },
yaxis: { ...layout_base.yaxis, title: 'Total P&L ($)' },
height: 320
});
// Trades per Day
Plotly.newPlot('chart-tradesperday', [
{
x: [400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000],
y: [1271.357142857143, 1213.357142857143, 1164.2142857142858, 1123.2857142857142, 1090.428571428571, 1066.2142857142858, 1043.142857142857, 880.9285714285714, 792.5714285714286, 730.2142857142857, 682.2142857142857],
name: 'Train',
type: 'scatter',
mode: 'lines+markers',
line: {color: '#636EFA', width: 2},
marker: {size: 6}
},
{
x: [400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000],
y: [444.1666666666667, 436.3333333333333, 428.0833333333333, 420.75, 414.8333333333333, 409.9166666666667, 404.6666666666667, 372.75, 352.75, 336.4166666666667, 324.75],
name: 'Test',
type: 'scatter',
mode: 'lines+markers',
line: {color: '#EF553B', width: 2},
marker: {size: 6}
}
], {
...layout_base,
title: { text: 'Trades per Day', font: { size: 14, color: '#f0f6fc' } },
yaxis: { ...layout_base.yaxis, title: 'Trades/Day' },
height: 350
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment