Added failing fill_leverage_brackets test to test_kraken
This commit is contained in:
parent
01263663be
commit
c5d97d07a8
@ -135,7 +135,7 @@ class Kraken(Exchange):
|
||||
"""
|
||||
leverages = {}
|
||||
try:
|
||||
for pair, market in self.markets.items():
|
||||
for pair, market in self._api.markets.items():
|
||||
info = market['info']
|
||||
leverage_buy = info['leverage_buy']
|
||||
leverage_sell = info['leverage_sell']
|
||||
|
@ -196,6 +196,7 @@ def test_get_order_id(mocker, default_conf):
|
||||
|
||||
|
||||
def test_fill_leverage_brackets(default_conf, mocker):
|
||||
# FTX only has one account wide leverage, so there's no leverage brackets
|
||||
exchange = get_patched_exchange(mocker, default_conf, id="ftx")
|
||||
exchange.fill_leverage_brackets()
|
||||
assert bool(exchange._leverage_brackets) is False
|
||||
|
@ -270,3 +270,233 @@ def test_get_max_leverage_kraken(default_conf, mocker, pair, nominal_value, max_
|
||||
'ZEC/USD': ['2']
|
||||
}
|
||||
assert exchange.get_max_leverage(pair, nominal_value) == max_lev
|
||||
|
||||
|
||||
def test_fill_leverage_brackets_kraken(default_conf, mocker):
|
||||
api_mock = MagicMock()
|
||||
api_mock.load_markets = MagicMock(return_value={{
|
||||
"ADA/BTC": {'active': True,
|
||||
'altname': 'ADAXBT',
|
||||
'base': 'ADA',
|
||||
'baseId': 'ADA',
|
||||
'darkpool': False,
|
||||
'id': 'ADAXBT',
|
||||
'info': {'aclass_base': 'currency',
|
||||
'aclass_quote': 'currency',
|
||||
'altname': 'ADAXBT',
|
||||
'base': 'ADA',
|
||||
'fee_volume_currency': 'ZUSD',
|
||||
'fees': [['0', '0.26'],
|
||||
['50000', '0.24'],
|
||||
['100000', '0.22'],
|
||||
['250000', '0.2'],
|
||||
['500000', '0.18'],
|
||||
['1000000', '0.16'],
|
||||
['2500000', '0.14'],
|
||||
['5000000', '0.12'],
|
||||
['10000000', '0.1']],
|
||||
'fees_maker': [['0', '0.16'],
|
||||
['50000', '0.14'],
|
||||
['100000', '0.12'],
|
||||
['250000', '0.1'],
|
||||
['500000', '0.08'],
|
||||
['1000000', '0.06'],
|
||||
['2500000', '0.04'],
|
||||
['5000000', '0.02'],
|
||||
['10000000', '0']],
|
||||
'leverage_buy': ['2', '3'],
|
||||
'leverage_sell': ['2', '3'],
|
||||
'lot': 'unit',
|
||||
'lot_decimals': '8',
|
||||
'lot_multiplier': '1',
|
||||
'margin_call': '80',
|
||||
'margin_stop': '40',
|
||||
'ordermin': '5',
|
||||
'pair_decimals': '8',
|
||||
'quote': 'XXBT',
|
||||
'wsname': 'ADA/XBT'},
|
||||
'limits': {'amount': {'max': 100000000.0, 'min': 5.0},
|
||||
'cost': {'max': None, 'min': 0},
|
||||
'price': {'max': None, 'min': 1e-08}},
|
||||
'maker': 0.0016,
|
||||
'percentage': True,
|
||||
'precision': {'amount': 8, 'price': 8},
|
||||
'quote': 'BTC',
|
||||
'quoteId': 'XXBT',
|
||||
'symbol': 'ADA/BTC',
|
||||
'taker': 0.0026,
|
||||
'tierBased': True,
|
||||
'tiers': {'maker': [[0, 0.0016],
|
||||
[50000, 0.0014],
|
||||
[100000, 0.0012],
|
||||
[250000, 0.001],
|
||||
[500000, 0.0008],
|
||||
[1000000, 0.0006],
|
||||
[2500000, 0.0004],
|
||||
[5000000, 0.0002],
|
||||
[10000000, 0.0]],
|
||||
'taker': [[0, 0.0026],
|
||||
[50000, 0.0024],
|
||||
[100000, 0.0022],
|
||||
[250000, 0.002],
|
||||
[500000, 0.0018],
|
||||
[1000000, 0.0016],
|
||||
[2500000, 0.0014],
|
||||
[5000000, 0.0012],
|
||||
[10000000, 0.0001]]}},
|
||||
"BTC/EUR": {'active': True,
|
||||
'altname': 'XBTEUR',
|
||||
'base': 'BTC',
|
||||
'baseId': 'XXBT',
|
||||
'darkpool': False,
|
||||
'id': 'XXBTZEUR',
|
||||
'info': {'aclass_base': 'currency',
|
||||
'aclass_quote': 'currency',
|
||||
'altname': 'XBTEUR',
|
||||
'base': 'XXBT',
|
||||
'fee_volume_currency': 'ZUSD',
|
||||
'fees': [['0', '0.26'],
|
||||
['50000', '0.24'],
|
||||
['100000', '0.22'],
|
||||
['250000', '0.2'],
|
||||
['500000', '0.18'],
|
||||
['1000000', '0.16'],
|
||||
['2500000', '0.14'],
|
||||
['5000000', '0.12'],
|
||||
['10000000', '0.1']],
|
||||
'fees_maker': [['0', '0.16'],
|
||||
['50000', '0.14'],
|
||||
['100000', '0.12'],
|
||||
['250000', '0.1'],
|
||||
['500000', '0.08'],
|
||||
['1000000', '0.06'],
|
||||
['2500000', '0.04'],
|
||||
['5000000', '0.02'],
|
||||
['10000000', '0']],
|
||||
'leverage_buy': ['2', '3', '4', '5'],
|
||||
'leverage_sell': ['2', '3', '4', '5'],
|
||||
'lot': 'unit',
|
||||
'lot_decimals': '8',
|
||||
'lot_multiplier': '1',
|
||||
'margin_call': '80',
|
||||
'margin_stop': '40',
|
||||
'ordermin': '0.0001',
|
||||
'pair_decimals': '1',
|
||||
'quote': 'ZEUR',
|
||||
'wsname': 'XBT/EUR'},
|
||||
'limits': {'amount': {'max': 100000000.0, 'min': 0.0001},
|
||||
'cost': {'max': None, 'min': 0},
|
||||
'price': {'max': None, 'min': 0.1}},
|
||||
'maker': 0.0016,
|
||||
'percentage': True,
|
||||
'precision': {'amount': 8, 'price': 1},
|
||||
'quote': 'EUR',
|
||||
'quoteId': 'ZEUR',
|
||||
'symbol': 'BTC/EUR',
|
||||
'taker': 0.0026,
|
||||
'tierBased': True,
|
||||
'tiers': {'maker': [[0, 0.0016],
|
||||
[50000, 0.0014],
|
||||
[100000, 0.0012],
|
||||
[250000, 0.001],
|
||||
[500000, 0.0008],
|
||||
[1000000, 0.0006],
|
||||
[2500000, 0.0004],
|
||||
[5000000, 0.0002],
|
||||
[10000000, 0.0]],
|
||||
'taker': [[0, 0.0026],
|
||||
[50000, 0.0024],
|
||||
[100000, 0.0022],
|
||||
[250000, 0.002],
|
||||
[500000, 0.0018],
|
||||
[1000000, 0.0016],
|
||||
[2500000, 0.0014],
|
||||
[5000000, 0.0012],
|
||||
[10000000, 0.0001]]}},
|
||||
"ZEC/USD": {'active': True,
|
||||
'altname': 'ZECUSD',
|
||||
'base': 'ZEC',
|
||||
'baseId': 'XZEC',
|
||||
'darkpool': False,
|
||||
'id': 'XZECZUSD',
|
||||
'info': {'aclass_base': 'currency',
|
||||
'aclass_quote': 'currency',
|
||||
'altname': 'ZECUSD',
|
||||
'base': 'XZEC',
|
||||
'fee_volume_currency': 'ZUSD',
|
||||
'fees': [['0', '0.26'],
|
||||
['50000', '0.24'],
|
||||
['100000', '0.22'],
|
||||
['250000', '0.2'],
|
||||
['500000', '0.18'],
|
||||
['1000000', '0.16'],
|
||||
['2500000', '0.14'],
|
||||
['5000000', '0.12'],
|
||||
['10000000', '0.1']],
|
||||
'fees_maker': [['0', '0.16'],
|
||||
['50000', '0.14'],
|
||||
['100000', '0.12'],
|
||||
['250000', '0.1'],
|
||||
['500000', '0.08'],
|
||||
['1000000', '0.06'],
|
||||
['2500000', '0.04'],
|
||||
['5000000', '0.02'],
|
||||
['10000000', '0']],
|
||||
'leverage_buy': ['2'],
|
||||
'leverage_sell': ['2'],
|
||||
'lot': 'unit',
|
||||
'lot_decimals': '8',
|
||||
'lot_multiplier': '1',
|
||||
'margin_call': '80',
|
||||
'margin_stop': '40',
|
||||
'ordermin': '0.035',
|
||||
'pair_decimals': '2',
|
||||
'quote': 'ZUSD',
|
||||
'wsname': 'ZEC/USD'},
|
||||
'limits': {'amount': {'max': 100000000.0, 'min': 0.035},
|
||||
'cost': {'max': None, 'min': 0},
|
||||
'price': {'max': None, 'min': 0.01}},
|
||||
'maker': 0.0016,
|
||||
'percentage': True,
|
||||
'precision': {'amount': 8, 'price': 2},
|
||||
'quote': 'USD',
|
||||
'quoteId': 'ZUSD',
|
||||
'symbol': 'ZEC/USD',
|
||||
'taker': 0.0026,
|
||||
'tierBased': True,
|
||||
'tiers': {'maker': [[0, 0.0016],
|
||||
[50000, 0.0014],
|
||||
[100000, 0.0012],
|
||||
[250000, 0.001],
|
||||
[500000, 0.0008],
|
||||
[1000000, 0.0006],
|
||||
[2500000, 0.0004],
|
||||
[5000000, 0.0002],
|
||||
[10000000, 0.0]],
|
||||
'taker': [[0, 0.0026],
|
||||
[50000, 0.0024],
|
||||
[100000, 0.0022],
|
||||
[250000, 0.002],
|
||||
[500000, 0.0018],
|
||||
[1000000, 0.0016],
|
||||
[2500000, 0.0014],
|
||||
[5000000, 0.0012],
|
||||
[10000000, 0.0001]]}}
|
||||
|
||||
}})
|
||||
exchange = get_patched_exchange(mocker, default_conf, api_mock, id="kraken")
|
||||
|
||||
assert exchange._leverage_brackets == {
|
||||
'ADA/BTC': ['2', '3'],
|
||||
'BTC/EUR': ['2', '3', '4', '5'],
|
||||
'ZEC/USD': ['2']
|
||||
}
|
||||
|
||||
ccxt_exceptionhandlers(
|
||||
mocker,
|
||||
default_conf,
|
||||
api_mock,
|
||||
"kraken",
|
||||
"fill_leverage_brackets",
|
||||
"fill_leverage_brackets"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user