refactor: Type backtest results

This commit is contained in:
Matthias
2025-04-06 14:38:51 +02:00
parent ca390eea6a
commit 4986f356ee
5 changed files with 44 additions and 9 deletions

View File

@@ -8,7 +8,6 @@ import logging
from collections import defaultdict
from copy import deepcopy
from datetime import datetime, timedelta
from typing import Any
from numpy import nan
from pandas import DataFrame
@@ -37,7 +36,12 @@ from freqtrade.exchange import (
timeframe_to_seconds,
)
from freqtrade.exchange.exchange import Exchange
from freqtrade.ft_types import BacktestResultType, get_BacktestResultType_default
from freqtrade.ft_types import (
BacktestContentType,
BacktestContentTypeIcomplete,
BacktestResultType,
get_BacktestResultType_default,
)
from freqtrade.leverage.liquidation_price import update_liquidation_prices
from freqtrade.mixins import LoggingMixin
from freqtrade.optimize.backtest_caching import get_strategy_run_id
@@ -119,7 +123,7 @@ class Backtesting:
config["dry_run"] = True
self.run_ids: dict[str, str] = {}
self.strategylist: list[IStrategy] = []
self.all_results: dict[str, dict] = {}
self.all_results: dict[str, BacktestContentType] = {}
self.analysis_results: dict[str, dict[str, DataFrame]] = {
"signals": {},
"rejected": {},
@@ -1611,7 +1615,9 @@ class Backtesting:
yield current_time_det, pair, row, is_last_row, trade_dir
self.progress.increment()
def backtest(self, processed: dict, start_date: datetime, end_date: datetime) -> dict[str, Any]:
def backtest(
self, processed: dict, start_date: datetime, end_date: datetime
) -> BacktestContentTypeIcomplete:
"""
Implement backtesting functionality