mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
Extract backtest_result deletion logic to separate function
This commit is contained in:
@@ -193,6 +193,17 @@ def get_backtest_resultlist(dirname: Path):
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
def delete_backtest_result(file_abs: Path):
|
||||||
|
"""
|
||||||
|
Delete backtest result file and corresponding metadata file.
|
||||||
|
"""
|
||||||
|
# *.meta.json
|
||||||
|
logger.info(f"Deleting backtest result file: {file_abs.name}")
|
||||||
|
file_abs_meta = file_abs.with_suffix('.meta.json')
|
||||||
|
file_abs.unlink()
|
||||||
|
file_abs_meta.unlink()
|
||||||
|
|
||||||
|
|
||||||
def find_existing_backtest_stats(dirname: Union[Path, str], run_ids: Dict[str, str],
|
def find_existing_backtest_stats(dirname: Union[Path, str], run_ids: Dict[str, str],
|
||||||
min_backtest_date: Optional[datetime] = None) -> Dict[str, Any]:
|
min_backtest_date: Optional[datetime] = None) -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ from fastapi.exceptions import HTTPException
|
|||||||
|
|
||||||
from freqtrade.configuration.config_validation import validate_config_consistency
|
from freqtrade.configuration.config_validation import validate_config_consistency
|
||||||
from freqtrade.constants import Config
|
from freqtrade.constants import Config
|
||||||
from freqtrade.data.btanalysis import get_backtest_resultlist, load_and_merge_backtest_result
|
from freqtrade.data.btanalysis import (delete_backtest_result, get_backtest_resultlist,
|
||||||
|
load_and_merge_backtest_result)
|
||||||
from freqtrade.enums import BacktestState
|
from freqtrade.enums import BacktestState
|
||||||
from freqtrade.exceptions import DependencyException, OperationalException
|
from freqtrade.exceptions import DependencyException, OperationalException
|
||||||
from freqtrade.exchange.common import remove_exchange_credentials
|
from freqtrade.exchange.common import remove_exchange_credentials
|
||||||
@@ -277,11 +278,5 @@ def api_delete_backtest_history_entry(file: str, config=Depends(get_config)):
|
|||||||
if not is_file_in_dir(file_abs, bt_results_base):
|
if not is_file_in_dir(file_abs, bt_results_base):
|
||||||
raise HTTPException(status_code=404, detail="File not found.")
|
raise HTTPException(status_code=404, detail="File not found.")
|
||||||
|
|
||||||
# *.meta.json
|
delete_backtest_result(file_abs)
|
||||||
file_abs_meta = file_abs.with_suffix('.meta.json')
|
|
||||||
logger.info(f"Deleting backtest result file: {file}")
|
|
||||||
# logger.info(f"Deleting backtest result file: {file_abs_meta}")
|
|
||||||
|
|
||||||
file_abs.unlink()
|
|
||||||
file_abs_meta.unlink()
|
|
||||||
return get_backtest_resultlist(config['user_data_dir'] / 'backtest_results')
|
return get_backtest_resultlist(config['user_data_dir'] / 'backtest_results')
|
||||||
|
|||||||
Reference in New Issue
Block a user