Conversation
…ow tracking Adds BrokerBalanceTracker for managing scheduled deposits/withdrawals and Context.sync_portfolio() for reconciling local portfolio state against broker balances. Cash flows are now recorded on every sync event so they can be subtracted from performance metrics (TWR).
Adds StopOrderType enum + validation for stop and stop-limit orders. Order model gains stop_price/limit_price fields, ccxt executor maps them to exchange-native stop orders, backtest service simulates trigger conditions per bar.
…al analysis Introduces 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. Adds new BacktestMetrics fields: twr_equity_curve, twr_drawdown_series, twr_max_drawdown, twr_max_drawdown_duration.
Backtest HTML dashboard now ships TWR_EQ / TWR_DD per run and overlays the alpha-only curve as a dashed line on the equity and drawdown charts. Scalar metrics gain twr_max_drawdown and twr_max_drawdown_duration.
Vector backtest engine now honours BrokerBalanceTracker schedules so DCA-style accumulation strategies can be backtested with realistic external cash flows. Adds scenario test for deposit schedules.
Updates serialized metrics.json/run.json fixtures to include the new twr_* fields so round-trip serialization tests stay green.
Bumps version 8.7.3 -> 8.8.0. Wires new BrokerBalanceTracker into the dependency container and event loop, exposes new public symbols from package __init__, adds OperationalException for sync errors, updates docs sidebar, and ships example strategies showcasing TWR metrics, DCA accumulation, and stop/stop-limit orders.
CI runs the suite under stdlib unittest (not pytest), so the bare 'import pytest' caused a ModuleNotFoundError on the runner.
Follow-up to #529: * Extract a single url_cache_key(url, headers) helper in base_url.py so the in-memory provider dict on Context and the on-disk cache filename hash use the exact same canonical serialization. Prevents future drift where an in-memory hit could read the wrong on-disk file. * Add a note to the headers= docstrings on Context.fetch_csv / fetch_json / fetch_parquet and DataSource.from_csv / from_json / from_parquet documenting that header values are redacted to '***' in to_dict() so secrets do not leak into diagnostic payloads.
…-test Optimize README example scenario test
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.
Release v8.8.0 — TWR metrics, broker balance tracker, stop orders
This PR rolls up the work currently on
devintomain. It adds threemajor capabilities and a number of supporting pieces of plumbing.
Highlights
1. Broker balance tracker +
Context.sync_portfolio()BrokerBalanceTrackerfor managing scheduled deposits/withdrawalsContext.sync_portfolio()reconciles local portfolio state againstthe broker and records cash flows on every sync event
performance metrics (TWR)
docusaurus/docs/Advanced Concepts/portfolio-sync.md2. Stop and stop-limit orders
StopOrderTypeenum + validationOrdermodel gainsstop_price/limit_pricefieldsdocusaurus/docs/Getting Started/orders.md3. Time-weighted return (TWR) metrics
TWR variants for CAGR, Sharpe, volatility, returns, drawdown, and
equity curve. All TWR metrics consume
snapshot.cash_flowto scrubexternal deposits/withdrawals from performance, giving a true alpha-only
view.
New
BacktestMetricsfields:twr_equity_curvetwr_drawdown_seriestwr_max_drawdowntwr_max_drawdown_duration4. HTML reporting
TWR_EQ/TWR_DDper run in dashboard datatwr_max_drawdownandtwr_max_drawdown_duration5. Vector backtest scheduled deposits
BrokerBalanceTrackerschedules so DCA-styleaccumulation strategies can be backtested with realistic external
cash flows
tests/scenarios/vectorized_backtests/test_deposit_schedule.py6. Examples
examples/strategies_showcase/— 26 reference strategiesexamples/advanced_tutorials/cross-sectional-pipelines/examples/rust_vs_python_benchmark/Commits
Test status
Full suite: 1668 passed, 42 skipped locally.
Compatibility
BacktestMetricsadds new fields with defaults —from_dict()isforward/backward compatible (unknown keys are dropped, missing keys
default).
tests/resources/backtest_reports_for_testing/were regenerated to include the new
twr_*fields.8.7.3 → 8.8.0.