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?