Hi the algorithm is a very simple algorithm that I have used as an example I am struggling to understand some very basic parts of quantopian.
The algorithm buys 1 hour after open, and should sell 10 min before close.
I would be grateful if you could assist me with the following:
a) is this backtest on minute bars or daily bars? if daily, then how is it submitting orders 1 hour after open?
b) it appears orders aren't being closed at the end of my day despite my function, why is this?
c) it appears leverage isn't being controlled? Is this due to b)?
The code is attached and also below:
def initialize(context):
# Rebalance every day, 1 hour after market open.
schedule_function(open_all, date_rules.every_day(), time_rules.market_open(hours=1))
# Close all orders at 10 minutes before end of day
schedule_function(func=close_all, date_rule=date_rules.every_day(), time_rule=time_rules.market_close(minutes=10) )
def before_trading_start(context, data):
context.sec_list = [sid(24), sid(114), sid(122), sid(630)]
def open_all(context,data):
for equity in context.sec_list:
order_percent(equity,0.25)
log.info(equity,"opened")
def close_all(context, data):
for equity in context.sec_list:
order_percent(equity, 0)
log.info(equity,"liquidated")