TradeBuilder drops commissions reported after the first execution of an order
Maintainer thường phản hồi trong vòng 1 ngày
Một pull request liên quan đã được merge.
- #10188 của @quantconnect-kronos — đã merge
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
The fee cache is in TradeBuilder.ProcessFill, keyed by order ID in _ordersWithFeesAssigned; the reproduction is a C# snippet that builds a SPY partial fill followed by a status-only Filled event with a $1 commission and checks ClosedTrades[0].TotalFees. Start by reading how ProcessFill decides whether an order's fee has already been assigned and separate commission handling from execution and price updates. Done means the snippet reports 1, duplicate commission reports are still ignored, and a regression test covers a status-only completion after a partial fill.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
TradeBuilder.ProcessFill records an order ID in _ordersWithFeesAssigned on its first execution, even when the reported fee is zero. Any commission reported by a later event for that order is then ignored by trade statistics.
For example, a partial buy execution can report no commission, followed by a final status-only event carrying the commission. After the position closes, ClosedTrades[].TotalFees is zero instead of the commission paid. This is independent of portfolio cash accounting: it concerns the fees attached to reconstructed trades.
Reproduction
var symbol = new Symbol(
SecurityIdentifier.GenerateEquity("SPY", Market.USA, mapSymbol: false), "SPY");
var time = new DateTime(2024, 1, 2, 15, 0, 0, DateTimeKind.Utc);
var builder = new TradeBuilder(FillGroupingMethod.FillToFill, FillMatchingMethod.FIFO);
builder.SetSecurityManager(new SecurityManager(new TimeKeeper(time)));
var noFee = new OrderFee(new CashAmount(0m, "USD"));
var commission = new OrderFee(new CashAmount(1m, "USD"));
builder.ProcessFill(new OrderEvent(1, symbol, time,
OrderStatus.PartiallyFilled, OrderDirection.Buy, 300m, 2m, noFee), 1m, 0m);
// The brokerage closes the order without another execution and reports its commission.
builder.ProcessFill(new OrderEvent(1, symbol, time.AddMinutes(1),
OrderStatus.Filled, OrderDirection.Buy, 300m, 0m, commission), 1m, 1m);
builder.ProcessFill(new OrderEvent(2, symbol, time.AddMinutes(2),
OrderStatus.Filled, OrderDirection.Sell, 301m, -2m, noFee), 1m, 0m);
Console.WriteLine(builder.ClosedTrades[0].TotalFees); // actual: 0; expected: 1
Verified with the QuantConnect.Common assembly built from master (0b5c3db88): the first closed trade has TotalFees = 0 for FillToFill, FlatToFlat, and FlatToReduced. The same missing commission remains with the zero-quantity statistics guards. It is not caused by those guards: the existing first-event fee cache already discarded it.
Expected result
Trade reconstruction must retain genuine commissions reported after an order's first execution, without inventing an execution or treating a status-only event's price as a market-price update. Existing protection against duplicate commission reporting must be preserved.
Suggestion: separate commission accounting from execution/price processing and define how incremental versus repeated order fees are handled. Add regression coverage for deferred commission, including a status-only completion after a partial fill.
Impact is limited to trade fee statistics; this reproduction does not imply missing portfolio cash charges.
- Ngôn ngữ chính
- C#
- Star
- 22.6k
- Fork
- 5.4k
- Merge trung bình
- 11 giờ 39 phút
- Pull request đã merge (30 ngày)
- 104
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của QuantConnect/Lean
-
priority:p2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
QuantConnect/Lean#10216 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
priority:p2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
QuantConnect/Lean#10206 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
priority:p2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
QuantConnect/Lean#10199 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
priority:p2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
QuantConnect/Lean#10198 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
priority:p2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
QuantConnect/Lean#10197 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của QuantConnect/Lean
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
dotnet-outdated/dotnet-outdated#871 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
triage/untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
unoplatform/uno#26676 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
.NET bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[问题] 导出文件时,提示后面还有1243390911步Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
jhaizhou-ops/S2Arm#2177 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area-CodeGen-coreclr untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
dotnet/runtime#138181 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày