Hi everyone, this is my first post. I'm still learning zipline.
I'm trying to create a simple backtest to buy(open) in the morning(near) and close the position at close(near).
context.asset = symbol('ibm')
schedule_function(morning, date_rule = date_rules.every_day(), time_rule = time_rules.market_open(minutes=1))
schedule_function(end_of_day, date_rule = date_rules.every_day(), time_rule = time_rules.market_close(minutes=1))
def morning(context, data):
def end_of_day(context, data):
def handle_data(context, data):
The results seem to suggest that I open and close at the same price everytime. I think I'm in a daily mode, but maybe I need to switch to a min mode? Note: I'm currently running it locally on zipline. I don't want to cheat the system. Basically I need the system to use the open price for the buy and the close price for the sell.
I'll continue to read/search the forum, but so far I don't have solution to this somewhat simple question.