My paper trading book has 165 closed trades in it. Split down the middle by date, it looks like two different strategies:
| Trades | Net | Price leg | Funding leg | Win rate | |
|---|---|---|---|---|---|
| First half | 89 | +525.21 | −94.82 | +651.82 | 39.3% |
| Second half | 76 | −393.85 | −695.62 | +331.83 | 28.9% |
Same code. Same parameters. Same exchange. The only thing that changed is the market it was trading in.
The obvious move is to add a filter. Find the trades that lost money in the second half, find a property they share, and refuse to take those. I had a whole list of candidates, and four of them looked great on the full history.
That last sentence is the problem. Here's how I test them now, and why four of the five got thrown away.
The part of the P&L that actually broke
The strategy is funding-rate carry: collect the funding payment, eat the price move as the cost. Two revenue legs, and they degraded in opposite directions.
The funding leg halved (+651 → +332). The price leg got 7x worse (−95 → −696). Meanwhile the average entry rate actually rose, from 0.446% to 0.555% per interval.
So the signal I select trades on got stronger while the book got worse. Every filter that looks at the rate, the rate band, or the composite score is optimising the leg that didn't break. That's the first thing I should have noticed, and I didn't — I went and wrote the filters anyway.
The filter that looked best and was the worst
Candidate #1: drop entries where the stability score is below 6. Rationale: unstable rates mean the funding flips and you pay instead of collect.
On the full 165 trades it improved the book by +215. That's a big number for a one-line filter, and if I had stopped there, I'd have shipped it.
Then I computed the same delta on each half separately:
| Filter | First half Δ | Second half Δ | Full history Δ |
|---|---|---|---|
| Stability score < 6 | +442 | −227 | +215 |
| Half size on rate > 1.5% | −115 | +61 | −54 |
| Coin cooldown after a loss | +3.07 | +0.00 | +3.07 |
| Rate cap (tested earlier) | fail | fail | fail |
| No entries for N hours after a forced close | +80.51 | +321.70 | +402.21 |
Look at row one. It's the best filter on the total and it is catastrophic in the half I'm actually worried about. It removes trades that were profitable in the calm regime and keeps the ones that bled in the bad one — because stability score measures the last 24 rate samples, and in a trending market the score stays high right up until it doesn't.
The other two rows are the same disease in milder form. Half-sizing high rates helps only in the second half (−115 in the first). The cooldown is +3 dollars, which is noise wearing a feature's clothes.
Aggregate deltas hide sign flips. A filter that helps one half and hurts the other isn't a filter, it's a bet on which half comes next.
The test I run now
Twenty lines, no library, and it has rejected more ideas than any backtest framework I've used:
def halves(trades, split):
first = [t for t in trades if t.closed_at < split]
second = [t for t in trades if t.closed_at >= split]
return first, second
def evaluate(trades, split, exclude):
"""Delta from dropping every trade where exclude(t) is True, per half."""
out = {}
for name, part in zip(("H1", "H2"), halves(trades, split)):
base = sum(t.pnl for t in part)
kept = sum(t.pnl for t in part if not exclude(t))
out[name] = kept - base
out["total"] = out["H1"] + out["H2"]
return out
def ships(result):
return min(result["H1"], result["H2"]) > 0 # both halves, not the average
min(...) > 0 instead of total > 0. That single change threw out four of five candidates. It's a blunt rule and it will reject some genuinely useful edges, but every filter I've shipped on the strength of an aggregate number has come back to charge me later.
What survived, and why it's not a threshold
The one row that passes both halves isn't a parameter. It's a mechanism: don't open new positions for a while after a forced liquidation.
That's not a tuned number, it's an accounting fact. When the drawdown breaker fires, it closes a position at a loss because price moved against it. The entry signal that opened that position is still firing — the funding rate is still attractive, that's why it was opened. So the next scan happily re-enters the same contract into the same move, sometimes within the hour, and pays the spread again.
Sweeping the lockout length:
| Lockout | First half Δ | Second half Δ | Total Δ |
|---|---|---|---|
| 24h | +0.00 | +0.00 | +0.00 |
| 48h | +33.05 | +170.27 | +203.32 |
| 72h | +80.51 | +321.70 | +402.21 |
| 120h | +36.84 | +310.21 | +347.05 |
Both halves positive at every step past 24h, peak at 72h, and it decays rather than climbing monotonically — that's a plateau, not a fitted spike. If 72h were an overfit you'd expect the curve to keep improving as you push further, or to collapse immediately on either side. It does neither.
The honest limit on that +402
I excluded 49 trades. Their exit reasons break down like this:
| Exit reason | Trades | P&L |
|---|---|---|
| Loss carry | 19 | −165.69 |
| Rotation | 12 | −23.57 |
| Defensive | 11 | −69.59 |
| Emergency close | 7 | −143.37 |
| Total | 49 | −402.22 |
Every one of them is a loser. That's exactly what the exclusion is defined to remove, so the number is circular in a way that's easy to forget: −402.22 is arithmetic, +402.21 is an upper bound, not a forecast.
Two reasons it overstates the gain:
- Empty slots aren't refilled. The real book would have opened something else in that time, and that something could be worse.
- Post-lockout re-entry. After 72h the same contract can be entered again at completely different prices and rates. The simulation can't see that trade because it doesn't exist yet.
What the number does support is much narrower and much more useful: that specific class of trade — immediately re-buying what the breaker just closed — was a pure loss, in both regimes, by a wide margin. I don't need a forecast to justify not doing that.
Verifying it against the real code, not the spreadsheet
A simulation that lives in its own file can be wrong in the same direction as the idea it's testing. So the last step is a reproduction gate: run the exact production entry logic over the same trade ledger with the lockout on, and require the trade count and total to match the simulation to the cent.
It matched: 49 trades, −402.21. Then the live scan log printed the gate itself —
⏸️ No entries — re-entry lock active after emergency close, 43.6h remaining
— with the positions still being managed, which was the actual point. My first instinct was to implement the lockout through the existing whole-scan cooldown, which returns early and leaves open positions unattended for up to three days. Entry-only gating was the entire difference between a safety feature and a new way to lose money.
What I'd tell myself in September
- Report deltas per half, never just in total. A filter is a claim about the future, and one half is a sample of a different future.
- Decompose the P&L before you filter it. I spent a day writing rate-based filters for a book whose funding leg was fine.
- Prefer mechanisms to thresholds. "Don't re-enter what just got stopped out" is true by construction. "Don't enter below stability 6" is true in the data I happened to collect.
- Say the bound out loud. +402 is an upper bound. Written down, it stops being a number I quietly start believing.
The lockout doesn't turn the book positive. It removes a category of self-inflicted loss and it'll save me a few hundred dollars a quarter. That's the honest size of the win — and the four filters I deleted were worth more than the one I kept, because they taught me to split the data before I believe anything.
If you've got a rule in production that only looks good in aggregate, split it. It takes twenty lines and it stings in exactly the right place.
Top comments (0)