Update leverage tier terminology to be clear and aligned with ccxt

This commit is contained in:
Matthias 2022-08-26 19:34:51 +02:00
parent 53d46a0385
commit 753d1b2aad
6 changed files with 326 additions and 325 deletions

View File

@ -2316,10 +2316,10 @@ class Exchange:
def parse_leverage_tier(self, tier) -> Dict: def parse_leverage_tier(self, tier) -> Dict:
info = tier.get('info', {}) info = tier.get('info', {})
return { return {
'min': tier['minNotional'], 'minNotional': tier['minNotional'],
'max': tier['maxNotional'], 'maxNotional': tier['maxNotional'],
'mmr': tier['maintenanceMarginRate'], 'maintenanceMarginRate': tier['maintenanceMarginRate'],
'lev': tier['maxLeverage'], 'maxLeverage': tier['maxLeverage'],
'maintAmt': float(info['cum']) if 'cum' in info else None, 'maintAmt': float(info['cum']) if 'cum' in info else None,
} }
@ -2348,18 +2348,18 @@ class Exchange:
pair_tiers = self._leverage_tiers[pair] pair_tiers = self._leverage_tiers[pair]
if stake_amount == 0: if stake_amount == 0:
return self._leverage_tiers[pair][0]['lev'] # Max lev for lowest amount return self._leverage_tiers[pair][0]['maxLeverage'] # Max lev for lowest amount
for tier_index in range(len(pair_tiers)): for tier_index in range(len(pair_tiers)):
tier = pair_tiers[tier_index] tier = pair_tiers[tier_index]
lev = tier['lev'] lev = tier['maxLeverage']
if tier_index < len(pair_tiers) - 1: if tier_index < len(pair_tiers) - 1:
next_tier = pair_tiers[tier_index + 1] next_tier = pair_tiers[tier_index + 1]
next_floor = next_tier['min'] / next_tier['lev'] next_floor = next_tier['minNotional'] / next_tier['maxLeverage']
if next_floor > stake_amount: # Next tier min too high for stake amount if next_floor > stake_amount: # Next tier min too high for stake amount
return min((tier['max'] / stake_amount), lev) return min((tier['maxNotional'] / stake_amount), lev)
# #
# With the two leverage tiers below, # With the two leverage tiers below,
# - a stake amount of 150 would mean a max leverage of (10000 / 150) = 66.66 # - a stake amount of 150 would mean a max leverage of (10000 / 150) = 66.66
@ -2380,10 +2380,11 @@ class Exchange:
# #
else: # if on the last tier else: # if on the last tier
if stake_amount > tier['max']: # If stake is > than max tradeable amount if stake_amount > tier['maxNotional']:
# If stake is > than max tradeable amount
raise InvalidOrderException(f'Amount {stake_amount} too high for {pair}') raise InvalidOrderException(f'Amount {stake_amount} too high for {pair}')
else: else:
return tier['lev'] return tier['maxLeverage']
raise OperationalException( raise OperationalException(
'Looped through all tiers without finding a max leverage. Should never be reached' 'Looped through all tiers without finding a max leverage. Should never be reached'
@ -2749,8 +2750,8 @@ class Exchange:
pair_tiers = self._leverage_tiers[pair] pair_tiers = self._leverage_tiers[pair]
for tier in reversed(pair_tiers): for tier in reversed(pair_tiers):
if nominal_value >= tier['min']: if nominal_value >= tier['minNotional']:
return (tier['mmr'], tier['maintAmt']) return (tier['maintenanceMarginRate'], tier['maintAmt'])
raise OperationalException("nominal value can not be lower than 0") raise OperationalException("nominal value can not be lower than 0")
# The lowest notional_floor for any pair in fetch_leverage_tiers is always 0 because it # The lowest notional_floor for any pair in fetch_leverage_tiers is always 0 because it

View File

@ -146,4 +146,4 @@ class Okx(Exchange):
return float('inf') return float('inf')
pair_tiers = self._leverage_tiers[pair] pair_tiers = self._leverage_tiers[pair]
return pair_tiers[-1]['max'] / leverage return pair_tiers[-1]['maxNotional'] / leverage

View File

@ -3085,416 +3085,416 @@ def leverage_tiers():
return { return {
"1000SHIB/USDT": [ "1000SHIB/USDT": [
{ {
'min': 0, 'minNotional': 0,
'max': 50000, 'maxNotional': 50000,
'mmr': 0.01, 'maintenanceMarginRate': 0.01,
'lev': 50, 'maxLeverage': 50,
'maintAmt': 0.0 'maintAmt': 0.0
}, },
{ {
'min': 50000, 'minNotional': 50000,
'max': 150000, 'maxNotional': 150000,
'mmr': 0.025, 'maintenanceMarginRate': 0.025,
'lev': 20, 'maxLeverage': 20,
'maintAmt': 750.0 'maintAmt': 750.0
}, },
{ {
'min': 150000, 'minNotional': 150000,
'max': 250000, 'maxNotional': 250000,
'mmr': 0.05, 'maintenanceMarginRate': 0.05,
'lev': 10, 'maxLeverage': 10,
'maintAmt': 4500.0 'maintAmt': 4500.0
}, },
{ {
'min': 250000, 'minNotional': 250000,
'max': 500000, 'maxNotional': 500000,
'mmr': 0.1, 'maintenanceMarginRate': 0.1,
'lev': 5, 'maxLeverage': 5,
'maintAmt': 17000.0 'maintAmt': 17000.0
}, },
{ {
'min': 500000, 'minNotional': 500000,
'max': 1000000, 'maxNotional': 1000000,
'mmr': 0.125, 'maintenanceMarginRate': 0.125,
'lev': 4, 'maxLeverage': 4,
'maintAmt': 29500.0 'maintAmt': 29500.0
}, },
{ {
'min': 1000000, 'minNotional': 1000000,
'max': 2000000, 'maxNotional': 2000000,
'mmr': 0.25, 'maintenanceMarginRate': 0.25,
'lev': 2, 'maxLeverage': 2,
'maintAmt': 154500.0 'maintAmt': 154500.0
}, },
{ {
'min': 2000000, 'minNotional': 2000000,
'max': 30000000, 'maxNotional': 30000000,
'mmr': 0.5, 'maintenanceMarginRate': 0.5,
'lev': 1, 'maxLeverage': 1,
'maintAmt': 654500.0 'maintAmt': 654500.0
}, },
], ],
"1INCH/USDT": [ "1INCH/USDT": [
{ {
'min': 0, 'minNotional': 0,
'max': 5000, 'maxNotional': 5000,
'mmr': 0.012, 'maintenanceMarginRate': 0.012,
'lev': 50, 'maxLeverage': 50,
'maintAmt': 0.0 'maintAmt': 0.0
}, },
{ {
'min': 5000, 'minNotional': 5000,
'max': 25000, 'maxNotional': 25000,
'mmr': 0.025, 'maintenanceMarginRate': 0.025,
'lev': 20, 'maxLeverage': 20,
'maintAmt': 65.0 'maintAmt': 65.0
}, },
{ {
'min': 25000, 'minNotional': 25000,
'max': 100000, 'maxNotional': 100000,
'mmr': 0.05, 'maintenanceMarginRate': 0.05,
'lev': 10, 'maxLeverage': 10,
'maintAmt': 690.0 'maintAmt': 690.0
}, },
{ {
'min': 100000, 'minNotional': 100000,
'max': 250000, 'maxNotional': 250000,
'mmr': 0.1, 'maintenanceMarginRate': 0.1,
'lev': 5, 'maxLeverage': 5,
'maintAmt': 5690.0 'maintAmt': 5690.0
}, },
{ {
'min': 250000, 'minNotional': 250000,
'max': 1000000, 'maxNotional': 1000000,
'mmr': 0.125, 'maintenanceMarginRate': 0.125,
'lev': 2, 'maxLeverage': 2,
'maintAmt': 11940.0 'maintAmt': 11940.0
}, },
{ {
'min': 1000000, 'minNotional': 1000000,
'max': 100000000, 'maxNotional': 100000000,
'mmr': 0.5, 'maintenanceMarginRate': 0.5,
'lev': 1, 'maxLeverage': 1,
'maintAmt': 386940.0 'maintAmt': 386940.0
}, },
], ],
"AAVE/USDT": [ "AAVE/USDT": [
{ {
'min': 0, 'minNotional': 0,
'max': 5000, 'maxNotional': 5000,
'mmr': 0.01, 'maintenanceMarginRate': 0.01,
'lev': 50, 'maxLeverage': 50,
'maintAmt': 0.0 'maintAmt': 0.0
}, },
{ {
'min': 5000, 'minNotional': 5000,
'max': 25000, 'maxNotional': 25000,
'mmr': 0.02, 'maintenanceMarginRate': 0.02,
'lev': 25, 'maxLeverage': 25,
'maintAmt': 75.0 'maintAmt': 75.0
}, },
{ {
'min': 25000, 'minNotional': 25000,
'max': 100000, 'maxNotional': 100000,
'mmr': 0.05, 'maintenanceMarginRate': 0.05,
'lev': 10, 'maxLeverage': 10,
'maintAmt': 700.0 'maintAmt': 700.0
}, },
{ {
'min': 100000, 'minNotional': 100000,
'max': 250000, 'maxNotional': 250000,
'mmr': 0.1, 'maintenanceMarginRate': 0.1,
'lev': 5, 'maxLeverage': 5,
'maintAmt': 5700.0 'maintAmt': 5700.0
}, },
{ {
'min': 250000, 'minNotional': 250000,
'max': 1000000, 'maxNotional': 1000000,
'mmr': 0.125, 'maintenanceMarginRate': 0.125,
'lev': 2, 'maxLeverage': 2,
'maintAmt': 11950.0 'maintAmt': 11950.0
}, },
{ {
'min': 10000000, 'minNotional': 10000000,
'max': 50000000, 'maxNotional': 50000000,
'mmr': 0.5, 'maintenanceMarginRate': 0.5,
'lev': 1, 'maxLeverage': 1,
'maintAmt': 386950.0 'maintAmt': 386950.0
}, },
], ],
"ADA/BUSD": [ "ADA/BUSD": [
{ {
"min": 0, "minNotional": 0,
"max": 100000, "maxNotional": 100000,
"mmr": 0.025, "maintenanceMarginRate": 0.025,
"lev": 20, "maxLeverage": 20,
"maintAmt": 0.0 "maintAmt": 0.0
}, },
{ {
"min": 100000, "minNotional": 100000,
"max": 500000, "maxNotional": 500000,
"mmr": 0.05, "maintenanceMarginRate": 0.05,
"lev": 10, "maxLeverage": 10,
"maintAmt": 2500.0 "maintAmt": 2500.0
}, },
{ {
"min": 500000, "minNotional": 500000,
"max": 1000000, "maxNotional": 1000000,
"mmr": 0.1, "maintenanceMarginRate": 0.1,
"lev": 5, "maxLeverage": 5,
"maintAmt": 27500.0 "maintAmt": 27500.0
}, },
{ {
"min": 1000000, "minNotional": 1000000,
"max": 2000000, "maxNotional": 2000000,
"mmr": 0.15, "maintenanceMarginRate": 0.15,
"lev": 3, "maxLeverage": 3,
"maintAmt": 77500.0 "maintAmt": 77500.0
}, },
{ {
"min": 2000000, "minNotional": 2000000,
"max": 5000000, "maxNotional": 5000000,
"mmr": 0.25, "maintenanceMarginRate": 0.25,
"lev": 2, "maxLeverage": 2,
"maintAmt": 277500.0 "maintAmt": 277500.0
}, },
{ {
"min": 5000000, "minNotional": 5000000,
"max": 30000000, "maxNotional": 30000000,
"mmr": 0.5, "maintenanceMarginRate": 0.5,
"lev": 1, "maxLeverage": 1,
"maintAmt": 1527500.0 "maintAmt": 1527500.0
}, },
], ],
'BNB/BUSD': [ 'BNB/BUSD': [
{ {
"min": 0, # stake(before leverage) = 0 "minNotional": 0, # stake(before leverage) = 0
"max": 100000, # max stake(before leverage) = 5000 "maxNotional": 100000, # max stake(before leverage) = 5000
"mmr": 0.025, "maintenanceMarginRate": 0.025,
"lev": 20, "maxLeverage": 20,
"maintAmt": 0.0 "maintAmt": 0.0
}, },
{ {
"min": 100000, # stake = 10000.0 "minNotional": 100000, # stake = 10000.0
"max": 500000, # max_stake = 50000.0 "maxNotional": 500000, # max_stake = 50000.0
"mmr": 0.05, "maintenanceMarginRate": 0.05,
"lev": 10, "maxLeverage": 10,
"maintAmt": 2500.0 "maintAmt": 2500.0
}, },
{ {
"min": 500000, # stake = 100000.0 "minNotional": 500000, # stake = 100000.0
"max": 1000000, # max_stake = 200000.0 "maxNotional": 1000000, # max_stake = 200000.0
"mmr": 0.1, "maintenanceMarginRate": 0.1,
"lev": 5, "maxLeverage": 5,
"maintAmt": 27500.0 "maintAmt": 27500.0
}, },
{ {
"min": 1000000, # stake = 333333.3333333333 "minNotional": 1000000, # stake = 333333.3333333333
"max": 2000000, # max_stake = 666666.6666666666 "maxNotional": 2000000, # max_stake = 666666.6666666666
"mmr": 0.15, "maintenanceMarginRate": 0.15,
"lev": 3, "maxLeverage": 3,
"maintAmt": 77500.0 "maintAmt": 77500.0
}, },
{ {
"min": 2000000, # stake = 1000000.0 "minNotional": 2000000, # stake = 1000000.0
"max": 5000000, # max_stake = 2500000.0 "maxNotional": 5000000, # max_stake = 2500000.0
"mmr": 0.25, "maintenanceMarginRate": 0.25,
"lev": 2, "maxLeverage": 2,
"maintAmt": 277500.0 "maintAmt": 277500.0
}, },
{ {
"min": 5000000, # stake = 5000000.0 "minNotional": 5000000, # stake = 5000000.0
"max": 30000000, # max_stake = 30000000.0 "maxNotional": 30000000, # max_stake = 30000000.0
"mmr": 0.5, "maintenanceMarginRate": 0.5,
"lev": 1, "maxLeverage": 1,
"maintAmt": 1527500.0 "maintAmt": 1527500.0
} }
], ],
'BNB/USDT': [ 'BNB/USDT': [
{ {
"min": 0, # stake = 0.0 "minNotional": 0, # stake = 0.0
"max": 10000, # max_stake = 133.33333333333334 "maxNotional": 10000, # max_stake = 133.33333333333334
"mmr": 0.0065, "maintenanceMarginRate": 0.0065,
"lev": 75, "maxLeverage": 75,
"maintAmt": 0.0 "maintAmt": 0.0
}, },
{ {
"min": 10000, # stake = 200.0 "minNotional": 10000, # stake = 200.0
"max": 50000, # max_stake = 1000.0 "maxNotional": 50000, # max_stake = 1000.0
"mmr": 0.01, "maintenanceMarginRate": 0.01,
"lev": 50, "maxLeverage": 50,
"maintAmt": 35.0 "maintAmt": 35.0
}, },
{ {
"min": 50000, # stake = 2000.0 "minNotional": 50000, # stake = 2000.0
"max": 250000, # max_stake = 10000.0 "maxNotional": 250000, # max_stake = 10000.0
"mmr": 0.02, "maintenanceMarginRate": 0.02,
"lev": 25, "maxLeverage": 25,
"maintAmt": 535.0 "maintAmt": 535.0
}, },
{ {
"min": 250000, # stake = 25000.0 "minNotional": 250000, # stake = 25000.0
"max": 1000000, # max_stake = 100000.0 "maxNotional": 1000000, # max_stake = 100000.0
"mmr": 0.05, "maintenanceMarginRate": 0.05,
"lev": 10, "maxLeverage": 10,
"maintAmt": 8035.0 "maintAmt": 8035.0
}, },
{ {
"min": 1000000, # stake = 200000.0 "minNotional": 1000000, # stake = 200000.0
"max": 2000000, # max_stake = 400000.0 "maxNotional": 2000000, # max_stake = 400000.0
"mmr": 0.1, "maintenanceMarginRate": 0.1,
"lev": 5, "maxLeverage": 5,
"maintAmt": 58035.0 "maintAmt": 58035.0
}, },
{ {
"min": 2000000, # stake = 500000.0 "minNotional": 2000000, # stake = 500000.0
"max": 5000000, # max_stake = 1250000.0 "maxNotional": 5000000, # max_stake = 1250000.0
"mmr": 0.125, "maintenanceMarginRate": 0.125,
"lev": 4, "maxLeverage": 4,
"maintAmt": 108035.0 "maintAmt": 108035.0
}, },
{ {
"min": 5000000, # stake = 1666666.6666666667 "minNotional": 5000000, # stake = 1666666.6666666667
"max": 10000000, # max_stake = 3333333.3333333335 "maxNotional": 10000000, # max_stake = 3333333.3333333335
"mmr": 0.15, "maintenanceMarginRate": 0.15,
"lev": 3, "maxLeverage": 3,
"maintAmt": 233035.0 "maintAmt": 233035.0
}, },
{ {
"min": 10000000, # stake = 5000000.0 "minNotional": 10000000, # stake = 5000000.0
"max": 20000000, # max_stake = 10000000.0 "maxNotional": 20000000, # max_stake = 10000000.0
"mmr": 0.25, "maintenanceMarginRate": 0.25,
"lev": 2, "maxLeverage": 2,
"maintAmt": 1233035.0 "maintAmt": 1233035.0
}, },
{ {
"min": 20000000, # stake = 20000000.0 "minNotional": 20000000, # stake = 20000000.0
"max": 50000000, # max_stake = 50000000.0 "maxNotional": 50000000, # max_stake = 50000000.0
"mmr": 0.5, "maintenanceMarginRate": 0.5,
"lev": 1, "maxLeverage": 1,
"maintAmt": 6233035.0 "maintAmt": 6233035.0
}, },
], ],
'BTC/USDT': [ 'BTC/USDT': [
{ {
"min": 0, # stake = 0.0 "minNotional": 0, # stake = 0.0
"max": 50000, # max_stake = 400.0 "maxNotional": 50000, # max_stake = 400.0
"mmr": 0.004, "maintenanceMarginRate": 0.004,
"lev": 125, "maxLeverage": 125,
"maintAmt": 0.0 "maintAmt": 0.0
}, },
{ {
"min": 50000, # stake = 500.0 "minNotional": 50000, # stake = 500.0
"max": 250000, # max_stake = 2500.0 "maxNotional": 250000, # max_stake = 2500.0
"mmr": 0.005, "maintenanceMarginRate": 0.005,
"lev": 100, "maxLeverage": 100,
"maintAmt": 50.0 "maintAmt": 50.0
}, },
{ {
"min": 250000, # stake = 5000.0 "minNotional": 250000, # stake = 5000.0
"max": 1000000, # max_stake = 20000.0 "maxNotional": 1000000, # max_stake = 20000.0
"mmr": 0.01, "maintenanceMarginRate": 0.01,
"lev": 50, "maxLeverage": 50,
"maintAmt": 1300.0 "maintAmt": 1300.0
}, },
{ {
"min": 1000000, # stake = 50000.0 "minNotional": 1000000, # stake = 50000.0
"max": 7500000, # max_stake = 375000.0 "maxNotional": 7500000, # max_stake = 375000.0
"mmr": 0.025, "maintenanceMarginRate": 0.025,
"lev": 20, "maxLeverage": 20,
"maintAmt": 16300.0 "maintAmt": 16300.0
}, },
{ {
"min": 7500000, # stake = 750000.0 "minNotional": 7500000, # stake = 750000.0
"max": 40000000, # max_stake = 4000000.0 "maxNotional": 40000000, # max_stake = 4000000.0
"mmr": 0.05, "maintenanceMarginRate": 0.05,
"lev": 10, "maxLeverage": 10,
"maintAmt": 203800.0 "maintAmt": 203800.0
}, },
{ {
"min": 40000000, # stake = 8000000.0 "minNotional": 40000000, # stake = 8000000.0
"max": 100000000, # max_stake = 20000000.0 "maxNotional": 100000000, # max_stake = 20000000.0
"mmr": 0.1, "maintenanceMarginRate": 0.1,
"lev": 5, "maxLeverage": 5,
"maintAmt": 2203800.0 "maintAmt": 2203800.0
}, },
{ {
"min": 100000000, # stake = 25000000.0 "minNotional": 100000000, # stake = 25000000.0
"max": 200000000, # max_stake = 50000000.0 "maxNotional": 200000000, # max_stake = 50000000.0
"mmr": 0.125, "maintenanceMarginRate": 0.125,
"lev": 4, "maxLeverage": 4,
"maintAmt": 4703800.0 "maintAmt": 4703800.0
}, },
{ {
"min": 200000000, # stake = 66666666.666666664 "minNotional": 200000000, # stake = 66666666.666666664
"max": 400000000, # max_stake = 133333333.33333333 "maxNotional": 400000000, # max_stake = 133333333.33333333
"mmr": 0.15, "maintenanceMarginRate": 0.15,
"lev": 3, "maxLeverage": 3,
"maintAmt": 9703800.0 "maintAmt": 9703800.0
}, },
{ {
"min": 400000000, # stake = 200000000.0 "minNotional": 400000000, # stake = 200000000.0
"max": 600000000, # max_stake = 300000000.0 "maxNotional": 600000000, # max_stake = 300000000.0
"mmr": 0.25, "maintenanceMarginRate": 0.25,
"lev": 2, "maxLeverage": 2,
"maintAmt": 4.97038E7 "maintAmt": 4.97038E7
}, },
{ {
"min": 600000000, # stake = 600000000.0 "minNotional": 600000000, # stake = 600000000.0
"max": 1000000000, # max_stake = 1000000000.0 "maxNotional": 1000000000, # max_stake = 1000000000.0
"mmr": 0.5, "maintenanceMarginRate": 0.5,
"lev": 1, "maxLeverage": 1,
"maintAmt": 1.997038E8 "maintAmt": 1.997038E8
}, },
], ],
"ZEC/USDT": [ "ZEC/USDT": [
{ {
'min': 0, 'minNotional': 0,
'max': 50000, 'maxNotional': 50000,
'mmr': 0.01, 'maintenanceMarginRate': 0.01,
'lev': 50, 'maxLeverage': 50,
'maintAmt': 0.0 'maintAmt': 0.0
}, },
{ {
'min': 50000, 'minNotional': 50000,
'max': 150000, 'maxNotional': 150000,
'mmr': 0.025, 'maintenanceMarginRate': 0.025,
'lev': 20, 'maxLeverage': 20,
'maintAmt': 750.0 'maintAmt': 750.0
}, },
{ {
'min': 150000, 'minNotional': 150000,
'max': 250000, 'maxNotional': 250000,
'mmr': 0.05, 'maintenanceMarginRate': 0.05,
'lev': 10, 'maxLeverage': 10,
'maintAmt': 4500.0 'maintAmt': 4500.0
}, },
{ {
'min': 250000, 'minNotional': 250000,
'max': 500000, 'maxNotional': 500000,
'mmr': 0.1, 'maintenanceMarginRate': 0.1,
'lev': 5, 'maxLeverage': 5,
'maintAmt': 17000.0 'maintAmt': 17000.0
}, },
{ {
'min': 500000, 'minNotional': 500000,
'max': 1000000, 'maxNotional': 1000000,
'mmr': 0.125, 'maintenanceMarginRate': 0.125,
'lev': 4, 'maxLeverage': 4,
'maintAmt': 29500.0 'maintAmt': 29500.0
}, },
{ {
'min': 1000000, 'minNotional': 1000000,
'max': 2000000, 'maxNotional': 2000000,
'mmr': 0.25, 'maintenanceMarginRate': 0.25,
'lev': 2, 'maxLeverage': 2,
'maintAmt': 154500.0 'maintAmt': 154500.0
}, },
{ {
'min': 2000000, 'minNotional': 2000000,
'max': 30000000, 'maxNotional': 30000000,
'mmr': 0.5, 'maintenanceMarginRate': 0.5,
'lev': 1, 'maxLeverage': 1,
'maintAmt': 654500.0 'maintAmt': 654500.0
}, },
] ]

View File

@ -376,96 +376,96 @@ def test_fill_leverage_tiers_binance(default_conf, mocker):
assert exchange._leverage_tiers == { assert exchange._leverage_tiers == {
'ADA/BUSD': [ 'ADA/BUSD': [
{ {
"min": 0, "minNotional": 0,
"max": 100000, "maxNotional": 100000,
"mmr": 0.025, "maintenanceMarginRate": 0.025,
"lev": 20, "maxLeverage": 20,
"maintAmt": 0.0 "maintAmt": 0.0
}, },
{ {
"min": 100000, "minNotional": 100000,
"max": 500000, "maxNotional": 500000,
"mmr": 0.05, "maintenanceMarginRate": 0.05,
"lev": 10, "maxLeverage": 10,
"maintAmt": 2500.0 "maintAmt": 2500.0
}, },
{ {
"min": 500000, "minNotional": 500000,
"max": 1000000, "maxNotional": 1000000,
"mmr": 0.1, "maintenanceMarginRate": 0.1,
"lev": 5, "maxLeverage": 5,
"maintAmt": 27500.0 "maintAmt": 27500.0
}, },
{ {
"min": 1000000, "minNotional": 1000000,
"max": 2000000, "maxNotional": 2000000,
"mmr": 0.15, "maintenanceMarginRate": 0.15,
"lev": 3, "maxLeverage": 3,
"maintAmt": 77500.0 "maintAmt": 77500.0
}, },
{ {
"min": 2000000, "minNotional": 2000000,
"max": 5000000, "maxNotional": 5000000,
"mmr": 0.25, "maintenanceMarginRate": 0.25,
"lev": 2, "maxLeverage": 2,
"maintAmt": 277500.0 "maintAmt": 277500.0
}, },
{ {
"min": 5000000, "minNotional": 5000000,
"max": 30000000, "maxNotional": 30000000,
"mmr": 0.5, "maintenanceMarginRate": 0.5,
"lev": 1, "maxLeverage": 1,
"maintAmt": 1527500.0 "maintAmt": 1527500.0
} }
], ],
"ZEC/USDT": [ "ZEC/USDT": [
{ {
'min': 0, 'minNotional': 0,
'max': 50000, 'maxNotional': 50000,
'mmr': 0.01, 'maintenanceMarginRate': 0.01,
'lev': 50, 'maxLeverage': 50,
'maintAmt': 0.0 'maintAmt': 0.0
}, },
{ {
'min': 50000, 'minNotional': 50000,
'max': 150000, 'maxNotional': 150000,
'mmr': 0.025, 'maintenanceMarginRate': 0.025,
'lev': 20, 'maxLeverage': 20,
'maintAmt': 750.0 'maintAmt': 750.0
}, },
{ {
'min': 150000, 'minNotional': 150000,
'max': 250000, 'maxNotional': 250000,
'mmr': 0.05, 'maintenanceMarginRate': 0.05,
'lev': 10, 'maxLeverage': 10,
'maintAmt': 4500.0 'maintAmt': 4500.0
}, },
{ {
'min': 250000, 'minNotional': 250000,
'max': 500000, 'maxNotional': 500000,
'mmr': 0.1, 'maintenanceMarginRate': 0.1,
'lev': 5, 'maxLeverage': 5,
'maintAmt': 17000.0 'maintAmt': 17000.0
}, },
{ {
'min': 500000, 'minNotional': 500000,
'max': 1000000, 'maxNotional': 1000000,
'mmr': 0.125, 'maintenanceMarginRate': 0.125,
'lev': 4, 'maxLeverage': 4,
'maintAmt': 29500.0 'maintAmt': 29500.0
}, },
{ {
'min': 1000000, 'minNotional': 1000000,
'max': 2000000, 'maxNotional': 2000000,
'mmr': 0.25, 'maintenanceMarginRate': 0.25,
'lev': 2, 'maxLeverage': 2,
'maintAmt': 154500.0 'maintAmt': 154500.0
}, },
{ {
'min': 2000000, 'minNotional': 2000000,
'max': 30000000, 'maxNotional': 30000000,
'mmr': 0.5, 'maintenanceMarginRate': 0.5,
'lev': 1, 'maxLeverage': 1,
'maintAmt': 654500.0 'maintAmt': 654500.0
}, },
] ]

View File

@ -4826,10 +4826,10 @@ def test_parse_leverage_tier(mocker, default_conf):
} }
assert exchange.parse_leverage_tier(tier) == { assert exchange.parse_leverage_tier(tier) == {
"min": 0, "minNotional": 0,
"max": 100000, "maxNotional": 100000,
"mmr": 0.025, "maintenanceMarginRate": 0.025,
"lev": 20, "maxLeverage": 20,
"maintAmt": 0.0, "maintAmt": 0.0,
} }
@ -4855,10 +4855,10 @@ def test_parse_leverage_tier(mocker, default_conf):
} }
assert exchange.parse_leverage_tier(tier2) == { assert exchange.parse_leverage_tier(tier2) == {
'min': 0, 'minNotional': 0,
'max': 2000, 'maxNotional': 2000,
'mmr': 0.01, 'maintenanceMarginRate': 0.01,
'lev': 75, 'maxLeverage': 75,
"maintAmt": None, "maintAmt": None,
} }

View File

@ -414,47 +414,47 @@ def test_load_leverage_tiers_okx(default_conf, mocker, markets, tmpdir, caplog,
assert exchange._leverage_tiers == { assert exchange._leverage_tiers == {
'ADA/USDT:USDT': [ 'ADA/USDT:USDT': [
{ {
'min': 0, 'minNotional': 0,
'max': 500, 'maxNotional': 500,
'mmr': 0.02, 'maintenanceMarginRate': 0.02,
'lev': 75, 'maxLeverage': 75,
'maintAmt': None 'maintAmt': None
}, },
{ {
'min': 501, 'minNotional': 501,
'max': 1000, 'maxNotional': 1000,
'mmr': 0.025, 'maintenanceMarginRate': 0.025,
'lev': 50, 'maxLeverage': 50,
'maintAmt': None 'maintAmt': None
}, },
{ {
'min': 1001, 'minNotional': 1001,
'max': 2000, 'maxNotional': 2000,
'mmr': 0.03, 'maintenanceMarginRate': 0.03,
'lev': 20, 'maxLeverage': 20,
'maintAmt': None 'maintAmt': None
}, },
], ],
'ETH/USDT:USDT': [ 'ETH/USDT:USDT': [
{ {
'min': 0, 'minNotional': 0,
'max': 2000, 'maxNotional': 2000,
'mmr': 0.01, 'maintenanceMarginRate': 0.01,
'lev': 75, 'maxLeverage': 75,
'maintAmt': None 'maintAmt': None
}, },
{ {
'min': 2001, 'minNotional': 2001,
'max': 4000, 'maxNotional': 4000,
'mmr': 0.015, 'maintenanceMarginRate': 0.015,
'lev': 50, 'maxLeverage': 50,
'maintAmt': None 'maintAmt': None
}, },
{ {
'min': 4001, 'minNotional': 4001,
'max': 8000, 'maxNotional': 8000,
'mmr': 0.02, 'maintenanceMarginRate': 0.02,
'lev': 20, 'maxLeverage': 20,
'maintAmt': None 'maintAmt': None
}, },
], ],