Cross-zero replacement uses full Lean quantity after the closing part fills
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 55/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C#
- Estrellas
- 22.6k
- Forks
- 5.4k
- Merge medio
- 11 h 39 min
- PR fusionados (30 d)
- 104
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de QuantConnect/Lean
-
priority:p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
QuantConnect/Lean#10216 ·
Los mantenedores suelen responder en 1 día
-
priority:p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
QuantConnect/Lean#10206 ·
Los mantenedores suelen responder en 1 día
-
priority:p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
QuantConnect/Lean#10199 ·
Los mantenedores suelen responder en 1 día
-
priority:p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
QuantConnect/Lean#10198 ·
Los mantenedores suelen responder en 1 día
-
priority:p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
QuantConnect/Lean#10197 ·
Los mantenedores suelen responder en 1 día
Todos los issues de QuantConnect/Lean
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
dotnet-outdated/dotnet-outdated#871 ·
Los mantenedores suelen responder en 1 día
-
triage/untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
unoplatform/uno#26676 ·
Los mantenedores suelen responder en 1 día
-
.NET bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
[问题] 导出文件时,提示后面还有1243390911步Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
jhaizhou-ops/S2Arm#2177 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
area-CodeGen-coreclr untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
dotnet/runtime#138181 · 1 comentario ·
Los mantenedores suelen responder en 1 día