Add more validation
This commit is contained in:
parent
cf9e99b8e1
commit
3497de3dd5
@ -5,7 +5,7 @@ bot constants
|
|||||||
"""
|
"""
|
||||||
from typing import Any, Dict, List, Literal, Tuple
|
from typing import Any, Dict, List, Literal, Tuple
|
||||||
|
|
||||||
from freqtrade.enums import CandleType, RPCMessageType
|
from freqtrade.enums import CandleType, PriceType, RPCMessageType
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_CONFIG = 'config.json'
|
DEFAULT_CONFIG = 'config.json'
|
||||||
@ -25,6 +25,7 @@ PRICING_SIDES = ['ask', 'bid', 'same', 'other']
|
|||||||
ORDERTYPE_POSSIBILITIES = ['limit', 'market']
|
ORDERTYPE_POSSIBILITIES = ['limit', 'market']
|
||||||
_ORDERTIF_POSSIBILITIES = ['GTC', 'FOK', 'IOC', 'PO']
|
_ORDERTIF_POSSIBILITIES = ['GTC', 'FOK', 'IOC', 'PO']
|
||||||
ORDERTIF_POSSIBILITIES = _ORDERTIF_POSSIBILITIES + [t.lower() for t in _ORDERTIF_POSSIBILITIES]
|
ORDERTIF_POSSIBILITIES = _ORDERTIF_POSSIBILITIES + [t.lower() for t in _ORDERTIF_POSSIBILITIES]
|
||||||
|
STOPLOSS_PRICE_TYPES = [p for p in PriceType]
|
||||||
HYPEROPT_LOSS_BUILTIN = ['ShortTradeDurHyperOptLoss', 'OnlyProfitHyperOptLoss',
|
HYPEROPT_LOSS_BUILTIN = ['ShortTradeDurHyperOptLoss', 'OnlyProfitHyperOptLoss',
|
||||||
'SharpeHyperOptLoss', 'SharpeHyperOptLossDaily',
|
'SharpeHyperOptLoss', 'SharpeHyperOptLossDaily',
|
||||||
'SortinoHyperOptLoss', 'SortinoHyperOptLossDaily',
|
'SortinoHyperOptLoss', 'SortinoHyperOptLossDaily',
|
||||||
@ -229,6 +230,7 @@ CONF_SCHEMA = {
|
|||||||
'default': 'market'},
|
'default': 'market'},
|
||||||
'stoploss': {'type': 'string', 'enum': ORDERTYPE_POSSIBILITIES},
|
'stoploss': {'type': 'string', 'enum': ORDERTYPE_POSSIBILITIES},
|
||||||
'stoploss_on_exchange': {'type': 'boolean'},
|
'stoploss_on_exchange': {'type': 'boolean'},
|
||||||
|
'stoploss_price_type': {'type': 'string', 'enum': STOPLOSS_PRICE_TYPES},
|
||||||
'stoploss_on_exchange_interval': {'type': 'number'},
|
'stoploss_on_exchange_interval': {'type': 'number'},
|
||||||
'stoploss_on_exchange_limit_ratio': {'type': 'number', 'minimum': 0.0,
|
'stoploss_on_exchange_limit_ratio': {'type': 'number', 'minimum': 0.0,
|
||||||
'maximum': 1.0}
|
'maximum': 1.0}
|
||||||
|
@ -50,7 +50,7 @@ def test_stoploss_order_binance(default_conf, mocker, limitratio, expected, side
|
|||||||
)
|
)
|
||||||
|
|
||||||
api_mock.create_order.reset_mock()
|
api_mock.create_order.reset_mock()
|
||||||
order_types = {'stoploss': 'limit'}
|
order_types = {'stoploss': 'limit', 'stoploss_price_type': 'mark'}
|
||||||
if limitratio is not None:
|
if limitratio is not None:
|
||||||
order_types.update({'stoploss_on_exchange_limit_ratio': limitratio})
|
order_types.update({'stoploss_on_exchange_limit_ratio': limitratio})
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ def test_stoploss_order_binance(default_conf, mocker, limitratio, expected, side
|
|||||||
if trademode == TradingMode.SPOT:
|
if trademode == TradingMode.SPOT:
|
||||||
params_dict = {'stopPrice': 220}
|
params_dict = {'stopPrice': 220}
|
||||||
else:
|
else:
|
||||||
params_dict = {'stopPrice': 220, 'reduceOnly': True}
|
params_dict = {'stopPrice': 220, 'reduceOnly': True, 'workingType': 'MARK_PRICE'}
|
||||||
assert api_mock.create_order.call_args_list[0][1]['params'] == params_dict
|
assert api_mock.create_order.call_args_list[0][1]['params'] == params_dict
|
||||||
|
|
||||||
# test exception handling
|
# test exception handling
|
||||||
|
Loading…
Reference in New Issue
Block a user