A zipline algo, has the following setup... that triggers monthly rebalance.
On Quantopian rebalance_stocks_monthly functions runs correctly - with Quatrocket it runs every day instead - see CSV output below. It seems there is a bug in the Quatrocket backtesting code:
Rebalance daily / monthly
schedule_function(rebalance_daily, date_rules.every_day(), time_rules.market_open(hours=1))
schedule_function(rebalance_stocks_monthly, date_rules.month_start(), time_rules.market_open(hours=2))
def rebalance_stocks_monthly(context, data):
record_signal("MONTHLY TRADE")
buy_secs = buy_list(context, data)
CSV output from the recorded file - shows trades daily vs. in the beginning of the month:
|2018-01-02 00:00:00+00:00 |MONTHLY TRADE|
|2018-01-03 00:00:00+00:00 |MONTHLY TRADE|
|2018-01-04 00:00:00+00:00 |MONTHLY TRADE|
|2018-01-05 00:00:00+00:00 |MONTHLY TRADE|
|2018-01-08 00:00:00+00:00 |MONTHLY TRADE|
|2018-01-09 00:00:00+00:00 |MONTHLY TRADE|
|2018-01-10 00:00:00+00:00 |MONTHLY TRADE|