fix: backtestResulttype - simplify

This commit is contained in:
Matthias
2025-03-23 15:51:48 +01:00
parent 9fa3a15e24
commit 04a28b2550
2 changed files with 10 additions and 11 deletions

View File

@@ -1,3 +1,4 @@
from copy import deepcopy
from typing import Any from typing import Any
from typing_extensions import TypedDict from typing_extensions import TypedDict
@@ -15,11 +16,13 @@ class BacktestResultType(TypedDict):
def get_BacktestResultType_default() -> BacktestResultType: def get_BacktestResultType_default() -> BacktestResultType:
return { return deepcopy(
"metadata": {}, {
"strategy": {}, "metadata": {},
"strategy_comparison": [], "strategy": {},
} "strategy_comparison": [],
}
)
class BacktestHistoryEntryType(BacktestMetadataType): class BacktestHistoryEntryType(BacktestMetadataType):

View File

@@ -18,7 +18,7 @@ from freqtrade.data.metrics import (
calculate_sortino, calculate_sortino,
calculate_sqn, calculate_sqn,
) )
from freqtrade.ft_types import BacktestResultType from freqtrade.ft_types import BacktestResultType, get_BacktestResultType_default
from freqtrade.util import decimals_per_coin, fmt_coin, get_dry_run_wallet from freqtrade.util import decimals_per_coin, fmt_coin, get_dry_run_wallet
@@ -587,11 +587,7 @@ def generate_backtest_stats(
:param max_date: Backtest end date :param max_date: Backtest end date
:return: Dictionary containing results per strategy and a strategy summary. :return: Dictionary containing results per strategy and a strategy summary.
""" """
result: BacktestResultType = { result: BacktestResultType = get_BacktestResultType_default()
"metadata": {},
"strategy": {},
"strategy_comparison": [],
}
market_change = calculate_market_change(btdata, "close") market_change = calculate_market_change(btdata, "close")
metadata = {} metadata = {}
pairlist = list(btdata.keys()) pairlist = list(btdata.keys())