Improve and fix pair detection from available data
This commit is contained in:
parent
0d1324718c
commit
0d6c933935
@ -173,7 +173,7 @@ class IDataHandler(ABC):
|
||||
Rebuild pair name from filename
|
||||
Assumes a asset name of max. 7 length to also support BTC-PERP and BTC-PERP:USD names.
|
||||
"""
|
||||
res = re.sub(r'^(.{1,7})(_)', r'\g<1>/', pair, 1)
|
||||
res = re.sub(r'^(([A-Za-z]{1,10})|^([A-Za-z\-]{1,6}))(_)', r'\g<1>/', pair, 1)
|
||||
res = re.sub('_', ':', res, 1)
|
||||
return res
|
||||
|
||||
|
@ -247,7 +247,7 @@ def get_strategy(strategy: str, config=Depends(get_config)):
|
||||
|
||||
@router.get('/available_pairs', response_model=AvailablePairs, tags=['candle data'])
|
||||
def list_available_pairs(timeframe: Optional[str] = None, stake_currency: Optional[str] = None,
|
||||
config=Depends(get_config)):
|
||||
candletype: Optional[str] = None, config=Depends(get_config)):
|
||||
|
||||
dh = get_datahandler(config['datadir'], config.get('dataformat_ohlcv', None))
|
||||
|
||||
@ -257,6 +257,11 @@ def list_available_pairs(timeframe: Optional[str] = None, stake_currency: Option
|
||||
pair_interval = [pair for pair in pair_interval if pair[1] == timeframe]
|
||||
if stake_currency:
|
||||
pair_interval = [pair for pair in pair_interval if pair[0].endswith(stake_currency)]
|
||||
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] == '']
|
||||
|
||||
pair_interval = sorted(pair_interval, key=lambda x: x[0])
|
||||
|
||||
pairs = list({x[0] for x in pair_interval})
|
||||
|
@ -699,6 +699,7 @@ def test_datahandler_ohlcv_regex(filename, pair, timeframe, candletype):
|
||||
('XRP_USDT_USDT', 'XRP/USDT:USDT'), # futures
|
||||
('BTC-PERP', 'BTC-PERP'),
|
||||
('BTC-PERP_USDT', 'BTC-PERP:USDT'), # potential FTX case
|
||||
('UNITTEST_USDT', 'UNITTEST/USDT'),
|
||||
])
|
||||
def test_rebuild_pair_from_filename(input, expected):
|
||||
|
||||
|
@ -1332,7 +1332,7 @@ def test_list_available_pairs(botclient):
|
||||
rc = client_get(client, f"{BASE_URI}/available_pairs")
|
||||
|
||||
assert_response(rc)
|
||||
assert rc.json()['length'] == 15
|
||||
assert rc.json()['length'] == 14
|
||||
assert isinstance(rc.json()['pairs'], list)
|
||||
|
||||
rc = client_get(client, f"{BASE_URI}/available_pairs?timeframe=5m")
|
||||
@ -1352,11 +1352,11 @@ def test_list_available_pairs(botclient):
|
||||
assert len(rc.json()['pair_interval']) == 1
|
||||
|
||||
rc = client_get(
|
||||
client, f"{BASE_URI}/available_pairs?stake_currency=USDT&timeframe=1h&type=mark")
|
||||
client, f"{BASE_URI}/available_pairs?timeframe=1h&candletype=mark")
|
||||
assert_response(rc)
|
||||
assert rc.json()['length'] == 2
|
||||
assert rc.json()['pairs'] == ['UNITTEST/USDT', 'XRP/USDT']
|
||||
assert len(rc.json()['pair_interval']) == 3 # TODO-lev: What is pair_interval? Should it be 3?
|
||||
assert len(rc.json()['pair_interval']) == 2
|
||||
|
||||
|
||||
def test_sysinfo(botclient):
|
||||
|
Loading…
Reference in New Issue
Block a user