alpacahq / Alpaca-API

The Alpaca API is a developer interface for trading operations and market data reception through the Alpaca platform.
https://alpaca.markets/
142 stars 13 forks source link

Order cancellation not performed #64

Closed d-e-s-o closed 5 years ago

d-e-s-o commented 5 years ago

(paper trading)

When I create an order and then quickly cancel it, the cancellation will not actually happen in many instances.

Here is a trace:

HTTP request: POST to https://paper-api.alpaca.markets/v1/orders
HTTP status: 200 OK
HTTP body: {"id":"7dcb16ae-2f86-4768-87cc-69d1838d0e85","client_order_id":"3ad6e617-bda2-4346-86c1-dac79bb54094","created_at":"2019-05-01T14:48:50.581270972Z","updated_at":"2019-05-01T14:48:50.58736125Z","submitted_at":"2019-05-01T14:48:50.577197611Z","filled_at":null,"expired_at":null,"canceled_at":null,"failed_at":null,"asset_id":"b0b6dd9d-8b9b-48a9-ba46-b9d54906e415","symbol":"AAPL","asset_class":"us_equity","qty":"1","filled_qty":"0","filled_avg_price":null,"order_type":"limit","type":"limit","side":"buy","time_in_force":"day","limit_price":"1","stop_price":null,"status":"new"}

HTTP request: GET to https://paper-api.alpaca.markets/v1/orders/7dcb16ae2f86476887cc69d1838d0e85
HTTP status: 200 OK
HTTP body: {"id":"7dcb16ae-2f86-4768-87cc-69d1838d0e85","client_order_id":"3ad6e617-bda2-4346-86c1-dac79bb54094","created_at":"2019-05-01T14:48:50.581271Z","updated_at":"2019-05-01T14:48:50.587361Z","submitted_at":"2019-05-01T14:48:50.577198Z","filled_at":null,"expired_at":null,"canceled_at":null,"failed_at":null,"asset_id":"b0b6dd9d-8b9b-48a9-ba46-b9d54906e415","symbol":"AAPL","asset_class":"us_equity","qty":"1","filled_qty":"0","filled_avg_price":null,"order_type":"limit","type":"limit","side":"buy","time_in_force":"day","limit_price":"1","stop_price":null,"status":"new"}

HTTP request: DELETE to https://paper-api.alpaca.markets/v1/orders/7dcb16ae2f86476887cc69d1838d0e85
HTTP status: 204 No Content
HTTP body:

Basically I create an order, retrieve it (optional, it's just for testing) and then cancel it. Everything seems to be going fine, except that the order is still being listed on the UI or when I list all orders programmatically.

Now, if I insert a delay of a couple of seconds between the POST/GET and the DELETE (two seconds seems to be the minimum), everything works just fine (same trace, it's just that the DELETE now actually deleted the order).

ttt733 commented 5 years ago

Hi @d-e-s-o - thanks for the report. We're currently testing a fix for this issue with our paper trading simulator, and we hope to release it soon.

ttt733 commented 5 years ago

We've released an update to our simulator, and issues like this should no longer be happening. Please file another issue if you see any more unexpected errors like this.

d-e-s-o commented 5 years ago

Awesome! I'll try it out tomorrow. Thanks for the quick turn around!