Remove SPOT_ candletype

This commit is contained in:
Matthias
2021-12-08 14:35:15 +01:00
parent d89cbda7b8
commit 9b9d61c6d6
19 changed files with 115 additions and 112 deletions

View File

@@ -54,7 +54,7 @@ class HDF5DataHandler(IDataHandler):
:return: List of Pairs
"""
candle = ""
if candle_type not in (CandleType.SPOT, CandleType.SPOT_):
if candle_type != CandleType.SPOT:
datadir = datadir.joinpath('futures')
candle = f"-{candle_type}"

View File

@@ -193,7 +193,7 @@ class IDataHandler(ABC):
) -> Path:
pair_s = misc.pair_to_filename(pair)
candle = ""
if candle_type not in (CandleType.SPOT, CandleType.SPOT_):
if candle_type != CandleType.SPOT:
datadir = datadir.joinpath('futures')
candle = f"-{candle_type}"
filename = datadir.joinpath(

View File

@@ -55,7 +55,7 @@ class JsonDataHandler(IDataHandler):
:return: List of Pairs
"""
candle = ""
if candle_type not in (CandleType.SPOT, CandleType.SPOT_):
if candle_type != CandleType.SPOT:
datadir = datadir.joinpath('futures')
candle = f"-{candle_type}"

View File

@@ -4,7 +4,6 @@ from enum import Enum
class CandleType(str, Enum):
"""Enum to distinguish candle types"""
SPOT = "spot"
SPOT_ = ""
FUTURES = "futures"
MARK = "mark"
INDEX = "index"
@@ -16,12 +15,11 @@ class CandleType(str, Enum):
def from_string(value: str) -> 'CandleType':
if not value:
# Default to spot
return CandleType.SPOT_
return CandleType.SPOT
return CandleType(value)
@staticmethod
def get_default(trading_mode: str) -> 'CandleType':
if trading_mode == 'futures':
return CandleType.FUTURES
# TODO-lev: The below should be SPOT, not SPOT_
return CandleType.SPOT_
return CandleType.SPOT

View File

