[zipline] Bug with limit orders

Hey! :slight_smile:

I’m trying out zipline with a very simple limit buy “strategy”.

%%zipline -b futures -s 2021-01-01 -e 2021-01-01 --no-benchmark --data-frequency minute --trading-calendar 24/7 --capital-base 30000

from zipline import api

def initialize(context):
    pass

def handle_data(context, data):
    asset = api.symbol('BTCUSDT')
    api.order_target(asset, target=1, limit_price=28800)

I guess it has something to do with my custom bundle, minute timeframe and/or 24/7 calendar.

image

Any hints?

Looks like it also behaves strange with the (most) default settings:

Last thing: I forked the latest master version. Perhaps that was a mistake? :slight_smile:

Hi,
This bug also exists in 1.4.1 and 1.4.0.

After some investigation the issue is that for daily simulations orders don’t get cancelled.
Currently the EODCancel is only implemented for minutely simulations.

In summary, what is happening is that the orders keep getting recorded until the limit_order is satisfied then it fills all the orders.
The following day the order_target sells back to fill the target.

Due to the zipline implementation logic, I don’t think there is a clean and easy fix to this daily transactions issue

Thanks @MBounouar for your help on this - see related PR.