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 :return: List of Pairs
""" """
candle = "" candle = ""
if candle_type not in (CandleType.SPOT, CandleType.SPOT_): if candle_type != CandleType.SPOT:
datadir = datadir.joinpath('futures') datadir = datadir.joinpath('futures')
candle = f"-{candle_type}" candle = f"-{candle_type}"

View File

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

View File

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

View File

@ -4,7 +4,6 @@ from enum import Enum
class CandleType(str, Enum): class CandleType(str, Enum):
"""Enum to distinguish candle types""" """Enum to distinguish candle types"""
SPOT = "spot" SPOT = "spot"
SPOT_ = ""
FUTURES = "futures" FUTURES = "futures"
MARK = "mark" MARK = "mark"
INDEX = "index" INDEX = "index"
@ -16,12 +15,11 @@ class CandleType(str, Enum):
def from_string(value: str) -> 'CandleType': def from_string(value: str) -> 'CandleType':
if not value: if not value:
# Default to spot # Default to spot
return CandleType.SPOT_ return CandleType.SPOT
return CandleType(value) return CandleType(value)
@staticmethod @staticmethod
def get_default(trading_mode: str) -> 'CandleType': def get_default(trading_mode: str) -> 'CandleType':
if trading_mode == 'futures': if trading_mode == 'futures':
return CandleType.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 pair, timeframe, since_ms, s
) )
params = deepcopy(self._ft_has.get('ohlcv_params', {})) 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}) params.update({'price': candle_type})
data = await self._api_async.fetch_ohlcv(pair, timeframe=timeframe, data = await self._api_async.fetch_ohlcv(pair, timeframe=timeframe,
since=since_ms, since=since_ms,

View File

@ -34,6 +34,7 @@ class VolatilityFilter(IPairList):
self._min_volatility = pairlistconfig.get('min_volatility', 0) self._min_volatility = pairlistconfig.get('min_volatility', 0)
self._max_volatility = pairlistconfig.get('max_volatility', sys.maxsize) self._max_volatility = pairlistconfig.get('max_volatility', sys.maxsize)
self._refresh_period = pairlistconfig.get('refresh_period', 1440) 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) self._pair_cache: TTLCache = TTLCache(maxsize=1000, ttl=self._refresh_period)
@ -69,7 +70,7 @@ class VolatilityFilter(IPairList):
:return: new allowlist :return: new allowlist
""" """
needed_pairs: ListPairsWithTimeframes = [ 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() since_ms = (arrow.utcnow()
.floor('day') .floor('day')
@ -83,8 +84,8 @@ class VolatilityFilter(IPairList):
if self._enabled: if self._enabled:
for p in deepcopy(pairlist): for p in deepcopy(pairlist):
daily_candles = candles[(p, '1d', self._config['candle_type_def'])] if ( daily_candles = candles[(p, '1d', self._def_candletype)] if (
p, '1d', self._config['candle_type_def']) in candles else None p, '1d', self._def_candletype) in candles else None
if not self._validate_pair_loc(p, daily_candles): if not self._validate_pair_loc(p, daily_candles):
pairlist.remove(p) pairlist.remove(p)
return pairlist 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._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._max_rate_of_change = pairlistconfig.get('max_rate_of_change', None)
self._refresh_period = pairlistconfig.get('refresh_period', 1440) 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) self._pair_cache: TTLCache = TTLCache(maxsize=1000, ttl=self._refresh_period)
@ -67,7 +68,7 @@ class RangeStabilityFilter(IPairList):
:return: new allowlist :return: new allowlist
""" """
needed_pairs: ListPairsWithTimeframes = [ 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() since_ms = (arrow.utcnow()
.floor('day') .floor('day')
@ -81,8 +82,8 @@ class RangeStabilityFilter(IPairList):
if self._enabled: if self._enabled:
for p in deepcopy(pairlist): for p in deepcopy(pairlist):
daily_candles = candles[(p, '1d', self._config['candle_type_def'])] if ( daily_candles = candles[(p, '1d', self._def_candletype)] if (
p, '1d', self._config['candle_type_def']) in candles else None p, '1d', self._def_candletype) in candles else None
if not self._validate_pair_loc(p, daily_candles): if not self._validate_pair_loc(p, daily_candles):
pairlist.remove(p) pairlist.remove(p)
return pairlist 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)): candletype: Optional[CandleType] = None, config=Depends(get_config)):
dh = get_datahandler(config['datadir'], config.get('dataformat_ohlcv', None)) dh = get_datahandler(config['datadir'], config.get('dataformat_ohlcv', None))
trading_mode = config.get('trading_mode', 'spot')
pair_interval = dh.ohlcv_get_available_data(config['datadir'], pair_interval = dh.ohlcv_get_available_data(config['datadir'], trading_mode)
config.get('trading_mode', 'spot'))
if timeframe: if timeframe:
pair_interval = [pair for pair in pair_interval if pair[1] == 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: if candletype:
pair_interval = [pair for pair in pair_interval if pair[2] == candletype] pair_interval = [pair for pair in pair_interval if pair[2] == candletype]
else: 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]) 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', []) informative_pairs = getattr(fn, '_ft_informative', [])
# TODO-lev: Add candle_type to InformativeData # TODO-lev: Add candle_type to InformativeData
informative_pairs.append(InformativeData(_asset, _timeframe, _fmt, _ffill, informative_pairs.append(InformativeData(_asset, _timeframe, _fmt, _ffill,
CandleType.SPOT_)) CandleType.SPOT))
setattr(fn, '_ft_informative', informative_pairs) setattr(fn, '_ft_informative', informative_pairs)
return fn return fn
return decorator return decorator