@@ -1492,7 +1492,7 @@ class Exchange:
pair, timeframe, since_ms, s
)
params = deepcopy(self._ft_has.get('ohlcv_params', {}))
if candle_type not in (CandleType.SPOT, CandleType.SPOT_):
if candle_type != CandleType.SPOT:
params.update({'price': candle_type})
data = await self._api_async.fetch_ohlcv(pair, timeframe=timeframe,
since=since_ms,

View File

@@ -34,6 +34,7 @@ class VolatilityFilter(IPairList):
self._min_volatility = pairlistconfig.get('min_volatility', 0)
self._max_volatility = pairlistconfig.get('max_volatility', sys.maxsize)
self._refresh_period = pairlistconfig.get('refresh_period', 1440)
self._def_candletype = self._config['candle_type_def']
self._pair_cache: TTLCache = TTLCache(maxsize=1000, ttl=self._refresh_period)
@@ -69,7 +70,7 @@ class VolatilityFilter(IPairList):
:return: new allowlist
"""
needed_pairs: ListPairsWithTimeframes = [
(p, '1d', self._config['candle_type_def']) for p in pairlist if p not in self._pair_cache]
(p, '1d', self._def_candletype) for p in pairlist if p not in self._pair_cache]
since_ms = (arrow.utcnow()
.floor('day')
@@ -83,8 +84,8 @@ class VolatilityFilter(IPairList):
if self._enabled:
for p in deepcopy(pairlist):
daily_candles = candles[(p, '1d', self._config['candle_type_def'])] if (
p, '1d', self._config['candle_type_def']) in candles else None
daily_candles = candles[(p, '1d', self._def_candletype)] if (
p, '1d', self._def_candletype) in candles else None
if not self._validate_pair_loc(p, daily_candles):
pairlist.remove(p)
return pairlist

View File

@@ -29,6 +29,7 @@ class RangeStabilityFilter(IPairList):
self._min_rate_of_change = pairlistconfig.get('min_rate_of_change', 0.01)
self._max_rate_of_change = pairlistconfig.get('max_rate_of_change', None)
self._refresh_period = pairlistconfig.get('refresh_period', 1440)
self._def_candletype = self._config['candle_type_def']
self._pair_cache: TTLCache = TTLCache(maxsize=1000, ttl=self._refresh_period)
@@ -67,7 +68,7 @@ class RangeStabilityFilter(IPairList):
:return: new allowlist
"""
needed_pairs: ListPairsWithTimeframes = [
(p, '1d', self._config['candle_type_def']) for p in pairlist if p not in self._pair_cache]
(p, '1d', self._def_candletype) for p in pairlist if p not in self._pair_cache]
since_ms = (arrow.utcnow()
.floor('day')
@@ -81,8 +82,8 @@ class RangeStabilityFilter(IPairList):
if self._enabled:
for p in deepcopy(pairlist):
daily_candles = candles[(p, '1d', self._config['candle_type_def'])] if (
p, '1d', self._config['candle_type_def']) in candles else None
daily_candles = candles[(p, '1d', self._def_candletype)] if (
p, '1d', self._def_candletype) in candles else None
if not self._validate_pair_loc(p, daily_candles):
pairlist.remove(p)
return pairlist

View File

@@ -254,9 +254,8 @@ def list_available_pairs(timeframe: Optional[str] = None, stake_currency: Option
candletype: Optional[CandleType] = None, config=Depends(get_config)):
dh = get_datahandler(config['datadir'], config.get('dataformat_ohlcv', None))
pair_interval = dh.ohlcv_get_available_data(config['datadir'],
config.get('trading_mode', 'spot'))
trading_mode = config.get('trading_mode', 'spot')
pair_interval = dh.ohlcv_get_available_data(config['datadir'], trading_mode)
if timeframe:
pair_interval = [pair for pair in pair_interval if pair[1] == timeframe]
@@ -265,7 +264,8 @@ def list_available_pairs(timeframe: Optional[str] = None, stake_currency: Option
if candletype:
pair_interval = [pair for pair in pair_interval if pair[2] == candletype]
else:
pair_interval = [pair for pair in pair_interval if pair[2] == CandleType.SPOT_]
candle_type = CandleType.get_default(trading_mode)
pair_interval = [pair for pair in pair_interval if pair[2] == candle_type]
pair_interval = sorted(pair_interval, key=lambda x: x[0])

View File

@@ -59,7 +59,7 @@ def informative(timeframe: str, asset: str = '',
informative_pairs = getattr(fn, '_ft_informative', [])
# TODO-lev: Add candle_type to InformativeData
informative_pairs.append(InformativeData(_asset, _timeframe, _fmt, _ffill,
CandleType.SPOT_))
CandleType.SPOT))
setattr(fn, '_ft_informative', informative_pairs)
return fn
return decorator

View File

@@ -425,7 +425,7 @@ class IStrategy(ABC, HyperStrategyMixin):
# Compatibility code for 2 tuple informative pairs
informative_pairs = [
(p[0], p[1], CandleType.from_string(p[2]) if len(
p) > 2 else self.config['candle_type_def'])
p) > 2 else self.config.get('candle_type_def', CandleType.SPOT))
for p in informative_pairs]
for inf_data, _ in self._ft_informative:
if inf_data.asset:
@@ -533,7 +533,7 @@ class IStrategy(ABC, HyperStrategyMixin):
if self.dp:
self.dp._set_cached_df(
pair, self.timeframe, dataframe,
candle_type=self.config['candle_type_def'])
candle_type=self.config.get('candle_type_def', CandleType.SPOT))
else:
logger.debug("Skipping TA Analysis for already analyzed candle")
dataframe[SignalType.ENTER_LONG.value] = 0