def initialize(context): context.lookback = 12 * 21 context.offset = 1 * 21 context.min_volume = 1E8 context.max_size = 10 context.min_size = 5 context.weight = 0 context.universe = [] if context.broker.name == 'regT': context.hedge = symbol('SPY') elif context.broker.name == 'nse-backtest': context.hedge = symbol('NIFTY-I') else: raise ValueError(f'this broker not supported:{context.broker.name}') context.hedge_threshold = 10000 schedule_function(strategy, date_rules.month_start(days_offset=0), time_rules.market_close(hours=2, minutes=30)) attach_pipeline(make_strategy_pipeline(context), name='strategy_pipeline') schedule_function(hedge, date_rules.every_day(), time_rules.market_open(hours=0, minutes=30)) schedule_function(hedge, date_rules.every_day(), time_rules.market_close(hours=0, minutes=30))
def initialize(context): context.lookback = 12*21 context.offset = 1*21 context.size = 5 context.weight = 0 context.candidates = [] context.universe = [ symbol('SPY'), # large cap symbol('QQQ'), # tech symbol('VUG'), # growth symbol('QUAL'), # quality symbol('MTUM'), # momentum symbol('IWM'), # small cap symbol('USMV'), # min vol symbol('HDV'), # dividend symbol('VEU'), # world equity symbol('VWO'), # EM equity symbol('DBC'), # commodities symbol('USO'), # oil symbol('GLD'), # gold symbol('AGG'), # bonds symbol('TIP'), # inflation ] attach_pipeline(make_strategy_pipeline(context), name='strategy_pipeline') schedule_function(rebalance, date_rules.month_start(days_offset=0), time_rules.market_close(hours=2, minutes=30))
def initialize(context): context.params = {'lookback': 12, 'min_volume': 1E7} schedule_function(strategy, date_rules.month_start(), time_rules.market_close(minutes=1)) attach_pipeline(make_strategy_pipeline(context), name='strategy_pipeline')
def initialize(context): """ function to define things to do at the start of the strategy """ # The context variables can be accessed by other methods context.params = {'lookback': 12, 'percentile': 0.05, 'min_volume': 1E8} # Call rebalance function on the first trading day of each month schedule_function(strategy, date_rules.month_start(), time_rules.market_close(minutes=1)) # Set up the pipe-lines for strategies attach_pipeline(make_strategy_pipeline(context), name='strategy_pipeline')
def initialize(context): """ function to define things to do at the start of the strategy """ context.weights = {} # the weights to trade # strategy parameters context.params = {'lookback_vol':252, 'lookback_ret':5, 'percentile':0.05, 'min_volume':1E8, 'universe':100, } # Call rebalance function on the first trading day of each week schedule_function(strategy, date_rules.week_start(), time_rules.market_close(minutes=30)) # Set up the pipeline attach_pipeline(make_strategy_pipeline(context), name='strategy_pipeline')