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