Backtest slippage modeling + offline point-in-time LLM signal eval#2
Open
biswajeetdev wants to merge 1 commit into
Open
Backtest slippage modeling + offline point-in-time LLM signal eval#2biswajeetdev wants to merge 1 commit into
biswajeetdev wants to merge 1 commit into
Conversation
backtest.py: model adverse slippage (0.05%/side, override via params[slippage]) at all fill points — buys fill higher, sells/stops/targets/EOD lower. Surface commission+slippage in the run header. Backtests were commission-only and thus optimistic on net fills. eval_llm.py (new): offline harness that replays historical as-of dates, rebuilds point-in-time price/technical indicators, calls the real debate_decide brain, and scores each call against realized forward returns (per-action avg return, directional hit-rate, BUY edge vs baseline). The LLM debate layer was previously validated only by live online loops. Includes a look-ahead-bias guard (--anonymize) and feeds only reconstructable context (live-only alt-data passed empty).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two improvements surfaced from a review of the trading bot against current open-source LLM-trading practice:
1. Slippage modeling in
backtest.pyBacktests were commission-only (0.05%/side), so net fills were optimistic. Adds a configurable
SLIPPAGE(0.05%/side, override viaparams["slippage"]) applied adversely at every fill point — BUY entries fill higher; SELL/STOP/TARGET/EOD exits fill lower. Commission + slippage are now printed in the run header.2.
eval_llm.py— offline point-in-time eval of the LLM debate brain (new)The rule layer is validated by
backtest.py/god_mode.py, but the LLM debate layer (signals/debate_brain.py) — the bot's claimed source of alpha — was previously scored only by live online loops (rag/strategy_evolver,self_improver). This harness gives it an offline test:debate_decidebrain.--anonymizemasks the ticker so the model can't recall a known stock's trajectory (cf. arXiv 2510.07920 Profit Mirage, 2601.13770 Look-Ahead-Bench); warns about pre-cutoff memorization.Verification
eval_llm.py: end-to-end smoke test (NVDA, 2 as-of dates) ran clean — point-in-time indicators → real brain → forward-return scoring → report.Not included (follow-ups)
🤖 Generated with Claude Code