mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-02-05 13:50:26 +00:00
chore: align interface of get_overall_performance
This commit is contained in:
@@ -6,7 +6,7 @@ import logging
|
||||
from collections import defaultdict
|
||||
from collections.abc import Sequence
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from datetime import datetime, timezone
|
||||
from math import isclose
|
||||
from typing import Any, ClassVar, Optional, cast
|
||||
|
||||
@@ -1914,14 +1914,13 @@ class Trade(ModelBase, LocalTrade):
|
||||
return total_open_stake_amount or 0
|
||||
|
||||
@staticmethod
|
||||
def get_overall_performance(minutes=None) -> list[dict[str, Any]]:
|
||||
def get_overall_performance(start_date: datetime | None = None) -> list[dict[str, Any]]:
|
||||
"""
|
||||
Returns List of dicts containing all Trades, including profit and trade count
|
||||
NOTE: Not supported in Backtesting.
|
||||
"""
|
||||
filters: list = [Trade.is_open.is_(False)]
|
||||
if minutes:
|
||||
start_date = datetime.now(timezone.utc) - timedelta(minutes=minutes)
|
||||
if start_date:
|
||||
filters.append(Trade.close_date >= start_date)
|
||||
|
||||
pair_costs = (
|
||||
|
||||
@@ -3,12 +3,14 @@ Performance pair list filter
|
||||
"""
|
||||
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
|
||||
import pandas as pd
|
||||
|
||||
from freqtrade.exchange.exchange_types import Tickers
|
||||
from freqtrade.persistence import Trade
|
||||
from freqtrade.plugins.pairlist.IPairList import IPairList, PairlistParameter, SupportsBacktesting
|
||||
from freqtrade.util.datetime_helpers import dt_now
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -69,7 +71,8 @@ class PerformanceFilter(IPairList):
|
||||
"""
|
||||
# Get the trading performance for pairs from database
|
||||
try:
|
||||
performance = pd.DataFrame(Trade.get_overall_performance(self._minutes))
|
||||
start_date = dt_now() - timedelta(minutes=self._minutes)
|
||||
performance = pd.DataFrame(Trade.get_overall_performance(start_date))
|
||||
except AttributeError:
|
||||
# Performancefilter does not work in backtesting.
|
||||
self.log_once("PerformanceFilter is not available in this mode.", logger.warning)
|
||||
|
||||
Reference in New Issue
Block a user