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

extended_hours field missing in returned order #76

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

d-e-s-o commented 5 years ago

(v2; paper trading)

When submitting a market order request the order object sent back in response contains no extended_hours field.

bdowling commented 5 years ago

1) market orders are not valid for extended hours, only limit orders. 2) are you seeing this in the streaming order_updates or api response?

d-e-s-o commented 5 years ago
  1. market orders are not valid for extended hours, only limit orders.

Okay, sure, but what does that have to do with the problem at hand?

  1. are you seeing this in the streaming order_updates or api response?

API response.

d-e-s-o commented 5 years ago

So what's the story here? Can somebody please fix this simple bug? It is rendering the v2 order API useless.

garyha commented 5 years ago

Is your code benefiting from an extended_hours field on another platform and relying on it? Can you elaborate a bit more? Maybe with an example scenario including minute of the trading day (1-390)?

d-e-s-o commented 5 years ago

It is not about benefiting. If the documentation states this field exists then it has to exist. Not only when the moon is full but unconditionally.

Limit Order:

HTTP request: POST to https://paper-api.alpaca.markets/v2/orders
Body: {"symbol":"SPY:ARCA:us_equity","qty":1,"side":"buy","type":"limit","time_in_force":"day","limit_price":"1","stop_price":null,"extended_hours":true}
Response HTTP status: 200 OK
Body: {"id":"127796c8-5057-4e32-b6d7-a72e3f61bc83","client_order_id":"41b89b04-0849-476c-9eaf-b4ccde9a932a","created_at":"2019-07-17T14:36:52.153217041Z","updated_at":"2019-07-17T14:36:52.157270588Z","submitted_at":"2019-07-17T14:36:52.137661921Z","filled_at":null,"expired_at":null,"canceled_at":null,"failed_at":null,"asset_id":"b28f4066-5c6d-479b-a2af-85dc1a8f16fb","symbol":"SPY","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","extended_hours":true}

Note: "extended_hours" is present in the response.

Market Order:

HTTP request: POST to https://paper-api.alpaca.markets/v2/orders
Body: {"symbol":"SPY:ARCA:us_equity","qty":1,"side":"buy","type":"market","time_in_force":"day","limit_price":null,"stop_price":null,"extended_hours":false}
Response HTTP status: 200 OK
Body: {"id":"3403918b-99b2-46df-9920-217db7dcc58a","client_order_id":"e206a7f7-bd8d-4458-9b67-e850a07f1803","created_at":"2019-07-17T14:42:10.223079686Z","updated_at":"2019-07-17T14:42:10.227720165Z","submitted_at":"2019-07-17T14:42:10.207844334Z","filled_at":null,"expired_at":null,"canceled_at":null,"failed_at":null,"asset_id":"b28f4066-5c6d-479b-a2af-85dc1a8f16fb","symbol":"SPY","asset_class":"us_equity","qty":"1","filled_qty":"0","filled_avg_price":null,"order_type":"market","type":"market","side":"buy","time_in_force":"day","limit_price":null,"stop_price":null,"status":"new"}

Note: "extended_hours" is NOT present in the response.

The cause actually seems to be the "extended_hours: false" in the request. That seems to cause the backend to drop it from the response altogether.

bdowling commented 5 years ago

Agreed that it should always be present. I think it may be a left over issue while the v2 api was in stealth mode. ;)

I'll file an issue with engineering to address.

d-e-s-o commented 5 years ago

Where are we with this bug?