View File

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

View File

@ -1340,7 +1340,7 @@ def test_start_list_data(testdatadir, capsys):
captured = capsys.readouterr() captured = capsys.readouterr()
assert "Found 17 pair / timeframe combinations." in captured.out assert "Found 17 pair / timeframe combinations." in captured.out
assert "\n| Pair | Timeframe | Type |\n" in captured.out assert "\n| Pair | Timeframe | Type |\n" in captured.out
assert "\n| UNITTEST/BTC | 1m, 5m, 8m, 30m | |\n" in captured.out assert "\n| UNITTEST/BTC | 1m, 5m, 8m, 30m | spot |\n" in captured.out
args = [ args = [
"list-data", "list-data",
@ -1357,7 +1357,7 @@ def test_start_list_data(testdatadir, capsys):
assert "Found 2 pair / timeframe combinations." in captured.out assert "Found 2 pair / timeframe combinations." in captured.out
assert "\n| Pair | Timeframe | Type |\n" in captured.out assert "\n| Pair | Timeframe | Type |\n" in captured.out
assert "UNITTEST/BTC" not in captured.out assert "UNITTEST/BTC" not in captured.out
assert "\n| XRP/ETH | 1m, 5m | |\n" in captured.out assert "\n| XRP/ETH | 1m, 5m | spot |\n" in captured.out
args = [ args = [
"list-data", "list-data",

View File

@ -20,10 +20,10 @@ def test_dp_ohlcv(mocker, default_conf, ohlcv_history, candle_type):
default_conf["runmode"] = RunMode.DRY_RUN default_conf["runmode"] = RunMode.DRY_RUN
timeframe = default_conf["timeframe"] timeframe = default_conf["timeframe"]
exchange = get_patched_exchange(mocker, default_conf) exchange = get_patched_exchange(mocker, default_conf)
exchange._klines[("XRP/BTC", timeframe, candle_type)] = ohlcv_history
exchange._klines[("UNITTEST/BTC", timeframe, candle_type)] = ohlcv_history
candletype = CandleType.from_string(candle_type) candletype = CandleType.from_string(candle_type)
exchange._klines[("XRP/BTC", timeframe, candletype)] = ohlcv_history
exchange._klines[("UNITTEST/BTC", timeframe, candletype)] = ohlcv_history
dp = DataProvider(default_conf, exchange) dp = DataProvider(default_conf, exchange)
assert dp.runmode == RunMode.DRY_RUN assert dp.runmode == RunMode.DRY_RUN
assert ohlcv_history.equals(dp.ohlcv("UNITTEST/BTC", timeframe, candle_type=candletype)) assert ohlcv_history.equals(dp.ohlcv("UNITTEST/BTC", timeframe, candle_type=candletype))
@ -96,10 +96,10 @@ def test_get_pair_dataframe(mocker, default_conf, ohlcv_history, candle_type):
default_conf["runmode"] = RunMode.DRY_RUN default_conf["runmode"] = RunMode.DRY_RUN
timeframe = default_conf["timeframe"] timeframe = default_conf["timeframe"]
exchange = get_patched_exchange(mocker, default_conf) exchange = get_patched_exchange(mocker, default_conf)
exchange._klines[("XRP/BTC", timeframe, candle_type)] = ohlcv_history
exchange._klines[("UNITTEST/BTC", timeframe, candle_type)] = ohlcv_history
candletype = CandleType.from_string(candle_type) candletype = CandleType.from_string(candle_type)
exchange._klines[("XRP/BTC", timeframe, candletype)] = ohlcv_history
exchange._klines[("UNITTEST/BTC", timeframe, candletype)] = ohlcv_history
dp = DataProvider(default_conf, exchange) dp = DataProvider(default_conf, exchange)
assert dp.runmode == RunMode.DRY_RUN assert dp.runmode == RunMode.DRY_RUN
assert ohlcv_history.equals(dp.get_pair_dataframe( assert ohlcv_history.equals(dp.get_pair_dataframe(

View File

@ -172,7 +172,7 @@ def test_json_pair_data_filename(pair, expected_result, candle_type):
Path('freqtrade/hello/world'), Path('freqtrade/hello/world'),
pair, pair,
'5m', '5m',
candle_type CandleType.from_string(candle_type)
) )
assert isinstance(fn, Path) assert isinstance(fn, Path)
assert fn == Path(expected_result) assert fn == Path(expected_result)
@ -180,7 +180,7 @@ def test_json_pair_data_filename(pair, expected_result, candle_type):
Path('freqtrade/hello/world'), Path('freqtrade/hello/world'),
pair, pair,
'5m', '5m',
candle_type=candle_type candle_type=CandleType.from_string(candle_type)
) )
assert isinstance(fn, Path) assert isinstance(fn, Path)
assert fn == Path(expected_result + '.gz') assert fn == Path(expected_result + '.gz')
@ -257,7 +257,7 @@ def test_load_cached_data_for_updating(mocker, testdatadir) -> None:
@pytest.mark.parametrize('candle_type,subdir,file_tail', [ @pytest.mark.parametrize('candle_type,subdir,file_tail', [
('mark', 'futures/', '-mark'), ('mark', 'futures/', '-mark'),
('', '', ''), ('spot', '', ''),
]) ])
def test_download_pair_history( def test_download_pair_history(
ohlcv_history_list, ohlcv_history_list,
@ -719,23 +719,23 @@ def test_datahandler_ohlcv_get_available_data(testdatadir):
paircombs = JsonDataHandler.ohlcv_get_available_data(testdatadir, 'spot') paircombs = JsonDataHandler.ohlcv_get_available_data(testdatadir, 'spot')
# Convert to set to avoid failures due to sorting # Convert to set to avoid failures due to sorting
assert set(paircombs) == { assert set(paircombs) == {
('UNITTEST/BTC', '5m', CandleType.SPOT_), ('UNITTEST/BTC', '5m', CandleType.SPOT),
('ETH/BTC', '5m', CandleType.SPOT_), ('ETH/BTC', '5m', CandleType.SPOT),
('XLM/BTC', '5m', CandleType.SPOT_), ('XLM/BTC', '5m', CandleType.SPOT),
('TRX/BTC', '5m', CandleType.SPOT_), ('TRX/BTC', '5m', CandleType.SPOT),
('LTC/BTC', '5m', CandleType.SPOT_), ('LTC/BTC', '5m', CandleType.SPOT),
('XMR/BTC', '5m', CandleType.SPOT_), ('XMR/BTC', '5m', CandleType.SPOT),
('ZEC/BTC', '5m', CandleType.SPOT_), ('ZEC/BTC', '5m', CandleType.SPOT),
('UNITTEST/BTC', '1m', CandleType.SPOT_), ('UNITTEST/BTC', '1m', CandleType.SPOT),
('ADA/BTC', '5m', CandleType.SPOT_), ('ADA/BTC', '5m', CandleType.SPOT),
('ETC/BTC', '5m', CandleType.SPOT_), ('ETC/BTC', '5m', CandleType.SPOT),
('NXT/BTC', '5m', CandleType.SPOT_), ('NXT/BTC', '5m', CandleType.SPOT),
('DASH/BTC', '5m', ''), ('DASH/BTC', '5m', CandleType.SPOT),
('XRP/ETH', '1m', ''), ('XRP/ETH', '1m', CandleType.SPOT),
('XRP/ETH', '5m', ''), ('XRP/ETH', '5m', CandleType.SPOT),
('UNITTEST/BTC', '30m', ''), ('UNITTEST/BTC', '30m', CandleType.SPOT),
('UNITTEST/BTC', '8m', ''), ('UNITTEST/BTC', '8m', CandleType.SPOT),
('NOPAIR/XXX', '4m', ''), ('NOPAIR/XXX', '4m', CandleType.SPOT),
} }
paircombs = JsonDataHandler.ohlcv_get_available_data(testdatadir, 'futures') paircombs = JsonDataHandler.ohlcv_get_available_data(testdatadir, 'futures')
@ -747,9 +747,9 @@ def test_datahandler_ohlcv_get_available_data(testdatadir):
} }
paircombs = JsonGzDataHandler.ohlcv_get_available_data(testdatadir, 'spot') paircombs = JsonGzDataHandler.ohlcv_get_available_data(testdatadir, 'spot')
assert set(paircombs) == {('UNITTEST/BTC', '8m', '')} assert set(paircombs) == {('UNITTEST/BTC', '8m', CandleType.SPOT)}
paircombs = HDF5DataHandler.ohlcv_get_available_data(testdatadir, 'spot') paircombs = HDF5DataHandler.ohlcv_get_available_data(testdatadir, 'spot')
assert set(paircombs) == {('UNITTEST/BTC', '5m', '')} assert set(paircombs) == {('UNITTEST/BTC', '5m', CandleType.SPOT)}
def test_jsondatahandler_trades_get_pairs(testdatadir): def test_jsondatahandler_trades_get_pairs(testdatadir):
@ -774,17 +774,17 @@ def test_jsondatahandler_ohlcv_purge(mocker, testdatadir):
def test_jsondatahandler_ohlcv_load(testdatadir, caplog): def test_jsondatahandler_ohlcv_load(testdatadir, caplog):
dh = JsonDataHandler(testdatadir) dh = JsonDataHandler(testdatadir)
df = dh.ohlcv_load('XRP/ETH', '5m', '') df = dh.ohlcv_load('XRP/ETH', '5m', 'spot')
assert len(df) == 711 assert len(df) == 711
df_mark = dh.ohlcv_load('UNITTEST/USDT', '1h', candle_type="mark") df_mark = dh.ohlcv_load('UNITTEST/USDT', '1h', candle_type="mark")
assert len(df_mark) == 99 assert len(df_mark) == 99
df_no_mark = dh.ohlcv_load('UNITTEST/USDT', '1h', '') df_no_mark = dh.ohlcv_load('UNITTEST/USDT', '1h', 'spot')
assert len(df_no_mark) == 0 assert len(df_no_mark) == 0
# Failure case (empty array) # Failure case (empty array)
df1 = dh.ohlcv_load('NOPAIR/XXX', '4m', '') df1 = dh.ohlcv_load('NOPAIR/XXX', '4m', 'spot')
assert len(df1) == 0 assert len(df1) == 0
assert log_has("Could not load data for NOPAIR/XXX.", caplog) assert log_has("Could not load data for NOPAIR/XXX.", caplog)
assert df.columns.equals(df1.columns) assert df.columns.equals(df1.columns)
@ -903,7 +903,7 @@ def test_hdf5datahandler_trades_purge(mocker, testdatadir):
@pytest.mark.parametrize('pair,timeframe,candle_type,candle_append,startdt,enddt', [ @pytest.mark.parametrize('pair,timeframe,candle_type,candle_append,startdt,enddt', [
# Data goes from 2018-01-10 - 2018-01-30 # Data goes from 2018-01-10 - 2018-01-30
('UNITTEST/BTC', '5m', '', '', '2018-01-15', '2018-01-19'), ('UNITTEST/BTC', '5m', 'spot', '', '2018-01-15', '2018-01-19'),
# Mark data goes from to 2021-11-15 2021-11-19 # Mark data goes from to 2021-11-15 2021-11-19
('UNITTEST/USDT', '1h', 'mark', '-mark', '2021-11-16', '2021-11-18'), ('UNITTEST/USDT', '1h', 'mark', '-mark', '2021-11-16', '2021-11-18'),
]) ])

View File

@ -4,7 +4,7 @@ from freqtrade.enums import CandleType
@pytest.mark.parametrize('input,expected', [ @pytest.mark.parametrize('input,expected', [
('', CandleType.SPOT_), ('', CandleType.SPOT),
('spot', CandleType.SPOT), ('spot', CandleType.SPOT),
(CandleType.SPOT, CandleType.SPOT), (CandleType.SPOT, CandleType.SPOT),
(CandleType.FUTURES, CandleType.FUTURES), (CandleType.FUTURES, CandleType.FUTURES),

View File

@ -462,11 +462,11 @@ def test_VolumePairList_whitelist_gen(mocker, whitelist_conf, shitcoinmarkets, t
ohlcv_history_high_vola.loc[ohlcv_history_high_vola.index == 1, 'close'] = 0.00090 ohlcv_history_high_vola.loc[ohlcv_history_high_vola.index == 1, 'close'] = 0.00090
ohlcv_data = { ohlcv_data = {
('ETH/BTC', '1d', CandleType.SPOT_): ohlcv_history, ('ETH/BTC', '1d', CandleType.SPOT): ohlcv_history,
('TKN/BTC', '1d', CandleType.SPOT_): ohlcv_history, ('TKN/BTC', '1d', CandleType.SPOT): ohlcv_history,
('LTC/BTC', '1d', CandleType.SPOT_): ohlcv_history.append(ohlcv_history), ('LTC/BTC', '1d', CandleType.SPOT): ohlcv_history.append(ohlcv_history),
('XRP/BTC', '1d', CandleType.SPOT_): ohlcv_history, ('XRP/BTC', '1d', CandleType.SPOT): ohlcv_history,
('HOT/BTC', '1d', CandleType.SPOT_): ohlcv_history_high_vola, ('HOT/BTC', '1d', CandleType.SPOT): ohlcv_history_high_vola,
} }
mocker.patch('freqtrade.exchange.Exchange.exchange_has', MagicMock(return_value=True)) mocker.patch('freqtrade.exchange.Exchange.exchange_has', MagicMock(return_value=True))
@ -580,11 +580,11 @@ def test_VolumePairList_range(mocker, whitelist_conf, shitcoinmarkets, tickers,
ohlcv_history_high_volume.loc[:, 'volume'] = 10 ohlcv_history_high_volume.loc[:, 'volume'] = 10
ohlcv_data = { ohlcv_data = {
('ETH/BTC', '1d', CandleType.SPOT_): ohlcv_history, ('ETH/BTC', '1d', CandleType.SPOT): ohlcv_history,
('TKN/BTC', '1d', CandleType.SPOT_): ohlcv_history, ('TKN/BTC', '1d', CandleType.SPOT): ohlcv_history,
('LTC/BTC', '1d', CandleType.SPOT_): ohlcv_history_medium_volume, ('LTC/BTC', '1d', CandleType.SPOT): ohlcv_history_medium_volume,
('XRP/BTC', '1d', CandleType.SPOT_): ohlcv_history_high_vola, ('XRP/BTC', '1d', CandleType.SPOT): ohlcv_history_high_vola,
('HOT/BTC', '1d', CandleType.SPOT_): ohlcv_history_high_volume, ('HOT/BTC', '1d', CandleType.SPOT): ohlcv_history_high_volume,
} }
mocker.patch('freqtrade.exchange.Exchange.exchange_has', MagicMock(return_value=True)) mocker.patch('freqtrade.exchange.Exchange.exchange_has', MagicMock(return_value=True))
@ -856,9 +856,9 @@ def test_agefilter_min_days_listed_too_large(mocker, default_conf, markets, tick
def test_agefilter_caching(mocker, markets, whitelist_conf_agefilter, tickers, ohlcv_history): def test_agefilter_caching(mocker, markets, whitelist_conf_agefilter, tickers, ohlcv_history):
with time_machine.travel("2021-09-01 05:00:00 +00:00") as t: with time_machine.travel("2021-09-01 05:00:00 +00:00") as t:
ohlcv_data = { ohlcv_data = {
('ETH/BTC', '1d', CandleType.SPOT_): ohlcv_history, ('ETH/BTC', '1d', CandleType.SPOT): ohlcv_history,
('TKN/BTC', '1d', CandleType.SPOT_): ohlcv_history, ('TKN/BTC', '1d', CandleType.SPOT): ohlcv_history,
('LTC/BTC', '1d', CandleType.SPOT_): ohlcv_history, ('LTC/BTC', '1d', CandleType.SPOT): ohlcv_history,
} }
mocker.patch.multiple( mocker.patch.multiple(
'freqtrade.exchange.Exchange', 'freqtrade.exchange.Exchange',
@ -880,10 +880,10 @@ def test_agefilter_caching(mocker, markets, whitelist_conf_agefilter, tickers, o
assert freqtrade.exchange.refresh_latest_ohlcv.call_count == 2 assert freqtrade.exchange.refresh_latest_ohlcv.call_count == 2
ohlcv_data = { ohlcv_data = {
('ETH/BTC', '1d', CandleType.SPOT_): ohlcv_history, ('ETH/BTC', '1d', CandleType.SPOT): ohlcv_history,
('TKN/BTC', '1d', CandleType.SPOT_): ohlcv_history, ('TKN/BTC', '1d', CandleType.SPOT): ohlcv_history,
('LTC/BTC', '1d', CandleType.SPOT_): ohlcv_history, ('LTC/BTC', '1d', CandleType.SPOT): ohlcv_history,
('XRP/BTC', '1d', CandleType.SPOT_): ohlcv_history.iloc[[0]], ('XRP/BTC', '1d', CandleType.SPOT): ohlcv_history.iloc[[0]],
} }
mocker.patch('freqtrade.exchange.Exchange.refresh_latest_ohlcv', return_value=ohlcv_data) mocker.patch('freqtrade.exchange.Exchange.refresh_latest_ohlcv', return_value=ohlcv_data)
freqtrade.pairlists.refresh_pairlist() freqtrade.pairlists.refresh_pairlist()
@ -901,10 +901,10 @@ def test_agefilter_caching(mocker, markets, whitelist_conf_agefilter, tickers, o
t.move_to("2021-09-03 01:00:00 +00:00") t.move_to("2021-09-03 01:00:00 +00:00")
# Called once for XRP/BTC # Called once for XRP/BTC
ohlcv_data = { ohlcv_data = {
('ETH/BTC', '1d', CandleType.SPOT_): ohlcv_history, ('ETH/BTC', '1d', CandleType.SPOT): ohlcv_history,
('TKN/BTC', '1d', CandleType.SPOT_): ohlcv_history, ('TKN/BTC', '1d', CandleType.SPOT): ohlcv_history,
('LTC/BTC', '1d', CandleType.SPOT_): ohlcv_history, ('LTC/BTC', '1d', CandleType.SPOT): ohlcv_history,
('XRP/BTC', '1d', CandleType.SPOT_): ohlcv_history, ('XRP/BTC', '1d', CandleType.SPOT): ohlcv_history,
} }
mocker.patch('freqtrade.exchange.Exchange.refresh_latest_ohlcv', return_value=ohlcv_data) mocker.patch('freqtrade.exchange.Exchange.refresh_latest_ohlcv', return_value=ohlcv_data)
freqtrade.pairlists.refresh_pairlist() freqtrade.pairlists.refresh_pairlist()
@ -965,12 +965,12 @@ def test_rangestabilityfilter_caching(mocker, markets, default_conf, tickers, oh
get_tickers=tickers get_tickers=tickers
) )
ohlcv_data = { ohlcv_data = {
('ETH/BTC', '1d', CandleType.SPOT_): ohlcv_history, ('ETH/BTC', '1d', CandleType.SPOT): ohlcv_history,
('TKN/BTC', '1d', CandleType.SPOT_): ohlcv_history, ('TKN/BTC', '1d', CandleType.SPOT): ohlcv_history,
('LTC/BTC', '1d', CandleType.SPOT_): ohlcv_history, ('LTC/BTC', '1d', CandleType.SPOT): ohlcv_history,
('XRP/BTC', '1d', CandleType.SPOT_): ohlcv_history, ('XRP/BTC', '1d', CandleType.SPOT): ohlcv_history,
('HOT/BTC', '1d', CandleType.SPOT_): ohlcv_history, ('HOT/BTC', '1d', CandleType.SPOT): ohlcv_history,
('BLK/BTC', '1d', CandleType.SPOT_): ohlcv_history, ('BLK/BTC', '1d', CandleType.SPOT): ohlcv_history,
} }
mocker.patch.multiple( mocker.patch.multiple(
'freqtrade.exchange.Exchange', 'freqtrade.exchange.Exchange',

View File

@ -1356,7 +1356,7 @@ def test_list_available_pairs(botclient):
ftbot.config['trading_mode'] = 'futures' ftbot.config['trading_mode'] = 'futures'
rc = client_get( rc = client_get(
client, f"{BASE_URI}/available_pairs?timeframe=1h&candletype=futures") client, f"{BASE_URI}/available_pairs?timeframe=1h")
assert_response(rc) assert_response(rc)
assert rc.json()['length'] == 1 assert rc.json()['length'] == 1
assert rc.json()['pairs'] == ['XRP/USDT'] assert rc.json()['pairs'] == ['XRP/USDT']

View File

@ -11,8 +11,7 @@ from pandas import DataFrame
from freqtrade.configuration import TimeRange from freqtrade.configuration import TimeRange
from freqtrade.data.dataprovider import DataProvider from freqtrade.data.dataprovider import DataProvider
from freqtrade.data.history import load_data from freqtrade.data.history import load_data
from freqtrade.enums import SellType from freqtrade.enums import SellType, SignalDirection
from freqtrade.enums.signaltype import SignalDirection
from freqtrade.exceptions import OperationalException, StrategyError from freqtrade.exceptions import OperationalException, StrategyError
from freqtrade.optimize.space import SKDecimal from freqtrade.optimize.space import SKDecimal
from freqtrade.persistence import PairLocks, Trade from freqtrade.persistence import PairLocks, Trade

View File

@ -152,18 +152,18 @@ def test_informative_decorator(mocker, default_conf):
test_data_30m = generate_test_data('30m', 40) test_data_30m = generate_test_data('30m', 40)
test_data_1h = generate_test_data('1h', 40) test_data_1h = generate_test_data('1h', 40)
data = { data = {
('XRP/USDT', '5m', CandleType.SPOT_): test_data_5m, ('XRP/USDT', '5m', CandleType.SPOT): test_data_5m,
('XRP/USDT', '30m', CandleType.SPOT_): test_data_30m, ('XRP/USDT', '30m', CandleType.SPOT): test_data_30m,
('XRP/USDT', '1h', CandleType.SPOT_): test_data_1h, ('XRP/USDT', '1h', CandleType.SPOT): test_data_1h,
('LTC/USDT', '5m', CandleType.SPOT_): test_data_5m, ('LTC/USDT', '5m', CandleType.SPOT): test_data_5m,
('LTC/USDT', '30m', CandleType.SPOT_): test_data_30m, ('LTC/USDT', '30m', CandleType.SPOT): test_data_30m,
('LTC/USDT', '1h', CandleType.SPOT_): test_data_1h, ('LTC/USDT', '1h', CandleType.SPOT): test_data_1h,
('NEO/USDT', '30m', CandleType.SPOT_): test_data_30m, ('NEO/USDT', '30m', CandleType.SPOT): test_data_30m,
('NEO/USDT', '5m', CandleType.SPOT_): test_data_5m, ('NEO/USDT', '5m', CandleType.SPOT): test_data_5m,
('NEO/USDT', '1h', CandleType.SPOT_): test_data_1h, ('NEO/USDT', '1h', CandleType.SPOT): test_data_1h,
('ETH/USDT', '1h', CandleType.SPOT_): test_data_1h, ('ETH/USDT', '1h', CandleType.SPOT): test_data_1h,
('ETH/USDT', '30m', CandleType.SPOT_): test_data_30m, ('ETH/USDT', '30m', CandleType.SPOT): test_data_30m,
('ETH/BTC', '1h', CandleType.SPOT_): test_data_1h, ('ETH/BTC', '1h', CandleType.SPOT): test_data_1h,
} }
from .strats.informative_decorator_strategy import InformativeDecoratorTest from .strats.informative_decorator_strategy import InformativeDecoratorTest
default_conf['stake_currency'] = 'USDT' default_conf['stake_currency'] = 'USDT'
@ -176,25 +176,26 @@ def test_informative_decorator(mocker, default_conf):
assert len(strategy._ft_informative) == 6 # Equal to number of decorators used assert len(strategy._ft_informative) == 6 # Equal to number of decorators used
informative_pairs = [ informative_pairs = [
('XRP/USDT', '1h', CandleType.SPOT_), ('XRP/USDT', '1h', CandleType.SPOT),
('LTC/USDT', '1h', CandleType.SPOT_), ('LTC/USDT', '1h', CandleType.SPOT),
('XRP/USDT', '30m', CandleType.SPOT_), ('XRP/USDT', '30m', CandleType.SPOT),
('LTC/USDT', '30m', CandleType.SPOT_), ('LTC/USDT', '30m', CandleType.SPOT),
('NEO/USDT', '1h', CandleType.SPOT_), ('NEO/USDT', '1h', CandleType.SPOT),
('NEO/USDT', '30m', CandleType.SPOT_), ('NEO/USDT', '30m', CandleType.SPOT),
('NEO/USDT', '5m', CandleType.SPOT_), ('NEO/USDT', '5m', CandleType.SPOT),
('ETH/BTC', '1h', CandleType.SPOT_), ('ETH/BTC', '1h', CandleType.SPOT),
('ETH/USDT', '30m', CandleType.SPOT_)] ('ETH/USDT', '30m', CandleType.SPOT)]
for inf_pair in informative_pairs: for inf_pair in informative_pairs:
assert inf_pair in strategy.gather_informative_pairs() assert inf_pair in strategy.gather_informative_pairs()
def test_historic_ohlcv(pair, timeframe, candle_type): def test_historic_ohlcv(pair, timeframe, candle_type):
return data[(pair, timeframe or strategy.timeframe, candle_type)].copy() return data[
(pair, timeframe or strategy.timeframe, CandleType.from_string(candle_type))].copy()
mocker.patch('freqtrade.data.dataprovider.DataProvider.historic_ohlcv', mocker.patch('freqtrade.data.dataprovider.DataProvider.historic_ohlcv',
side_effect=test_historic_ohlcv) side_effect=test_historic_ohlcv)
analyzed = strategy.advise_all_indicators( analyzed = strategy.advise_all_indicators(
{p: data[(p, strategy.timeframe, CandleType.SPOT_)] for p in ('XRP/USDT', 'LTC/USDT')}) {p: data[(p, strategy.timeframe, CandleType.SPOT)] for p in ('XRP/USDT', 'LTC/USDT')})
expected_columns = [ expected_columns = [
'rsi_1h', 'rsi_30m', # Stacked informative decorators 'rsi_1h', 'rsi_30m', # Stacked informative decorators
'neo_usdt_rsi_1h', # NEO 1h informative 'neo_usdt_rsi_1h', # NEO 1h informative

View File

@ -681,7 +681,10 @@ def test_process_informative_pairs_added(default_conf_usdt, ticker_usdt, mocker)
create_order=MagicMock(side_effect=TemporaryError), create_order=MagicMock(side_effect=TemporaryError),
refresh_latest_ohlcv=refresh_mock, refresh_latest_ohlcv=refresh_mock,
) )
inf_pairs = MagicMock(return_value=[("BTC/ETH", '1m', ''), ("ETH/USDT", "1h", '')]) inf_pairs = MagicMock(return_value=[
("BTC/ETH", '1m', CandleType.SPOT),
("ETH/USDT", "1h", CandleType.SPOT)
])
mocker.patch.multiple( mocker.patch.multiple(
'freqtrade.strategy.interface.IStrategy', 'freqtrade.strategy.interface.IStrategy',
get_exit_signal=MagicMock(return_value=(False, False)), get_exit_signal=MagicMock(return_value=(False, False)),
@ -696,8 +699,8 @@ def test_process_informative_pairs_added(default_conf_usdt, ticker_usdt, mocker)
freqtrade.process() freqtrade.process()
assert inf_pairs.call_count == 1 assert inf_pairs.call_count == 1
assert refresh_mock.call_count == 1 assert refresh_mock.call_count == 1
assert ("BTC/ETH", "1m", CandleType.SPOT_) in refresh_mock.call_args[0][0] assert ("BTC/ETH", "1m", CandleType.SPOT) in refresh_mock.call_args[0][0]
assert ("ETH/USDT", "1h", CandleType.SPOT_) in refresh_mock.call_args[0][0] assert ("ETH/USDT", "1h", CandleType.SPOT) in refresh_mock.call_args[0][0]
assert ("ETH/USDT", default_conf_usdt["timeframe"], assert ("ETH/USDT", default_conf_usdt["timeframe"],
CandleType.SPOT) in refresh_mock.call_args[0][0] CandleType.SPOT) in refresh_mock.call_args[0][0]