fix: impove behavior when loading old backtest results
This commit is contained in:
@@ -312,18 +312,25 @@ def get_backtest_market_change(filename: Path, include_ts: bool = True) -> pd.Da
|
|||||||
return df
|
return df
|
||||||
|
|
||||||
|
|
||||||
def get_backtest_wallet_change(filename: Path, strategy_name: str) -> pd.DataFrame:
|
def get_backtest_wallet_change(filename: Path, strategy_name: str) -> pd.DataFrame | None:
|
||||||
"""
|
"""
|
||||||
Read backtest wallet change file.
|
Read backtest wallet change file.
|
||||||
:param filename: Path to the backtest result zip file
|
:param filename: Path to the backtest result zip file
|
||||||
:param strategy_name: Name of the strategy to load
|
:param strategy_name: Name of the strategy to load
|
||||||
:return: DataFrame with wallet change data
|
:return: DataFrame with wallet change data
|
||||||
"""
|
"""
|
||||||
data = load_file_from_zip(filename, f"{filename.stem}_{strategy_name}_wallet.feather")
|
if filename.suffix != ".zip":
|
||||||
df = pd.read_feather(BytesIO(data))
|
return None
|
||||||
|
|
||||||
df.loc[:, "__date_ts"] = df.loc[:, "date"].astype(np.int64) // 1000 // 1000
|
try:
|
||||||
return df
|
data = load_file_from_zip(filename, f"{filename.stem}_{strategy_name}_wallet.feather")
|
||||||
|
df = pd.read_feather(BytesIO(data))
|
||||||
|
|
||||||
|
df.loc[:, "__date_ts"] = df.loc[:, "date"].astype(np.int64) // 1000 // 1000
|
||||||
|
return df
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def find_existing_backtest_stats(
|
def find_existing_backtest_stats(
|
||||||
|
|||||||
Reference in New Issue
Block a user