# How can I use \`api.list\_orders()\` to list new orders that are not filled

**URL:** <https://forum.alpaca.markets/t/how-can-i-use-api-list-orders-to-list-new-orders-that-are-not-filled/1440>\
**Category:** Alpaca Integration Applications\
**Created:** [May 12, 2020, 11:27pm UTC](https://forum.alpaca.markets/t/how-can-i-use-api-list-orders-to-list-new-orders-that-are-not-filled/1440 "2020-05-12T23:27:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wenliang\_Zhang](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/wenliang_zhang/32/759_2.png) [@Wenliang\_Zhang](https://forum.alpaca.markets/u/Wenliang_Zhang)\
**Post date:** [May 12, 2020, 11:27pm UTC](https://forum.alpaca.markets/t/how-can-i-use-api-list-orders-to-list-new-orders-that-are-not-filled/1440/1 "2020-05-12T23:27:17Z")

</div>

how can I list orders that I placed when market was closed. Those orders are marked as “NEW” when you placed when market is closed. which parameter should I pass to api.list\_orders() in order to get those new orders?

---

<div class="post-metadata">

**Author:** ![hitoshi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/hitoshi/32/69_2.png) [@hitoshi](https://forum.alpaca.markets/u/hitoshi)\
**Post date:** [May 19, 2020, 7:22pm UTC](https://forum.alpaca.markets/t/how-can-i-use-api-list-orders-to-list-new-orders-that-are-not-filled/1440/2 "2020-05-19T19:22:14Z")

</div>

How about filtering by `order.submitted_at` and compare with market hours? This can be done in the client side.

---

<div class="post-metadata">

**Author:** ![Travis\_Welch](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/travis_welch/32/1368_2.png) [@Travis\_Welch](https://forum.alpaca.markets/u/Travis_Welch)\
**Post date:** [October 4, 2020, 5:56pm UTC](https://forum.alpaca.markets/t/how-can-i-use-api-list-orders-to-list-new-orders-that-are-not-filled/1440/3 "2020-10-04T17:56:57Z")

</div>

I’m running into a similar problem. I’m just trying to get a list of my entire order history, but list\_orders() doesn’t seem to want to return filled orders. Is there something I’m doing wrong?

---

<div class="post-metadata">

**Author:** ![dan\_whitnable](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/dan_whitnable/32/1323_2.png) [@dan\_whitnable](https://forum.alpaca.markets/u/dan_whitnable)\
**Post date:** [October 4, 2020, 8:03pm UTC](https://forum.alpaca.markets/t/how-can-i-use-api-list-orders-to-list-new-orders-that-are-not-filled/1440/4 "2020-10-04T20:03:44Z")

</div>

If using the python `alpaca-trade-api-python` SDK one can get a list of all unfilled orders something like this

```
# Imports we need. Also import pandas while we're at it. It'll come in handy later on.
import alpaca_trade_api as alpacaapi
import pandas as pd

# Set endpoints for either live or paper trading
ALPACA_API_ENDPOINT = 'https://paper-api.alpaca.markets'
ALPACA_API_KEY_ID = 'XXXXX'
ALPACA_API_SECRET_KEY = 'XXXXXXX'

# Get a reference to a a rest object
api = alpacaapi.REST(ALPACA_API_KEY_ID, ALPACA_API_SECRET_KEY, ALPACA_API_ENDPOINT)

# Get a list of all orders.
open_orders_list = api.list_orders(status='open')

```

Setting `status='open'` will return only unfilled open orders. Setting `status` to either ‘closed’ or ‘all’ will return only closed or all orders respectively. The default quantity returned is 50. To get more than that add the parameter `limit`. The maximum however is 500. If one has more than 500 orders to return then the list will need to be ‘chunked’ into smaller pieces using the `after` and/or `until` parameters. Something like this will return up to 100 of the most recently closed orders

```
all_orders_list = api.list_orders(status='closed', limit=100)

```

The list is rather cumbersome to work with (IMHO). It can be easily turned into a dataframe like this

`all_orders_df = pd.DataFrame([order._raw for order in all_orders_list])`

Hope that helps. BTW welcome to the forums @Travis_Welch.

---

<div class="post-metadata">

**Author:** ![Travis\_Welch](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/travis_welch/32/1368_2.png) [@Travis\_Welch](https://forum.alpaca.markets/u/Travis_Welch)\
**Post date:** [October 4, 2020, 8:23pm UTC](https://forum.alpaca.markets/t/how-can-i-use-api-list-orders-to-list-new-orders-that-are-not-filled/1440/5 "2020-10-04T20:23:14Z")

</div>

This is exactly the help I was looking for! I assumed the default value for status was all, but I was wrong. Thanks!
