Adding status=='filled' filter to v2/orders API

Greetings all!

I am requesting the history of my orders from /v2/orders API using Python REST api.list_orders() method, and although I ask for status=‘filled’ I get orders with status=‘canceled’.

There is a ambiguity for status as parameter (with open , closed or all according to the documentation) and status as a return value that has ‘filled’ and ‘canceled’. I have about 10 canceled orders for every filled order, and with the limit of up to 500 orders in the response I get stuck on getting partial results. It would be possible to parse out the ‘after’ and ‘until’ to chop the response to smaller pieces, but this might cause many bugs.

It would be incredibly helpful and efficient to be able to filter in the request only ‘filled’ orders, perhaps by adding another field (‘closed_status’ or ‘status_result’ etc. It would drastically reduce response byte size, and will also help disambiguate between status ‘open’/‘closed’ and status ‘filled’ 'canceled;.

With thanks for any consideration!

I was experiencing similar challenges. I switched to Account Activities with activity_type of FILL. Then it aligned with what I wanted – a ledger of completed trades.

Thanks. This totally solved the issue!

Two comments:

  1. The reason I missed account_activities() is because there is no Code Example for it, and it might be a good idea for Alpaca to complete the examples to all the REST methods.

  2. I still thing there is an issue of ambiguity with parameter status in the above REST request and the returned account data structure. It would advisable to disambiguate it.


1 Like

Glad it solved it for you too! :slight_smile: