diff --git a/qlib/contrib/backtest/account.py b/qlib/contrib/backtest/account.py index d8b285019..a614f08b6 100644 --- a/qlib/contrib/backtest/account.py +++ b/qlib/contrib/backtest/account.py @@ -104,10 +104,9 @@ class Account: # if suspend, no new price to be updated, profit is 0 if trader.check_stock_suspended(code, today): continue - else: - today_close = trader.get_close(code, today) - profit += (today_close - self.current.position[code]["price"]) * self.current.position[code]["amount"] - self.current.update_stock_price(stock_id=code, price=today_close) + today_close = trader.get_close(code, today) + profit += (today_close - self.current.position[code]["price"]) * self.current.position[code]["amount"] + self.current.update_stock_price(stock_id=code, price=today_close) self.rtn += profit # update holding day count self.current.add_count_all() diff --git a/qlib/contrib/online/operator.py b/qlib/contrib/online/operator.py index c8b44f578..d2307dad5 100644 --- a/qlib/contrib/online/operator.py +++ b/qlib/contrib/online/operator.py @@ -148,7 +148,7 @@ class Operator: for user_id, user in um.users.items(): dates, trade_exchange = prepare(um, trade_date, user_id, exchange_config) executor = SimulatorExecutor(trade_exchange=trade_exchange) - if not str(dates[0].date()) == str(pred_date.date()): + if str(dates[0].date()) != str(pred_date.date()): raise ValueError( "The account data is not newest! last trading date {}, today {}".format( dates[0].date(), trade_date.date() diff --git a/qlib/workflow/cli.py b/qlib/workflow/cli.py index 6eba96277..879c0aaeb 100644 --- a/qlib/workflow/cli.py +++ b/qlib/workflow/cli.py @@ -16,7 +16,7 @@ def get_path_list(path): if isinstance(path, str): return [path] else: - return [p for p in path] + return list(path) def sys_config(config, config_path): diff --git a/qlib/workflow/recorder.py b/qlib/workflow/recorder.py index bc0a9ef77..5915e58da 100644 --- a/qlib/workflow/recorder.py +++ b/qlib/workflow/recorder.py @@ -245,10 +245,10 @@ class MLflowRecorder(Recorder): This function will return the directory path of this recorder. """ if self.artifact_uri is not None: - local_file_prefix = "file:" - if self.artifact_uri.startswith(local_file_prefix): - xpath = self.artifact_uri.lstrip(local_file_prefix) - return (Path(xpath) / "..").resolve() + local_dir_path = Path(self.artifact_uri.lstrip("file:")) / ".." + local_dir_path = str(local_dir_path.resolve()) + if os.path.isdir(local_dir_path): + return local_dir_path else: raise RuntimeError("This recorder is not saved in the local file system.")