ccxt_compat_tests for leverage tiers
This commit is contained in:
parent
88a8ff2f4e
commit
ef5dae2770
@ -24,10 +24,8 @@ EXCHANGES = {
|
|||||||
'stake_currency': 'USDT',
|
'stake_currency': 'USDT',
|
||||||
'hasQuoteVolume': False,
|
'hasQuoteVolume': False,
|
||||||
'timeframe': '1h',
|
'timeframe': '1h',
|
||||||
'leverage_in_market': {
|
'leverage_tiers_public': False,
|
||||||
'spot': False,
|
'leverage_in_spot_market': False,
|
||||||
'futures': False,
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
'binance': {
|
'binance': {
|
||||||
'pair': 'BTC/USDT',
|
'pair': 'BTC/USDT',
|
||||||
@ -35,20 +33,16 @@ EXCHANGES = {
|
|||||||
'hasQuoteVolume': True,
|
'hasQuoteVolume': True,
|
||||||
'timeframe': '5m',
|
'timeframe': '5m',
|
||||||
'futures': True,
|
'futures': True,
|
||||||
'leverage_in_market': {
|
'leverage_tiers_public': False,
|
||||||
'spot': False,
|
'leverage_in_spot_market': False,
|
||||||
'futures': False,
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
'kraken': {
|
'kraken': {
|
||||||
'pair': 'BTC/USDT',
|
'pair': 'BTC/USDT',
|
||||||
'stake_currency': 'USDT',
|
'stake_currency': 'USDT',
|
||||||
'hasQuoteVolume': True,
|
'hasQuoteVolume': True,
|
||||||
'timeframe': '5m',
|
'timeframe': '5m',
|
||||||
'leverage_in_market': {
|
'leverage_tiers_public': False,
|
||||||
'spot': True,
|
'leverage_in_spot_market': True,
|
||||||
'futures': True,
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
'ftx': {
|
'ftx': {
|
||||||
'pair': 'BTC/USD',
|
'pair': 'BTC/USD',
|
||||||
@ -57,20 +51,16 @@ EXCHANGES = {
|
|||||||
'timeframe': '5m',
|
'timeframe': '5m',
|
||||||
'futures_pair': 'BTC/USD:USD',
|
'futures_pair': 'BTC/USD:USD',
|
||||||
'futures': True,
|
'futures': True,
|
||||||
'leverage_in_market': {
|
'leverage_tiers_public': False, # TODO: Set to True once implemented on CCXT
|
||||||
'spot': True,
|
'leverage_in_spot_market': True,
|
||||||
'futures': True,
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
'kucoin': {
|
'kucoin': {
|
||||||
'pair': 'BTC/USDT',
|
'pair': 'BTC/USDT',
|
||||||
'stake_currency': 'USDT',
|
'stake_currency': 'USDT',
|
||||||
'hasQuoteVolume': True,
|
'hasQuoteVolume': True,
|
||||||
'timeframe': '5m',
|
'timeframe': '5m',
|
||||||
'leverage_in_market': {
|
'leverage_tiers_public': False,
|
||||||
'spot': False,
|
'leverage_in_spot_market': True,
|
||||||
'futures': False,
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
'gateio': {
|
'gateio': {
|
||||||
'pair': 'BTC/USDT',
|
'pair': 'BTC/USDT',
|
||||||
@ -79,10 +69,8 @@ EXCHANGES = {
|
|||||||
'timeframe': '5m',
|
'timeframe': '5m',
|
||||||
'futures': True,
|
'futures': True,
|
||||||
'futures_pair': 'BTC/USDT:USDT',
|
'futures_pair': 'BTC/USDT:USDT',
|
||||||
'leverage_in_market': {
|
'leverage_tiers_public': False, # TODO-lev: Set to True once implemented on CCXT
|
||||||
'spot': True,
|
'leverage_in_spot_market': True,
|
||||||
'futures': True,
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
'okx': {
|
'okx': {
|
||||||
'pair': 'BTC/USDT',
|
'pair': 'BTC/USDT',
|
||||||
@ -91,20 +79,16 @@ EXCHANGES = {
|
|||||||
'timeframe': '5m',
|
'timeframe': '5m',
|
||||||
'futures_pair': 'BTC/USDT:USDT',
|
'futures_pair': 'BTC/USDT:USDT',
|
||||||
'futures': True,
|
'futures': True,
|
||||||
'leverage_in_market': {
|
'leverage_tiers_public': True,
|
||||||
'spot': True,
|
'leverage_in_spot_market': True,
|
||||||
'futures': True,
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
'bitvavo': {
|
'bitvavo': {
|
||||||
'pair': 'BTC/EUR',
|
'pair': 'BTC/EUR',
|
||||||
'stake_currency': 'EUR',
|
'stake_currency': 'EUR',
|
||||||
'hasQuoteVolume': True,
|
'hasQuoteVolume': True,
|
||||||
'timeframe': '5m',
|
'timeframe': '5m',
|
||||||
'leverage_in_market': {
|
'leverage_tiers_public': False,
|
||||||
'spot': False,
|
'leverage_in_spot_market': False,
|
||||||
'futures': False,
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,7 +316,7 @@ class TestCCXTExchange():
|
|||||||
def test_ccxt_get_max_leverage_spot(self, exchange):
|
def test_ccxt_get_max_leverage_spot(self, exchange):
|
||||||
spot, spot_name = exchange
|
spot, spot_name = exchange
|
||||||
if spot:
|
if spot:
|
||||||
leverage_in_market_spot = EXCHANGES[spot_name]['leverage_in_market']['spot']
|
leverage_in_market_spot = EXCHANGES[spot_name]['leverage_in_spot_market']
|
||||||
if leverage_in_market_spot:
|
if leverage_in_market_spot:
|
||||||
spot_pair = EXCHANGES[spot_name].get('pair', EXCHANGES[spot_name]['pair'])
|
spot_pair = EXCHANGES[spot_name].get('pair', EXCHANGES[spot_name]['pair'])
|
||||||
spot_leverage = spot.get_max_leverage(spot_pair, 20)
|
spot_leverage = spot.get_max_leverage(spot_pair, 20)
|
||||||
@ -342,9 +326,8 @@ class TestCCXTExchange():
|
|||||||
def test_ccxt_get_max_leverage_futures(self, exchange_futures):
|
def test_ccxt_get_max_leverage_futures(self, exchange_futures):
|
||||||
futures, futures_name = exchange_futures
|
futures, futures_name = exchange_futures
|
||||||
if futures:
|
if futures:
|
||||||
leverage_in_market_futures = EXCHANGES[futures_name]['leverage_in_market']['futures']
|
leverage_tiers_public = EXCHANGES[futures_name]['leverage_tiers_public']
|
||||||
# TODO-lev: binance, gateio, and okx don't have leverage_in_market
|
if leverage_tiers_public:
|
||||||
if leverage_in_market_futures:
|
|
||||||
futures_pair = EXCHANGES[futures_name].get(
|
futures_pair = EXCHANGES[futures_name].get(
|
||||||
'futures_pair',
|
'futures_pair',
|
||||||
EXCHANGES[futures_name]['pair']
|
EXCHANGES[futures_name]['pair']
|
||||||
@ -364,6 +347,34 @@ class TestCCXTExchange():
|
|||||||
assert (isinstance(contract_size, float) or isinstance(contract_size, int))
|
assert (isinstance(contract_size, float) or isinstance(contract_size, int))
|
||||||
assert contract_size >= 0.0
|
assert contract_size >= 0.0
|
||||||
|
|
||||||
|
def test_ccxt_load_leverage_tiers(self, exchange_futures):
|
||||||
|
futures, futures_name = exchange_futures
|
||||||
|
if futures and EXCHANGES[futures_name]['leverage_tiers_public']:
|
||||||
|
leverage_tiers = futures.load_leverage_tiers()
|
||||||
|
futures_pair = EXCHANGES[futures_name].get(
|
||||||
|
'futures_pair',
|
||||||
|
EXCHANGES[futures_name]['pair']
|
||||||
|
)
|
||||||
|
assert (isinstance(leverage_tiers, dict))
|
||||||
|
assert futures_pair in leverage_tiers
|
||||||
|
pair_tiers = leverage_tiers[futures_pair]
|
||||||
|
assert len(pair_tiers) > 0
|
||||||
|
oldLeverage = 0
|
||||||
|
oldMaintenanceMarginRate = oldNotionalFloor = oldNotionalCap = float('inf')
|
||||||
|
for tier in pair_tiers:
|
||||||
|
for key in ['maintenanceMarginRate', 'notionalFloor', 'notionalCap', 'maxLeverage']:
|
||||||
|
assert key in tier
|
||||||
|
assert pair_tiers[key] > 0.0
|
||||||
|
assert pair_tiers['notionalCap'] > pair_tiers['notionalFloor']
|
||||||
|
assert tier['maxLeverage'] < oldLeverage
|
||||||
|
assert tier['maintenanceMarginRate'] > oldMaintenanceMarginRate
|
||||||
|
assert tier['notionalFloor'] > oldNotionalFloor
|
||||||
|
assert tier['notionalCap'] > oldNotionalCap
|
||||||
|
oldLeverage = tier['maxLeverage']
|
||||||
|
oldMaintenanceMarginRate = tier['maintenanceMarginRate']
|
||||||
|
oldNotionalFloor = tier['notionalFloor']
|
||||||
|
oldNotionalCap = tier['notionalCap']
|
||||||
|
|
||||||
# def test_ccxt_get_liquidation_price():
|
# def test_ccxt_get_liquidation_price():
|
||||||
# return # TODO-lev
|
# return # TODO-lev
|
||||||
|
|
||||||
@ -373,8 +384,5 @@ class TestCCXTExchange():
|
|||||||
# def test_ccxt_get_max_pair_stake_amount():
|
# def test_ccxt_get_max_pair_stake_amount():
|
||||||
# return # TODO-lev
|
# return # TODO-lev
|
||||||
|
|
||||||
# def test_ccxt_load_leverage_tiers():
|
|
||||||
# return # TODO-lev
|
|
||||||
|
|
||||||
# def test_ccxt_get_maintenance_ratio_and_amt():
|
# def test_ccxt_get_maintenance_ratio_and_amt():
|
||||||
# return # TODO-lev
|
# return # TODO-lev
|
||||||
|
Loading…
Reference in New Issue
Block a user