def init(client, path, date=None): """Initial UserManager(), get predict date and trade date Parameters ---------- client: str The qlib client config file(.yaml) path : str Path to save user account. date : str (YYYY-MM-DD) Trade date, when the generated order list will be traded. Return ---------- um: UserManager() pred_date: pd.Timestamp trade_date: pd.Timestamp """ qlib.init_from_yaml_conf(client) um = UserManager(user_data_path=pathlib.Path(path)) um.load_users() if not date: trade_date, pred_date = None, None else: trade_date = pd.Timestamp(date) if not is_tradable_date(trade_date): raise ValueError("trade date is not tradable date".format( trade_date.date())) pred_date = get_pre_trading_date(trade_date, future=True) return um, pred_date, trade_date
def add_user(self, id, config, path, date): """Add a new user into the a folder to run 'online' module. Parameters ---------- id : str User id, should be unique. config : str The file path (yaml) of user config path : str Path to save user account. date : str (YYYY-MM-DD) The date that user account was added. """ create_user_folder(path) qlib.init_from_yaml_conf(self.client) um = UserManager(user_data_path=path) add_date = D.calendar(end_time=date)[-1] if not is_tradable_date(add_date): raise ValueError("add date is not tradable date".format(add_date.date())) um.add_user(user_id=id, config_file=config, add_date=add_date)