Move stoploss_on_exchange_limit_ratio to configuration schema
This commit is contained in:
parent
0b36693acc
commit
5cebc9f39d
@ -389,13 +389,6 @@ class Exchange:
|
||||
f'On exchange stoploss is not supported for {self.name}.'
|
||||
)
|
||||
|
||||
# Limit price threshold: As limit price should always be below stop-price
|
||||
# Used for limit stoplosses on exchange
|
||||
limit_price_pct = order_types.get('stoploss_on_exchange_limit_ratio', 0.99)
|
||||
if limit_price_pct >= 1.0 or limit_price_pct <= 0.0:
|
||||
raise OperationalException(
|
||||
"stoploss_on_exchange_limit_ratio should be < 1.0 and > 0.0")
|
||||
|
||||
def validate_order_time_in_force(self, order_time_in_force: Dict) -> None:
|
||||
"""
|
||||
Checks if order time in force configured in strategy/config are supported
|
||||
|
@ -746,28 +746,6 @@ def test_validate_order_types(default_conf, mocker):
|
||||
match=r'On exchange stoploss is not supported for .*'):
|
||||
Exchange(default_conf)
|
||||
|
||||
default_conf['order_types'] = {
|
||||
'buy': 'limit',
|
||||
'sell': 'limit',
|
||||
'stoploss': 'limit',
|
||||
'stoploss_on_exchange': False,
|
||||
'stoploss_on_exchange_limit_ratio': 1.05
|
||||
}
|
||||
with pytest.raises(OperationalException,
|
||||
match=r'stoploss_on_exchange_limit_ratio should be < 1.0 and > 0.0'):
|
||||
Exchange(default_conf)
|
||||
|
||||
default_conf['order_types'] = {
|
||||
'buy': 'limit',
|
||||
'sell': 'limit',
|
||||
'stoploss': 'limit',
|
||||
'stoploss_on_exchange': False,
|
||||
'stoploss_on_exchange_limit_ratio': -0.1
|
||||
}
|
||||
with pytest.raises(OperationalException,
|
||||
match=r'stoploss_on_exchange_limit_ratio should be < 1.0 and > 0.0'):
|
||||
Exchange(default_conf)
|
||||
|
||||
|
||||
def test_validate_order_types_not_in_config(default_conf, mocker):
|
||||
api_mock = MagicMock()
|
||||
|
@ -871,6 +871,14 @@ def test_load_config_default_exchange_name(all_conf) -> None:
|
||||
validate_config_schema(all_conf)
|
||||
|
||||
|
||||
def test_load_config_stoploss_exchange_limit_ratio(all_conf) -> None:
|
||||
all_conf['order_types']['stoploss_on_exchange_limit_ratio'] = 1.15
|
||||
|
||||
with pytest.raises(ValidationError,
|
||||
match=r"1.15 is greater than the maximum"):
|
||||
validate_config_schema(all_conf)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("keys", [("exchange", "sandbox", False),
|
||||
("exchange", "key", ""),
|
||||
("exchange", "secret", ""),
|
||||
|
Loading…
Reference in New Issue
Block a user