Skip to content

Commit

Permalink
Switch performanceFilter to use Minutes lookback resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Sep 18, 2021
1 parent 12c12d4 commit 564e0b9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docs/includes/pairlists.md
Expand Up @@ -191,15 +191,15 @@ Sorts pairs by past trade performance, as follows:

Trade count is used as a tie breaker.

You can use the `days` parameter to only consider performance of the past X days.
You can use the `minutes` parameter to only consider performance of the past X minutes (rolling window).
Not defining this parameter (or setting it to 0) will use all-time performance.

```json
"pairlists": [
// ...
{
"method": "PerformanceFilter",
"days": 10
"minutes": 1440 // rolling 24h
}
],
```
Expand Down
6 changes: 3 additions & 3 deletions freqtrade/persistence/models.py
Expand Up @@ -832,14 +832,14 @@ def total_open_trades_stakes() -> float:
return total_open_stake_amount or 0

@staticmethod
def get_overall_performance(days=None) -> List[Dict[str, Any]]:
def get_overall_performance(minutes=None) -> List[Dict[str, Any]]:
"""
Returns List of dicts containing all Trades, including profit and trade count
NOTE: Not supported in Backtesting.
"""
filters = [Trade.is_open.is_(False)]
if days:
start_date = datetime.today() - timedelta(days)
if minutes:
start_date = datetime.now(timezone.utc) - timedelta(minutes=minutes)
filters.append(Trade.close_date >= start_date)
pair_rates = Trade.query.with_entities(
Trade.pair,
Expand Down
4 changes: 2 additions & 2 deletions freqtrade/plugins/pairlist/PerformanceFilter.py
Expand Up @@ -20,7 +20,7 @@ def __init__(self, exchange, pairlistmanager,
pairlist_pos: int) -> None:
super().__init__(exchange, pairlistmanager, config, pairlistconfig, pairlist_pos)

self._days = pairlistconfig.get('days', 0)
self._minutes = pairlistconfig.get('minutes', 0)

@property
def needstickers(self) -> bool:
Expand All @@ -47,7 +47,7 @@ def filter_pairlist(self, pairlist: List[str], tickers: Dict) -> List[str]:
"""
# Get the trading performance for pairs from database
try:
performance = pd.DataFrame(Trade.get_overall_performance(self._days))
performance = pd.DataFrame(Trade.get_overall_performance(self._minutes))
except AttributeError:
# Performancefilter does not work in backtesting.
self.log_once("PerformanceFilter is not available in this mode.", logger.warning)
Expand Down

0 comments on commit 564e0b9

Please sign in to comment.