Skip to content

feat(backtest): add bid/ask-aware fills and transaction cost overlays#24

Merged
davison merged 1 commit intomainfrom
feature/rad-45-bid-ask-fills
Mar 26, 2026
Merged

feat(backtest): add bid/ask-aware fills and transaction cost overlays#24
davison merged 1 commit intomainfrom
feature/rad-45-bid-ask-fills

Conversation

@radiusred-cody
Copy link
Copy Markdown

Summary

Implements bid/ask-aware fill pricing in the backtest engine (RAD-45).

  • BacktestClient fills BUY at ask, SELL at bid using Dukascopy paired ask candle data
  • TransactionCosts dataclass added with slippage and commission fields — all default zero for backward compatibility
  • BacktestStreamer injects _AskPriceUpdate sentinels so ask price is current at each fill timestamp
  • TradeRecord + PositionClosedEvent gain cost breakdown fields (all default 0.0)
  • TradeLedger writes cost columns to trades.csv and round_trips.csv
  • Warning logged when ask series is registered but ask price is missing at fill timestamp

Test plan

  • 10 new unit tests in tests/execution/backtest/test_bid_ask_fills.py
  • All 586 tradedesk tests pass (mypy strict ✓, ruff ✓)
  • Backward compat verified: backtests without ask data produce identical results

QA

Approved by Testy after veto-fix squash. Relates to RAD-45.

🤖 Generated with Claude Code

- BacktestClient fills BUY at ask, SELL at bid using Dukascopy ask candle data
- TransactionCosts dataclass added (slippage_points, slippage_bps, commission_per_fill,
  commission_per_round_trip) — all default zero for backward compatibility
- BacktestStreamer injects _AskPriceUpdate sentinels so ask price is current at each fill
- TradeRecord + PositionClosedEvent gain cost fields (all default 0.0)
- TradeLedger: trades.csv and round_trips.csv include cost columns
- Warning logged when ask series registered but ask price missing at fill timestamp

Co-Authored-By: Paperclip <[email protected]>
@davison davison merged commit 57dfb38 into main Mar 26, 2026
5 checks passed
@davison davison deleted the feature/rad-45-bid-ask-fills branch March 26, 2026 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant