Repository navigation
Add self-financing backtest accounting with drift-aware trades - #87
Merged
Merged
Conversation
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.
The existing vector backtest charges changes in consecutive target fractions. Constant targets therefore pay no ongoing fees even when relative price moves require rebalancing. Add an opt-in
run_self_financing_backtestthat marks old holdings, measures actual trades, jointly solves cash-paid proportional fees and post-fee targets, and carries residual cash without external funding.mlquant backtest --accounting self_financingreuses existing artifacts;backtest_accountingalso works through the demo config. The legacy target-difference path remains the default, and reports label the accounting convention. The complete result retains marked pre-trade weights, trade values, cash, fees, actual weights, NAV and executed turnover. Entry fees enter drawdown, small float32 budget overruns are corrected on a copy and recorded, and total-loss assets/accounts cannot be reinvested or restarted.Validation:
docs/audits/self-financing-20261120/.This is long-only/cash historical accounting with complete fills at each mark and zero cash interest. It does not add broker access, tradability enforcement, settlement, volume or price impact, and does not revalidate archived market results. Fee assumptions are uncalibrated synthetic inputs. No market data was downloaded and no GPU was used.