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

@@ -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",

View File

@@ -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(

View File

@@ -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'),
])

View File

@@ -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),

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_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',

View File

@@ -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']

View File

@@ -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

View File

@@ -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

View File

@@ -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]