List Orders filled today

Is there any simple code to only receive orders filled today for a given symbol in python ?
Maybe add a parameter to orders = api.list_orders(status=‘filled’) ?

This would give you a list of Order objects that have at least some portion filled.

api = tradeapi.REST()
orders = api.list_orders(status='all', limit=500)
orders_filled = [ order for order in orders if order.filled_qty != '0' ]

Two caveats.

  1. This assumes the ‘filled_qty’ class member will always be a string zero. To future proof this, you could consider casting the ‘filled_qty’ to an integer first.
  2. If you have more than 500 orders, this won’t pick up all of them. You could narrow the scope using the ‘after/until/symbol’ parameters.

Alternatively, you can use the hint in this thread to pull everything into a dataframe (How can I use `api.list_orders()` to list new orders that are not filled).

1 Like