Merge pull request #7068 from freqtrade/ccxt_ordertype_validations

Ccxt ordertype validations
This commit is contained in:
Matthias 2022-07-11 19:41:05 +02:00 committed by GitHub
commit 0669d93f56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 13 deletions

View File

@ -73,7 +73,7 @@ EXCHANGE_HAS_REQUIRED = [
EXCHANGE_HAS_OPTIONAL = [ EXCHANGE_HAS_OPTIONAL = [
# Private # Private
'fetchMyTrades', # Trades for order - fee detection 'fetchMyTrades', # Trades for order - fee detection
# 'createLimitOrder', 'createMarketOrder', # Either OR for orders 'createLimitOrder', 'createMarketOrder', # Either OR for orders
# 'setLeverage', # Margin/Futures trading # 'setLeverage', # Margin/Futures trading
# 'setMarginMode', # Margin/Futures trading # 'setMarginMode', # Margin/Futures trading
# 'fetchFundingHistory', # Futures trading # 'fetchFundingHistory', # Futures trading

View File

@ -586,13 +586,10 @@ class Exchange:
""" """
Checks if order-types configured in strategy/config are supported Checks if order-types configured in strategy/config are supported
""" """
# TODO: Reenable once ccxt fixes createMarketOrder assignment - as well as if any(v == 'market' for k, v in order_types.items()):
# Revert the change in test_validate_ordertypes. if not self.exchange_has('createMarketOrder'):
raise OperationalException(
# if any(v == 'market' for k, v in order_types.items()): f'Exchange {self.name} does not support market orders.')
# if not self.exchange_has('createMarketOrder'):
# raise OperationalException(
# f'Exchange {self.name} does not support market orders.')
if (order_types.get("stoploss_on_exchange") if (order_types.get("stoploss_on_exchange")
and not self._ft_has.get("stoploss_on_exchange", False)): and not self._ft_has.get("stoploss_on_exchange", False)):

View File

@ -2,7 +2,7 @@ numpy==1.23.1
pandas==1.4.3 pandas==1.4.3
pandas-ta==0.3.14b pandas-ta==0.3.14b
ccxt==1.90.41 ccxt==1.90.47
# Pin cryptography for now due to rust build errors with piwheels # Pin cryptography for now due to rust build errors with piwheels
cryptography==37.0.4 cryptography==37.0.4
aiohttp==3.8.1 aiohttp==3.8.1

View File

@ -153,6 +153,25 @@ class TestCCXTExchange():
assert isinstance(markets[pair], dict) assert isinstance(markets[pair], dict)
assert exchange.market_is_spot(markets[pair]) assert exchange.market_is_spot(markets[pair])
def test_has_validations(self, exchange):
exchange, exchangename = exchange
exchange.validate_ordertypes({
'entry': 'limit',
'exit': 'limit',
'stoploss': 'limit',
})
if exchangename == 'gateio':
# gateio doesn't have market orders on spot
return
exchange.validate_ordertypes({
'entry': 'market',
'exit': 'market',
'stoploss': 'market',
})
def test_load_markets_futures(self, exchange_futures): def test_load_markets_futures(self, exchange_futures):
exchange, exchangename = exchange_futures exchange, exchangename = exchange_futures
if not exchange: if not exchange:

View File

@ -1027,10 +1027,9 @@ def test_validate_ordertypes(default_conf, mocker):
'stoploss': 'market', 'stoploss': 'market',
'stoploss_on_exchange': False 'stoploss_on_exchange': False
} }
# TODO: Revert once createMarketOrder is available again. with pytest.raises(OperationalException,
# with pytest.raises(OperationalException, match=r'Exchange .* does not support market orders.'):
# match=r'Exchange .* does not support market orders.'): Exchange(default_conf)
# Exchange(default_conf)
default_conf['order_types'] = { default_conf['order_types'] = {
'entry': 'limit', 'entry': 'limit',