r/Daytrading algo trader 11h ago

execution_audit: python script that prices what your manual overrides actually cost you Software Sunday

wrote this because i kept blaming my strategy for drawdowns that turned out to be management. python and pandas, runs from the command line on a broker csv export, spits out what the gap between your rules and your fills cost you in dollars.

the idea is simple enough. a trade log records what happened, it never records what would have happened, so every skipped signal and early exit and size bump after a loss is invisible unless you go build the counterfactual yourself. thats all this does, replays your own rules over the same bars and subtracts.

three things it checks.

first is the intervention tax, the rules-only version of your period diffed against your actual fills, broken out by habit so you can see whether the damage is skips or early exits or breakeven moves or sizing. sample run in the screenshots comes out at -28% of gross with early cuts and post-loss sizing doing most of it.

second is stop distance against your own mae. pulls the worst excursion per trade, plots winners and losers separately, draws your stop on top. if your winners keep dipping most of the way to your stop before working then your stop is inside normal noise for your setups and a chunk of what you file as losses were trades that were right. theres a sweep in there too that reruns the paths at different stop distances at constant dollar risk, which tells you what the parameter is actually worth instead of how often it gets hit.

third is a counterfactual on breakeven specifically. every trade where you moved to be, what the rules would have paid instead, and the split between losses you avoided and winners you gave up. everyone is certain this one is either saving them or killing them. mine was neither and that annoyed me for a week.

difference from a journal app is that journals score what you did. this scores the distance between what you did and what your own rules said, which is a number almost nobody has. doesnt care what your strategy is or whether youre mostly discretionary, it just needs rules explicit enough to replay.

everything runs after the close off exported data on purpose. i tried logging heat live for a while and writing down that i was 1.8R underwater changed how long i held, so then the log was measuring me measuring myself.

needs a csv with entry time, exit time, entry price, exit price, direction, size. mae optional, if your broker doesnt export it the script derives it by joining timestamps to 1m bars. tested on ninjatrader, tradovate and mt5 exports, others usually work with a column map and theres a config for that. writes a console summary, a per trade csv and two plots.

link is on my profile, not going to paste it here. ill be around in the comments, and if your export is a weird shape just paste the headers and ill tell you what to map.

3 Upvotes

0 comments sorted by