Extract .last_result.json to constant
This commit is contained in:
@@ -10,6 +10,7 @@ import pandas as pd
|
||||
from datetime import timezone
|
||||
|
||||
from freqtrade import persistence
|
||||
from freqtrade.constants import LAST_BT_RESULT_FN
|
||||
from freqtrade.misc import json_load
|
||||
from freqtrade.persistence import Trade
|
||||
|
||||
@@ -34,7 +35,7 @@ def get_latest_backtest_filename(directory: Union[Path, str]) -> str:
|
||||
directory = Path(directory)
|
||||
if not directory.is_dir():
|
||||
raise ValueError(f"Directory '{directory}' does not exist.")
|
||||
filename = directory / '.last_result.json'
|
||||
filename = directory / LAST_BT_RESULT_FN
|
||||
|
||||
if not filename.is_file():
|
||||
raise ValueError(f"Directory '{directory}' does not seem to contain backtest statistics yet.")
|
||||
@@ -43,7 +44,7 @@ def get_latest_backtest_filename(directory: Union[Path, str]) -> str:
|
||||
data = json_load(file)
|
||||
|
||||
if 'latest_backtest' not in data:
|
||||
raise ValueError("Invalid '.last_result.json' format.")
|
||||
raise ValueError(f"Invalid '{LAST_BT_RESULT_FN}' format.")
|
||||
|
||||
return data['latest_backtest']
|
||||
|
||||
|
Reference in New Issue
Block a user