v8.8.0 — TWR metrics, broker balance tracker, stop orders
This release adds three major capabilities plus a number of supporting
improvements.
✨ Highlights
Time-Weighted Return (TWR) metrics
TWR variants for CAGR, Sharpe, volatility, returns, drawdown, and
equity curve. All TWR metrics consume snapshot.cash_flow to scrub
external deposits/withdrawals from performance, giving a true
alpha-only view of the strategy.
New BacktestMetrics fields:
twr_equity_curvetwr_drawdown_seriestwr_max_drawdowntwr_max_drawdown_duration
The HTML backtest dashboard surfaces these as a dashed alpha-only
overlay on the equity and drawdown charts.
Broker balance tracker + Context.sync_portfolio()
- New
BrokerBalanceTrackerfor managing scheduled deposits/withdrawals Context.sync_portfolio()reconciles local portfolio state against
the broker and records cash flows on every sync event- Cash flows are now first-class so they can be subtracted from
performance metrics (TWR) - New docs page: Advanced Concepts → Portfolio sync
Stop and stop-limit orders
StopOrderTypeenum + validationOrdermodel gainsstop_price/limit_pricefields- CCXT executor maps to exchange-native stop orders
- Backtest order service simulates trigger conditions per bar
Vector backtest scheduled deposits
The vector engine now honours BrokerBalanceTracker schedules so
DCA-style accumulation strategies can be backtested with realistic
external cash flows.
Authenticated external data (#529)
Optional headers parameter on Context.fetch_csv / fetch_json /
fetch_parquet and on DataSource.from_csv / from_json /
from_parquet. Cache keys are separated per credential and header
values are redacted ("***") in DataSource.to_dict() so secrets
don't leak into diagnostic payloads.
📚 Examples
examples/strategies_showcase/— 26 reference strategiesexamples/advanced_tutorials/cross-sectional-pipelines/examples/rust_vs_python_benchmark/
🔄 Compatibility
BacktestMetricsadds new fields with defaults —from_dict()is
forward/backward compatible (unknown keys are dropped, missing keys
default).- Backtest fixtures under
tests/resources/backtest_reports_for_testing/were regenerated to
include the newtwr_*fields.
✅ Test status
1668 passed, 42 skipped.
Full Changelog: v8.7.3...v8.8.0