alpacahq / alpacahq/Alpaca-API

The API `PATCH/v2/orders/` incorrectly uses original qty and not updated qty if the order has a partial fill

Offen
#165 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug
Vorherrschende Sprache
Keine Sprachdaten
Sterne
173
Forks
17
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

**Describe the bug**
When a sell order that was opened with qty=N is partially filled, and then gets replaced with a new price (using the `PATCH` API), the replaced order reflects the original qty N and NOT the unfilled qty. This results in the replaced partially filled orders ultimately filling the wrong total quantity or returning an error (because now, for a liquidating sell, it is trying to sell more than one has shares).

It appears that the replaced order gets created with qty = N (the original order qty). The correct behaviour would be to create the new order with with only the outstanding, unfilled shares, qty = N - partially_filled_qty.

This may also occur for a buy order but cannot confirm this.

**To Reproduce**
This is hard to reproduce because it only happens when replacing a partially filled order.

**Expected behavior**
The correct behaviour would be to create the new order with with only the outstanding, unfilled shares, qty = N - partially_filled_qty.

**Additional context**
There is a forum post explaining this behaviour in more detail.
https://forum.alpaca.markets/t/quantity-error-when-replacing-partially-filled-sell-order/4329

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.