mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
Remove .json from backtesting output
This commit is contained in:
@@ -184,7 +184,7 @@ def get_backtest_resultlist(dirname: Path):
|
|||||||
continue
|
continue
|
||||||
for s, v in metadata.items():
|
for s, v in metadata.items():
|
||||||
results.append({
|
results.append({
|
||||||
'filename': filename.name,
|
'filename': filename.stem,
|
||||||
'strategy': s,
|
'strategy': s,
|
||||||
'run_id': v['run_id'],
|
'run_id': v['run_id'],
|
||||||
'backtest_start_time': v['backtest_start_time'],
|
'backtest_start_time': v['backtest_start_time'],
|
||||||
|
|||||||
@@ -247,7 +247,8 @@ def api_backtest_history(config=Depends(get_config)):
|
|||||||
def api_backtest_history_result(filename: str, strategy: str, config=Depends(get_config)):
|
def api_backtest_history_result(filename: str, strategy: str, config=Depends(get_config)):
|
||||||
# Get backtest result history, read from metadata files
|
# Get backtest result history, read from metadata files
|
||||||
bt_results_base: Path = config['user_data_dir'] / 'backtest_results'
|
bt_results_base: Path = config['user_data_dir'] / 'backtest_results'
|
||||||
fn = bt_results_base / filename
|
fn = (bt_results_base / filename).with_suffix('.json')
|
||||||
|
|
||||||
results: Dict[str, Any] = {
|
results: Dict[str, Any] = {
|
||||||
'metadata': {},
|
'metadata': {},
|
||||||
'strategy': {},
|
'strategy': {},
|
||||||
@@ -271,7 +272,7 @@ def api_backtest_history_result(filename: str, strategy: str, config=Depends(get
|
|||||||
def api_delete_backtest_history_entry(file: str, config=Depends(get_config)):
|
def api_delete_backtest_history_entry(file: str, config=Depends(get_config)):
|
||||||
# Get backtest result history, read from metadata files
|
# Get backtest result history, read from metadata files
|
||||||
bt_results_base: Path = config['user_data_dir'] / 'backtest_results'
|
bt_results_base: Path = config['user_data_dir'] / 'backtest_results'
|
||||||
file_abs = bt_results_base / file
|
file_abs = (bt_results_base / file).with_suffix('.json')
|
||||||
# Ensure file is in backtest_results directory
|
# Ensure file is in backtest_results directory
|
||||||
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.")
|
||||||
|
|||||||
@@ -2000,7 +2000,7 @@ def test_api_backtest_history(botclient, mocker, testdatadir):
|
|||||||
result = rc.json()
|
result = rc.json()
|
||||||
assert len(result) == 3
|
assert len(result) == 3
|
||||||
fn = result[0]['filename']
|
fn = result[0]['filename']
|
||||||
assert fn == "backtest-result_multistrat.json"
|
assert fn == "backtest-result_multistrat"
|
||||||
strategy = result[0]['strategy']
|
strategy = result[0]['strategy']
|
||||||
rc = client_get(client, f"{BASE_URI}/backtest/history/result?filename={fn}&strategy={strategy}")
|
rc = client_get(client, f"{BASE_URI}/backtest/history/result?filename={fn}&strategy={strategy}")
|
||||||
assert_response(rc)
|
assert_response(rc)
|
||||||
|
|||||||
Reference in New Issue
Block a user