def init(context): context.number = 10 context.period = 20 context.SMAPERIOD = 5 context.marketval = context.portfolio.market_value context.stocks = sector('原材料') update_universe(context.stocks) scheduler.run_monthly(get_head, monthday=1) scheduler.run_monthly(position, monthday=1) scheduler.run_daily(stoploss)
def handle_bar(context, bar_dict): assert len(sector('金融')) >= 180
def handle_bar(context, bar_dict): assert len(sector('金融')) >= 80, "sector('金融') 返回结果少于 80 个"