Cross-zero replacement uses full Lean quantity after the closing part fills
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đá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
- 55/100
Hướng nghiên cứu
Start with Brokerages/Brokerage.cs, especially TryHandleRemainingCrossZeroOrder and TryGetUpdateCrossZeroOrderQuantity, then trace TradeStation's and Alpaca's UpdateOrder callers. Add regression tests with a test brokerage that records replacement requests for both split parts after the closing part fills; confirm price-only replacements preserve each part's intended quantity and ordinary orders still work.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
After a split cross-zero order's closing part fills, Brokerage.TryGetUpdateCrossZeroOrderQuantity forgets that the still-working opening part is only part of the original Lean quantity. A later price-only replacement can therefore request too much quantity.
Deterministic reproduction
No brokerage connection is needed. Using a test brokerage that records PlaceCrossZeroOrder and replacement requests:
- Start short 5 AAPL and register a Lean buy limit order for 10.
- Call
TryCrossZeroPositionOrder(order, -5). The closing request buys 5; the deferred opening request also buys 5. - Pass a
Filledevent for the first 5 throughTryHandleRemainingCrossZeroOrderand wait for the opening request to be submitted. - Update the limit price without changing the Lean quantity.
Observed with TradeStation's UpdateOrder, recording its replacement arguments:
Brokerage id: opening part's id
Expected replace quantity: 5
Actual replace quantity: 10
If the replacement is accepted and filled, this can buy 15 shares in total instead of the requested 10. The test records the outgoing request; it does not connect to a broker or establish a live occurrence.
Cause and affected callers
Brokerages/Brokerage.cs,TryHandleRemainingCrossZeroOrder: the firstFilledremoves_leanOrderByBrokerageCrossingOrders[order.Id]before submitting the opening part.TryGetUpdateCrossZeroOrderQuantity: once that entry is absent, it returnsleanOrder.Quantity, losing the split quantity.- TradeStation's
UpdateOrdersends that quantity to the last brokerage id. - Alpaca's
UpdateOrderalso uses the returned quantity with the last brokerage id, andCreateAlpacaChangeOrderputs it in the replacement request. It uses the same shared split lifecycle. - Tradier calls the helper but ignores the returned quantity and does not send a quantity in its price replacement, so this specific over-sizing path does not apply there.
This is present independently of the invalid-id soft-rejection change in TradeStation #118.
Required result
A price-only replacement of either part must preserve that part's intended total quantity, including after the closing part completes. Existing first-part updates and ordinary non-split orders must continue to work.
Suggestion: retain enough split lifecycle information in the shared brokerage helper to calculate replacement quantities for both parts, with regression tests; TradeStation and Alpaca can then reuse the correction rather than implementing separate bookkeeping.
- 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