alpacahq / Alpaca-API

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

Open orders are missing from table #119

Open ryanpf opened 4 years ago

ryanpf commented 4 years ago

My paper dashboard shows that I have positions, but I get an "insufficient qty" error when trying to liquidate the position. image I get the same error when trying to liquidate the long position "AQUA"

umitanuki commented 4 years ago

Do you know if you have open orders for the same symbol?

ryanpf commented 4 years ago

There are no open orders for ASH or AQUA listed (sorted alphabetically): image

ryanpf commented 4 years ago

The logs from my bot seem to indicate that there is an open OCO order for ASH, which would be consistent with my trading strategy. It seems like the "Open Orders" table is just missing the orders.

Order update: {"event":"new","order":{"asset_class":"us_equity","asset_id":"84299156-28e6-4746-a1c8-e91bf21cf128","canceled_at":null,"client_order_id":"314e9aac-0148-4577-98cf-6d2cb7606610","created_at":"2020-04-21T13:41:17.868699Z","expired_at":null,"extended_hours":false,"failed_at":null,"filled_at":null,"filled_avg_price":null,"filled_qty":"0","id":"c403c5b3-4460-4ef9-9b26-547de9ec40c3","legs":null,"limit_price":"53.47","order_class":"","order_type":"stop_limit","qty":"17","replaced_at":null,"replaced_by":null,"replaces":null,"side":"sell","status":"new","stop_price":"55.58","submitted_at":"2020-04-21T13:41:17.800241Z","symbol":"ASH","time_in_force":"day","type":"stop_limit","updated_at":"2020-04-21T13:41:18.137933Z"}} Order update: {"event":"fill","order":{"asset_class":"us_equity","asset_id":"84299156-28e6-4746-a1c8-e91bf21cf128","canceled_at":null,"client_order_id":"314e9aac-0148-4577-98cf-6d2cb7606610","created_at":"2020-04-21T13:41:17.868699Z","expired_at":null,"extended_hours":false,"failed_at":null,"filled_at":"2020-04-21T13:43:07.943077Z","filled_avg_price":"53.53","filled_qty":"17","id":"c403c5b3-4460-4ef9-9b26-547de9ec40c3","legs":null,"limit_price":"53.47","order_class":"","order_type":"stop_limit","qty":"17","replaced_at":null,"replaced_by":null,"replaces":null,"side":"sell","status":"filled","stop_price":"55.58","submitted_at":"2020-04-21T13:41:17.800241Z","symbol":"ASH","time_in_force":"day","type":"stop_limit","updated_at":"2020-04-21T13:43:07.964738Z"},"position_qty":"-17","price":"53.53","qty":"17","timestamp":"2020-04-21T13:43:07.943076846Z"} Order update: {"event":"new","order":{"asset_class":"us_equity","asset_id":"84299156-28e6-4746-a1c8-e91bf21cf128","canceled_at":null,"client_order_id":"025d0a99-430a-411f-aefa-e5eb21604f85","created_at":"2020-04-21T13:43:08.243774Z","expired_at":null,"extended_hours":false,"failed_at":null,"filled_at":null,"filled_avg_price":null,"filled_qty":"0","id":"e616e83d-ce6c-494d-a04c-119a520ed535","legs":[{"asset_class":"us_equity","asset_id":"84299156-28e6-4746-a1c8-e91bf21cf128","canceled_at":null,"client_order_id":"3ff5fe8c-5b9b-40c7-93e4-f69de209159e","created_at":"2020-04-21T13:43:08.243774Z","expired_at":null,"extended_hours":false,"failed_at":null,"filled_at":null,"filled_avg_price":null,"filled_qty":"0","id":"aa8bb747-7e90-4b00-b601-b86acfb46c93","legs":null,"limit_price":null,"order_class":"oco","order_type":"stop","qty":"17","replaced_at":null,"replaced_by":null,"replaces":null,"side":"buy","status":"held","stop_price":"57.69","submitted_at":"2020-04-21T13:43:08.237878Z","symbol":"ASH","time_in_force":"gtc","type":"stop","updated_at":"2020-04-21T13:43:08.243774Z"}],"limit_price":"53.47","order_class":"oco","order_type":"limit","qty":"17","replaced_at":null,"replaced_by":null,"replaces":null,"side":"buy","status":"new","stop_price":null,"submitted_at":"2020-04-21T13:43:08.237878Z","symbol":"ASH","time_in_force":"gtc","type":"limit","updated_at":"2020-04-21T13:43:08.43359Z"}}