Skip to content

v8.8.0

Latest

Choose a tag to compare

@MDUYN MDUYN released this 09 May 19:38
0dbd880

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_curve
  • twr_drawdown_series
  • twr_max_drawdown
  • twr_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 BrokerBalanceTracker for 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

  • StopOrderType enum + validation
  • Order model gains stop_price / limit_price fields
  • 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 strategies
  • examples/advanced_tutorials/cross-sectional-pipelines/
  • examples/rust_vs_python_benchmark/

🔄 Compatibility

  • BacktestMetrics adds 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 new twr_* fields.

✅ Test status

1668 passed, 42 skipped.

Full Changelog: v8.7.3...v8.8.0