Implement trading fee model in portfolio rebalancing and update relat…#16
Merged
Implement trading fee model in portfolio rebalancing and update relat…#16
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements a trading fee model for portfolio rebalancing and enhances individual hedge analysis with performance metrics (CAGR, Sharpe). The changes enable realistic transaction cost modeling in the quantitative finance backtesting framework.
Key changes:
- Adds configurable trading fees (basis points per turnover) applied during rebalancing
- Computes base (unhedged) performance metrics for comparison with hedged portfolios
- Enriches HTML reports with CAGR and Sharpe ratios alongside existing risk metrics
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
config.yaml |
Adds trading_fee_bps: 10 parameter under rebalancing section |
src/backtester/rebalancing.py |
Implements fee calculation logic in simulate_rebalanced_portfolio() with first-day exemption |
src/backtester/engine.py |
Computes base_metrics for unhedged baseline, enriches optimization results with CAGR/Sharpe per weight, passes fees to simulations |
src/reporting/report.py |
Adds trading fee and rebalancing frequency to summary, expands individual hedge table with 4 new performance columns (base/hedged CAGR and Sharpe) |
tests/test_rebalancing.py |
Adds TestTradingFees class with 5 comprehensive tests covering fee mechanics, edge cases, and frequency effects |
tests/test_engine.py |
Adds TestBaseMetrics class verifying base_metrics presence, structure, and handling of insufficient data |
docs/trading_fees.md |
Documents implementation approach, fee formula, design decisions, and testing strategy |
data/risk_free_rate.parquet |
Binary data file update (likely routine data refresh) |
data/prices_metadata.csv |
Updates end date from 2025-12-08 to 2025-12-09 (routine data refresh) |
…annualization and updating related calculations
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.
…ed documentation