alpacahq / alpaca-trade-api-python

Python client for Alpaca's trade API
https://pypi.org/project/alpaca-trade-api/
Apache License 2.0
1.73k stars 538 forks source link

cancel_order not working #135

Closed PrashantJalan closed 4 years ago

PrashantJalan commented 4 years ago

The cancel_order call in the REST api that calls Alpaca seem to execute fine but the order is still open. I tested this outside regular trading hours. Not sure if it works during normal trading hours. Regardless, it should throw an exception if the order was not cancelled.

umitanuki commented 4 years ago

The order cancelation is asynchronous and depends on the venue's action to reflect the order has been canceled or not which is indicated in the status. So, it is not realistic to throw exception synchronously. That said, from API caller perspective we understand it's hard to know if cancel is in progress, so we are planning to add more information in order entity for better visibility.

PrashantJalan commented 4 years ago

Thank you for the clarification. So is it possible that the cancel order I sent on Saturday will be executed on Monday?

On Sat, Jan 11, 2020 at 4:16 AM Hitoshi Harada notifications@github.com wrote:

The order cancelation is asynchronous and depends on the venue's action to reflect the order has been canceled or not which is indicated in the status. So, it is not realistic to throw exception synchronously. That said, from API caller perspective we understand it's hard to know if cancel is in progress, so we are planning to add more information in order entity for better visibility.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/alpacahq/alpaca-trade-api-python/issues/135?email_source=notifications&email_token=AAQPWEWU3O3QYOQY5DKOQ4DQ5G2CZA5CNFSM4KFQDEM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIWAXEQ#issuecomment-573311890, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQPWEWK2KUR34YCMGWJXO3Q5G2CZANCNFSM4KFQDEMQ .

ttt733 commented 4 years ago

That's correct. We mark the order as canceled at Alpaca, and at the next possible opportunity, we send the cancellation request to the market. We've been discussing ways to make this more obvious in the cancel endpoint's response.