offset must be in between 1 minute and 12 hours, inclusive.
Below is my code
%%zipline -b gdax-bundle --start 2018-1-3 --end 2018-1-8 --data-frequency minute --trading-calendar GDAX
from zipline.api import symbol, get_datetime
from zipline.api import schedule_function, date_rules, time_rules
def initialize(context):
context.btc = symbol("BTC")
for i in range(0,24,2):
schedule_function(rebalance,
date_rules.every_day(),
time_rules.market_open(hours=i))
def rebalance(context, data):
print(get_datetime())
def handle_data(context, data):
pass
I can use handle_data to call rebalance function every two hour Since handle_data is called every minute. However I think it is better to use schedule_function.
Does anyone know how to set offset of time_rules beyond 12?
--
You received this message because you are subscribed to the Google Groups "Zipline Python Opensource Backtester" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zipline+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
%%zipline -b gdax-bundle --start 2018-1-3 --end 2018-1-8 --data-frequency minute --trading-calendar GDAX
from zipline.api import symbol, get_datetime
from zipline.api import schedule_function, date_rules, time_rules
def initialize(context):
context.btc = symbol("BTC")
for i in range(0,12,2):
schedule_function(rebalance,
date_rules.every_day(),
time_rules.market_open(hours=i, minutes=1))
schedule_function(rebalance,
date_rules.every_day(),
time_rules.market_close(hours=i+2))
def rebalance(context, data):
print(get_datetime())
def handle_data(context, data):
pass
2018-01-03 00:00:00+00:00 2018-01-03 02:00:00+00:00 2018-01-03 04:00:00+00:00 2018-01-03 06:00:00+00:00 2018-01-03 08:00:00+00:00 2018-01-03 10:00:00+00:00 2018-01-03 11:59:00+00:00 2018-01-03 13:59:00+00:00 2018-01-03 15:59:00+00:00 2018-01-03 17:59:00+00:00 2018-01-03 19:59:00+00:00 2018-01-03 21:59:00+00:00 2018-01-04 00:00:00+00:00 2018-01-04 02:00:00+00:00 2018-01-04 04:00:00+00:00 2018-01-04 06:00:00+00:00 2018-01-04 08:00:00+00:00 2018-01-04 10:00:00+00:00 2018-01-04 11:59:00+00:00 2018-01-04 13:59:00+00:00 2018-01-04 15:59:00+00:00 2018-01-04 17:59:00+00:00 2018-01-04 19:59:00+00:00 2018-01-04 21:59:00+00:00 2018-01-05 00:00:00+00:00 2018-01-05 02:00:00+00:00 2018-01-05 04:00:00+00:00 2018-01-05 06:00:00+00:00 2018-01-05 08:00:00+00:00
--
You received this message because you are subscribed to the Google Groups "Zipline Python Opensource Backtester" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zipline+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.