Open orders not closing

In Zipline I have observed that open orders are not closing. These orders are older than a day.
The documentation states that any open orders will by default close at the end of the day.

By default, Zipline automatically cancels open orders at the end of each day. Alternatively, you can instruct Zipline to never automatically cancel open orders.

I have found neither to be true. I will provide sample code to illustrate.

import zipline.api as algo

def initialize(context):
    pass

def handle_data(context, data):
  SPY_sid = algo.sid("FIBBG000BDTBL9")
  algo.order(SPY_sid, 10)
  algo.order_percent(SPY_sid , 0.1, limit_price=0.69)

  open_orders = algo.get_open_orders()
  SPY_open_orders = open_orders.get(SPY_sid, [])
  print(f'{data.current_dt} number of open orders {len(SPY_open_orders)}')

What happens when you run the above code is that SPY’s price is much higher than $0.69 so the orders are never triggered. The orders pile up and are never canceled. Even when I explicitly set the policy to EODCancel the behavior is the same.

Has anyone else seen this behavior?

I tried this on Zipline 1.4.1 outside of Quantrocket and the results were the same.

I noticed that if you are using minute data limit orders will by default close at the end of the day. If you are using daily data limit orders do not automatically close at all and you will need to get the order id and manually cancel these.

Thank you for pointing this out. You’re correct that Zipline does not execute any kind of cancel policy in daily mode, only in minute mode. At minimum, we will improve the docs around this, or ideally see if we can make Zipline respect the cancel policy in daily mode.