Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR introduces per_contract_fee support to TradingFee, enabling per-unit costs for contracts like options. Decimal coercion is standardized across all fee fields. Backtesting broker applies per_contract_fee scaled by order quantity alongside existing flat and percent fees. Comprehensive regression tests validate the new calculations. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes
✨ Finishing Touches
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Pylint (4.0.5)lumibot/entities/trading_fee.py************* Module pylintrc ... [truncated 686 characters] ... 13" tests/test_tradingfee.py************* Module pylintrc ... [truncated 3502 characters] ... ] lumibot/backtesting/backtesting_broker.py************* Module pylintrc ... [truncated 175044 characters] ... ] Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What
Adds per-contract fee support to
TradingFeeand applies it in backtesting trade-cost calculations so option commission modeling matches broker per-contract pricing.Why
Backtests were undercharging commissions for strategies that model option fees as per-contract costs (for example, $0.65/contract).
Risk
Low-to-moderate: affects commission calculations and therefore PnL metrics in backtests where
per_contract_feeis configured. No impact when it is left at default0.Tests run
python3 -m pytest tests/test_tradingfee.py -qNotes
4.4.54.Summary by CodeRabbit
Release Notes - Version 4.4.54
New Features
Changed
Bug Fixes
Tests