Remove SPOT_ candletype
This commit is contained in:
parent
d89cbda7b8
commit
9b9d61c6d6
@ -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}"
|
||||
|
||||
|
@ -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(
|
||||
|
@ -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}"
|
||||
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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])
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -1340,7 +1340,7 @@ def test_start_list_data(testdatadir, capsys):
|
||||
captured = capsys.readouterr()
|
||||
assert "Found 17 pair / timeframe combinations." 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 = [
|
||||
"list-data",
|
||||
@ -1357,7 +1357,7 @@ def test_start_list_data(testdatadir, capsys):
|
||||
assert "Found 2 pair / timeframe combinations." in captured.out
|
||||
assert "\n| Pair | Timeframe | Type |\n" 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 = [
|
||||
"list-data",
|
||||
|
@ -20,10 +20,10 @@ def test_dp_ohlcv(mocker, default_conf, ohlcv_history, candle_type):
|
||||
default_conf["runmode"] = RunMode.DRY_RUN
|
||||
timeframe = default_conf["timeframe"]
|
||||
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)
|
||||
exchange._klines[("XRP/BTC", timeframe, candletype)] = ohlcv_history
|
||||
exchange._klines[("UNITTEST/BTC", timeframe, candletype)] = ohlcv_history
|
||||
|
||||
dp = DataProvider(default_conf, exchange)
|
||||
assert dp.runmode == RunMode.DRY_RUN
|
||||
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
|
||||
timeframe = default_conf["timeframe"]
|
||||
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)
|
||||
exchange._klines[("XRP/BTC", timeframe, candletype)] = ohlcv_history
|
||||
exchange._klines[("UNITTEST/BTC", timeframe, candletype)] = ohlcv_history
|
||||
|
||||
dp = DataProvider(default_conf, exchange)
|
||||
assert dp.runmode == RunMode.DRY_RUN
|
||||
assert ohlcv_history.equals(dp.get_pair_dataframe(
|
||||
|
@ -172,7 +172,7 @@ def test_json_pair_data_filename(pair, expected_result, candle_type):
|
||||
Path('freqtrade/hello/world'),
|
||||
pair,
|
||||
'5m',
|
||||
candle_type
|
||||
CandleType.from_string(candle_type)
|
||||
)
|
||||
assert isinstance(fn, Path)
|
||||
assert fn == Path(expected_result)
|
||||
@ -180,7 +180,7 @@ def test_json_pair_data_filename(pair, expected_result, candle_type):
|
||||
Path('freqtrade/hello/world'),
|
||||
pair,
|
||||
'5m',
|
||||
candle_type=candle_type
|
||||
candle_type=CandleType.from_string(candle_type)
|
||||
)
|
||||
assert isinstance(fn, Path)
|
||||
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', [
|
||||
('mark', 'futures/', '-mark'),
|
||||
('', '', ''),
|
||||
('spot', '', ''),
|
||||
])
|
||||
def test_download_pair_history(
|
||||
ohlcv_history_list,
|
||||
@ -719,23 +719,23 @@ def test_datahandler_ohlcv_get_available_data(testdatadir):
|
||||
paircombs = JsonDataHandler.ohlcv_get_available_data(testdatadir, 'spot')
|
||||
# Convert to set to avoid failures due to sorting
|
||||
assert set(paircombs) == {
|
||||
('UNITTEST/BTC', '5m', CandleType.SPOT_),
|
||||
('ETH/BTC', '5m', CandleType.SPOT_),
|
||||
('XLM/BTC', '5m', CandleType.SPOT_),
|
||||
('TRX/BTC', '5m', CandleType.SPOT_),
|
||||
('LTC/BTC', '5m', CandleType.SPOT_),
|
||||
('XMR/BTC', '5m', CandleType.SPOT_),
|
||||
('ZEC/BTC', '5m', CandleType.SPOT_),
|
||||
('UNITTEST/BTC', '1m', CandleType.SPOT_),
|
||||
('ADA/BTC', '5m', CandleType.SPOT_),
|
||||
('ETC/BTC', '5m', CandleType.SPOT_),
|
||||
('NXT/BTC', '5m', CandleType.SPOT_),
|
||||
('DASH/BTC', '5m', ''),
|
||||
('XRP/ETH', '1m', ''),
|
||||
('XRP/ETH', '5m', ''),
|
||||
('UNITTEST/BTC', '30m', ''),
|
||||
('UNITTEST/BTC', '8m', ''),
|
||||
('NOPAIR/XXX', '4m', ''),
|
||||
('UNITTEST/BTC', '5m', CandleType.SPOT),
|
||||
('ETH/BTC', '5m', CandleType.SPOT),
|
||||
('XLM/BTC', '5m', CandleType.SPOT),
|
||||
('TRX/BTC', '5m', CandleType.SPOT),
|
||||
('LTC/BTC', '5m', CandleType.SPOT),
|
||||
('XMR/BTC', '5m', CandleType.SPOT),
|
||||
('ZEC/BTC', '5m', CandleType.SPOT),
|
||||
('UNITTEST/BTC', '1m', CandleType.SPOT),
|
||||
('ADA/BTC', '5m', CandleType.SPOT),
|
||||
('ETC/BTC', '5m', CandleType.SPOT),
|
||||
('NXT/BTC', '5m', CandleType.SPOT),
|
||||
('DASH/BTC', '5m', CandleType.SPOT),
|
||||
('XRP/ETH', '1m', CandleType.SPOT),
|
||||
('XRP/ETH', '5m', CandleType.SPOT),
|
||||
('UNITTEST/BTC', '30m', CandleType.SPOT),
|
||||
('UNITTEST/BTC', '8m', CandleType.SPOT),
|
||||
('NOPAIR/XXX', '4m', CandleType.SPOT),
|
||||
}
|
||||
|
||||
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')
|
||||
assert set(paircombs) == {('UNITTEST/BTC', '8m', '')}
|
||||
assert set(paircombs) == {('UNITTEST/BTC', '8m', CandleType.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):
|
||||
@ -774,17 +774,17 @@ def test_jsondatahandler_ohlcv_purge(mocker, testdatadir):
|
||||
|
||||
def test_jsondatahandler_ohlcv_load(testdatadir, caplog):
|
||||
dh = JsonDataHandler(testdatadir)
|
||||
df = dh.ohlcv_load('XRP/ETH', '5m', '')
|
||||
df = dh.ohlcv_load('XRP/ETH', '5m', 'spot')
|
||||
assert len(df) == 711
|
||||
|
||||
df_mark = dh.ohlcv_load('UNITTEST/USDT', '1h', candle_type="mark")
|
||||
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
|
||||
|
||||
# Failure case (empty array)
|
||||
df1 = dh.ohlcv_load('NOPAIR/XXX', '4m', '')
|
||||
df1 = dh.ohlcv_load('NOPAIR/XXX', '4m', 'spot')
|
||||
assert len(df1) == 0
|
||||
assert log_has("Could not load data for NOPAIR/XXX.", caplog)
|
||||
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', [
|
||||
# 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
|
||||
('UNITTEST/USDT', '1h', 'mark', '-mark', '2021-11-16', '2021-11-18'),
|
||||
])
|
||||
|
@ -4,7 +4,7 @@ from freqtrade.enums import CandleType
|
||||
|
||||
|
||||
@pytest.mark.parametrize('input,expected', [
|
||||
('', CandleType.SPOT_),
|
||||
('', CandleType.SPOT),
|
||||
('spot', CandleType.SPOT),
|
||||
(CandleType.SPOT, CandleType.SPOT),
|
||||
(CandleType.FUTURES, CandleType.FUTURES),
|
||||
|
@ -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_data = {
|
||||
('ETH/BTC', '1d', CandleType.SPOT_): ohlcv_history,
|
||||
('TKN/BTC', '1d', CandleType.SPOT_): ohlcv_history,
|
||||
('LTC/BTC', '1d', CandleType.SPOT_): ohlcv_history.append(ohlcv_history),
|
||||
('XRP/BTC', '1d', CandleType.SPOT_): ohlcv_history,
|
||||
('HOT/BTC', '1d', CandleType.SPOT_): ohlcv_history_high_vola,
|
||||
('ETH/BTC', '1d', CandleType.SPOT): ohlcv_history,
|
||||
('TKN/BTC', '1d', CandleType.SPOT): ohlcv_history,
|
||||
('LTC/BTC', '1d', CandleType.SPOT): ohlcv_history.append(ohlcv_history),
|
||||
('XRP/BTC', '1d', CandleType.SPOT): ohlcv_history,
|
||||
('HOT/BTC', '1d', CandleType.SPOT): ohlcv_history_high_vola,
|
||||
}
|
||||
|
||||
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_data = {
|
||||
('ETH/BTC', '1d', CandleType.SPOT_): ohlcv_history,
|
||||
('TKN/BTC', '1d', CandleType.SPOT_): ohlcv_history,
|
||||
('LTC/BTC', '1d', CandleType.SPOT_): ohlcv_history_medium_volume,
|
||||
('XRP/BTC', '1d', CandleType.SPOT_): ohlcv_history_high_vola,
|
||||
('HOT/BTC', '1d', CandleType.SPOT_): ohlcv_history_high_volume,
|
||||
('ETH/BTC', '1d', CandleType.SPOT): ohlcv_history,
|
||||
('TKN/BTC', '1d', CandleType.SPOT): ohlcv_history,
|
||||
('LTC/BTC', '1d', CandleType.SPOT): ohlcv_history_medium_volume,
|
||||
('XRP/BTC', '1d', CandleType.SPOT): ohlcv_history_high_vola,
|
||||
('HOT/BTC', '1d', CandleType.SPOT): ohlcv_history_high_volume,
|
||||
}
|
||||
|
||||
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):
|
||||
with time_machine.travel("2021-09-01 05:00:00 +00:00") as t:
|
||||
ohlcv_data = {
|
||||
('ETH/BTC', '1d', CandleType.SPOT_): ohlcv_history,
|
||||
('TKN/BTC', '1d', CandleType.SPOT_): ohlcv_history,
|
||||
('LTC/BTC', '1d', CandleType.SPOT_): ohlcv_history,
|
||||
('ETH/BTC', '1d', CandleType.SPOT): ohlcv_history,
|
||||
('TKN/BTC', '1d', CandleType.SPOT): ohlcv_history,
|
||||
('LTC/BTC', '1d', CandleType.SPOT): ohlcv_history,
|
||||
}
|
||||
mocker.patch.multiple(
|
||||
'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
|
||||
|
||||
ohlcv_data = {
|
||||
('ETH/BTC', '1d', CandleType.SPOT_): ohlcv_history,
|
||||
('TKN/BTC', '1d', CandleType.SPOT_): ohlcv_history,
|
||||
('LTC/BTC', '1d', CandleType.SPOT_): ohlcv_history,
|
||||
('XRP/BTC', '1d', CandleType.SPOT_): ohlcv_history.iloc[[0]],
|
||||
('ETH/BTC', '1d', CandleType.SPOT): ohlcv_history,
|
||||
('TKN/BTC', '1d', CandleType.SPOT): ohlcv_history,
|
||||
('LTC/BTC', '1d', CandleType.SPOT): ohlcv_history,
|
||||
('XRP/BTC', '1d', CandleType.SPOT): ohlcv_history.iloc[[0]],
|
||||
}
|
||||
mocker.patch('freqtrade.exchange.Exchange.refresh_latest_ohlcv', return_value=ohlcv_data)
|
||||
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")
|
||||
# Called once for XRP/BTC
|
||||
ohlcv_data = {
|
||||
('ETH/BTC', '1d', CandleType.SPOT_): ohlcv_history,
|
||||
('TKN/BTC', '1d', CandleType.SPOT_): ohlcv_history,
|
||||
('LTC/BTC', '1d', CandleType.SPOT_): ohlcv_history,
|
||||
('XRP/BTC', '1d', CandleType.SPOT_): ohlcv_history,
|
||||
('ETH/BTC', '1d', CandleType.SPOT): ohlcv_history,
|
||||
('TKN/BTC', '1d', CandleType.SPOT): ohlcv_history,
|
||||
('LTC/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)
|
||||
freqtrade.pairlists.refresh_pairlist()
|
||||
@ -965,12 +965,12 @@ def test_rangestabilityfilter_caching(mocker, markets, default_conf, tickers, oh
|
||||
get_tickers=tickers
|
||||
)
|
||||
ohlcv_data = {
|
||||
('ETH/BTC', '1d', CandleType.SPOT_): ohlcv_history,
|
||||
('TKN/BTC', '1d', CandleType.SPOT_): ohlcv_history,
|
||||
('LTC/BTC', '1d', CandleType.SPOT_): ohlcv_history,
|
||||
('XRP/BTC', '1d', CandleType.SPOT_): ohlcv_history,
|
||||
('HOT/BTC', '1d', CandleType.SPOT_): ohlcv_history,
|
||||
('BLK/BTC', '1d', CandleType.SPOT_): ohlcv_history,
|
||||
('ETH/BTC', '1d', CandleType.SPOT): ohlcv_history,
|
||||
('TKN/BTC', '1d', CandleType.SPOT): ohlcv_history,
|
||||
('LTC/BTC', '1d', CandleType.SPOT): ohlcv_history,
|
||||
('XRP/BTC', '1d', CandleType.SPOT): ohlcv_history,
|
||||
('HOT/BTC', '1d', CandleType.SPOT): ohlcv_history,
|
||||
('BLK/BTC', '1d', CandleType.SPOT): ohlcv_history,
|
||||
}
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
|
@ -1356,7 +1356,7 @@ def test_list_available_pairs(botclient):
|
||||
|
||||
ftbot.config['trading_mode'] = 'futures'
|
||||
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 rc.json()['length'] == 1
|
||||
assert rc.json()['pairs'] == ['XRP/USDT']
|
||||
|
@ -11,8 +11,7 @@ from pandas import DataFrame
|
||||
from freqtrade.configuration import TimeRange
|
||||
from freqtrade.data.dataprovider import DataProvider
|
||||
from freqtrade.data.history import load_data
|
||||
from freqtrade.enums import SellType
|
||||
from freqtrade.enums.signaltype import SignalDirection
|
||||
from freqtrade.enums import SellType, SignalDirection
|
||||
from freqtrade.exceptions import OperationalException, StrategyError
|
||||
from freqtrade.optimize.space import SKDecimal
|
||||
from freqtrade.persistence import PairLocks, Trade
|
||||
|
@ -152,18 +152,18 @@ def test_informative_decorator(mocker, default_conf):
|
||||
test_data_30m = generate_test_data('30m', 40)
|
||||
test_data_1h = generate_test_data('1h', 40)
|
||||
data = {
|
||||
('XRP/USDT', '5m', CandleType.SPOT_): test_data_5m,
|
||||
('XRP/USDT', '30m', CandleType.SPOT_): test_data_30m,
|
||||
('XRP/USDT', '1h', CandleType.SPOT_): test_data_1h,
|
||||
('LTC/USDT', '5m', CandleType.SPOT_): test_data_5m,
|
||||
('LTC/USDT', '30m', CandleType.SPOT_): test_data_30m,
|
||||
('LTC/USDT', '1h', CandleType.SPOT_): test_data_1h,
|
||||
('NEO/USDT', '30m', CandleType.SPOT_): test_data_30m,
|
||||
('NEO/USDT', '5m', CandleType.SPOT_): test_data_5m,
|
||||
('NEO/USDT', '1h', CandleType.SPOT_): test_data_1h,
|
||||
('ETH/USDT', '1h', CandleType.SPOT_): test_data_1h,
|
||||
('ETH/USDT', '30m', CandleType.SPOT_): test_data_30m,
|
||||
('ETH/BTC', '1h', CandleType.SPOT_): test_data_1h,
|
||||
('XRP/USDT', '5m', CandleType.SPOT): test_data_5m,
|
||||
('XRP/USDT', '30m', CandleType.SPOT): test_data_30m,
|
||||
('XRP/USDT', '1h', CandleType.SPOT): test_data_1h,
|
||||
('LTC/USDT', '5m', CandleType.SPOT): test_data_5m,
|
||||
('LTC/USDT', '30m', CandleType.SPOT): test_data_30m,
|
||||
('LTC/USDT', '1h', CandleType.SPOT): test_data_1h,
|
||||
('NEO/USDT', '30m', CandleType.SPOT): test_data_30m,
|
||||
('NEO/USDT', '5m', CandleType.SPOT): test_data_5m,
|
||||
('NEO/USDT', '1h', CandleType.SPOT): test_data_1h,
|
||||
('ETH/USDT', '1h', CandleType.SPOT): test_data_1h,
|
||||
('ETH/USDT', '30m', CandleType.SPOT): test_data_30m,
|
||||
('ETH/BTC', '1h', CandleType.SPOT): test_data_1h,
|
||||
}
|
||||
from .strats.informative_decorator_strategy import InformativeDecoratorTest
|
||||
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
|
||||
informative_pairs = [
|
||||
('XRP/USDT', '1h', CandleType.SPOT_),
|
||||
('LTC/USDT', '1h', CandleType.SPOT_),
|
||||
('XRP/USDT', '30m', CandleType.SPOT_),
|
||||
('LTC/USDT', '30m', CandleType.SPOT_),
|
||||
('NEO/USDT', '1h', CandleType.SPOT_),
|
||||
('NEO/USDT', '30m', CandleType.SPOT_),
|
||||
('NEO/USDT', '5m', CandleType.SPOT_),
|
||||
('ETH/BTC', '1h', CandleType.SPOT_),
|
||||
('ETH/USDT', '30m', CandleType.SPOT_)]
|
||||
('XRP/USDT', '1h', CandleType.SPOT),
|
||||
('LTC/USDT', '1h', CandleType.SPOT),
|
||||
('XRP/USDT', '30m', CandleType.SPOT),
|
||||
('LTC/USDT', '30m', CandleType.SPOT),
|
||||
('NEO/USDT', '1h', CandleType.SPOT),
|
||||
('NEO/USDT', '30m', CandleType.SPOT),
|
||||
('NEO/USDT', '5m', CandleType.SPOT),
|
||||
('ETH/BTC', '1h', CandleType.SPOT),
|
||||
('ETH/USDT', '30m', CandleType.SPOT)]
|
||||
for inf_pair in informative_pairs:
|
||||
assert inf_pair in strategy.gather_informative_pairs()
|
||||
|
||||
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',
|
||||
side_effect=test_historic_ohlcv)
|
||||
|
||||
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 = [
|
||||
'rsi_1h', 'rsi_30m', # Stacked informative decorators
|
||||
'neo_usdt_rsi_1h', # NEO 1h informative
|
||||
|
@ -681,7 +681,10 @@ def test_process_informative_pairs_added(default_conf_usdt, ticker_usdt, mocker)
|
||||
create_order=MagicMock(side_effect=TemporaryError),
|
||||
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(
|
||||
'freqtrade.strategy.interface.IStrategy',
|
||||
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()
|
||||
assert inf_pairs.call_count == 1
|
||||
assert refresh_mock.call_count == 1
|
||||
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 ("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", default_conf_usdt["timeframe"],
|
||||
CandleType.SPOT) in refresh_mock.call_args[0][0]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user