Update more to use candleType

This commit is contained in:
Matthias
2021-12-03 14:11:24 +01:00
parent 5493212672
commit 2f17fa2765
18 changed files with 56 additions and 55 deletions

View File

@@ -9,6 +9,7 @@ import arrow
from pandas import DataFrame
from freqtrade.configuration import PeriodicCache
from freqtrade.enums import CandleType
from freqtrade.exceptions import OperationalException
from freqtrade.misc import plural
from freqtrade.plugins.pairlist.IPairList import IPairList
@@ -72,7 +73,7 @@ class AgeFilter(IPairList):
:return: new allowlist
"""
needed_pairs = [
(p, '1d', '') for p in pairlist
(p, '1d', CandleType.SPOT_) for p in pairlist
if p not in self._symbolsChecked and p not in self._symbolsCheckFailed]
if not needed_pairs:
# Remove pairs that have been removed before
@@ -88,7 +89,8 @@ class AgeFilter(IPairList):
candles = self._exchange.refresh_latest_ohlcv(needed_pairs, since_ms=since_ms, cache=False)
if self._enabled:
for p in deepcopy(pairlist):
daily_candles = candles[(p, '1d', '')] if (p, '1d', '') in candles else None
daily_candles = candles[(p, '1d', CandleType.SPOT_)] if (
p, '1d', CandleType.SPOT_) in candles else None
if not self._validate_pair_loc(p, daily_candles):
pairlist.remove(p)
self.log_once(f"Validated {len(pairlist)} pairs.", logger.info)

View File

@@ -5,7 +5,7 @@ import logging
import random
from typing import Any, Dict, List
from freqtrade.enums.runmode import RunMode
from freqtrade.enums import RunMode
from freqtrade.plugins.pairlist.IPairList import IPairList

View File

@@ -11,6 +11,7 @@ import numpy as np
from cachetools.ttl import TTLCache
from pandas import DataFrame
from freqtrade.enums import CandleType
from freqtrade.exceptions import OperationalException
from freqtrade.misc import plural
from freqtrade.plugins.pairlist.IPairList import IPairList
@@ -67,7 +68,7 @@ class VolatilityFilter(IPairList):
:param tickers: Tickers (from exchange.get_tickers()). May be cached.
:return: new allowlist
"""
needed_pairs = [(p, '1d', '') for p in pairlist if p not in self._pair_cache]
needed_pairs = [(p, '1d', CandleType.SPOT_) for p in pairlist if p not in self._pair_cache]
since_ms = (arrow.utcnow()
.floor('day')
@@ -81,7 +82,8 @@ class VolatilityFilter(IPairList):
if self._enabled:
for p in deepcopy(pairlist):
daily_candles = candles[(p, '1d', '')] if (p, '1d', '') in candles else None
daily_candles = candles[(p, '1d', CandleType.SPOT_)] if (
p, '1d', CandleType.SPOT_) in candles else None
if not self._validate_pair_loc(p, daily_candles):
pairlist.remove(p)
return pairlist

View File

@@ -10,6 +10,7 @@ from typing import Any, Dict, List
import arrow
from cachetools.ttl import TTLCache
from freqtrade.enums import CandleType
from freqtrade.exceptions import OperationalException
from freqtrade.exchange import timeframe_to_minutes
from freqtrade.misc import format_ms_time
@@ -160,7 +161,7 @@ class VolumePairList(IPairList):
f"{self._lookback_timeframe}, starting from {format_ms_time(since_ms)} "
f"till {format_ms_time(to_ms)}", logger.info)
needed_pairs = [
(p, self._lookback_timeframe, '') for p in
(p, self._lookback_timeframe, CandleType.SPOT_) for p in
[s['symbol'] for s in filtered_tickers]
if p not in self._pair_cache
]
@@ -173,8 +174,8 @@ class VolumePairList(IPairList):
)
for i, p in enumerate(filtered_tickers):
pair_candles = candles[
(p['symbol'], self._lookback_timeframe, '')
] if (p['symbol'], self._lookback_timeframe, '') in candles else None
(p['symbol'], self._lookback_timeframe, CandleType.SPOT_)
] if (p['symbol'], self._lookback_timeframe, CandleType.SPOT_) in candles else None
# in case of candle data calculate typical price and quoteVolume for candle
if pair_candles is not None and not pair_candles.empty:
pair_candles['typical_price'] = (pair_candles['high'] + pair_candles['low']

View File

@@ -9,6 +9,7 @@ import arrow
from cachetools.ttl import TTLCache
from pandas import DataFrame
from freqtrade.enums import CandleType
from freqtrade.exceptions import OperationalException
from freqtrade.misc import plural
from freqtrade.plugins.pairlist.IPairList import IPairList
@@ -65,7 +66,7 @@ class RangeStabilityFilter(IPairList):
:param tickers: Tickers (from exchange.get_tickers()). May be cached.
:return: new allowlist
"""
needed_pairs = [(p, '1d', '') for p in pairlist if p not in self._pair_cache]
needed_pairs = [(p, '1d', CandleType.SPOT_) for p in pairlist if p not in self._pair_cache]
since_ms = (arrow.utcnow()
.floor('day')
@@ -79,7 +80,8 @@ class RangeStabilityFilter(IPairList):
if self._enabled:
for p in deepcopy(pairlist):
daily_candles = candles[(p, '1d', '')] if (p, '1d', '') in candles else None
daily_candles = candles[(p, '1d', CandleType.SPOT_)] if (
p, '1d', CandleType.SPOT_) in candles else None
if not self._validate_pair_loc(p, daily_candles):
pairlist.remove(p)
return pairlist

View File

@@ -8,6 +8,7 @@ from typing import Dict, List
from cachetools import TTLCache, cached
from freqtrade.constants import ListPairsWithTimeframes
from freqtrade.enums import CandleType
from freqtrade.exceptions import OperationalException
from freqtrade.plugins.pairlist.IPairList import IPairList
from freqtrade.plugins.pairlist.pairlist_helpers import expand_pairlist
@@ -138,4 +139,4 @@ class PairListManager():
"""
Create list of pair tuples with (pair, timeframe)
"""
return [(pair, timeframe or self._config['timeframe'], '') for pair in pairs]
return [(pair, timeframe or self._config['timeframe'], CandleType.SPOT) for pair in pairs]