Update order time in force to use entry/exit wording
This commit is contained in:
@@ -319,6 +319,7 @@ def test_backtesting_init_no_timeframe(mocker, default_conf, caplog) -> None:
|
||||
del default_conf['timeframe']
|
||||
default_conf['strategy_list'] = [CURRENT_TEST_STRATEGY,
|
||||
'SampleStrategy']
|
||||
# TODO: This refers to the sampleStrategy in user_data if it exists...
|
||||
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_fee', MagicMock(return_value=0.5))
|
||||
with pytest.raises(OperationalException):
|
||||
|
@@ -45,8 +45,8 @@ class HyperoptableStrategy(IStrategy):
|
||||
|
||||
# Optional time in force for orders
|
||||
order_time_in_force = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc',
|
||||
'entry': 'gtc',
|
||||
'exit': 'gtc',
|
||||
}
|
||||
|
||||
buy_params = {
|
||||
|
@@ -47,8 +47,8 @@ class StrategyTestV2(IStrategy):
|
||||
|
||||
# Optional time in force for orders
|
||||
order_time_in_force = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc',
|
||||
'entry': 'gtc',
|
||||
'exit': 'gtc',
|
||||
}
|
||||
|
||||
# By default this strategy does not use Position Adjustments
|
||||
|
@@ -48,8 +48,8 @@ class StrategyTestV3(IStrategy):
|
||||
|
||||
# Optional time in force for orders
|
||||
order_time_in_force = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc',
|
||||
'entry': 'gtc',
|
||||
'exit': 'gtc',
|
||||
}
|
||||
|
||||
buy_params = {
|
||||
|
@@ -257,8 +257,8 @@ def test_strategy_override_order_tif(caplog, default_conf):
|
||||
caplog.set_level(logging.INFO)
|
||||
|
||||
order_time_in_force = {
|
||||
'buy': 'fok',
|
||||
'sell': 'gtc',
|
||||
'entry': 'fok',
|
||||
'exit': 'gtc',
|
||||
}
|
||||
|
||||
default_conf.update({
|
||||
@@ -268,15 +268,15 @@ def test_strategy_override_order_tif(caplog, default_conf):
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
assert strategy.order_time_in_force
|
||||
for method in ['buy', 'sell']:
|
||||
for method in ['entry', 'exit']:
|
||||
assert strategy.order_time_in_force[method] == order_time_in_force[method]
|
||||
|
||||
assert log_has("Override strategy 'order_time_in_force' with value in config file:"
|
||||
" {'buy': 'fok', 'sell': 'gtc'}.", caplog)
|
||||
" {'entry': 'fok', 'exit': 'gtc'}.", caplog)
|
||||
|
||||
default_conf.update({
|
||||
'strategy': CURRENT_TEST_STRATEGY,
|
||||
'order_time_in_force': {'buy': 'fok'}
|
||||
'order_time_in_force': {'entry': 'fok'}
|
||||
})
|
||||
# Raise error for invalid configuration
|
||||
with pytest.raises(ImportError,
|
||||
|
@@ -941,6 +941,28 @@ def test_validate_ask_orderbook(default_conf, caplog) -> None:
|
||||
validate_config_consistency(conf)
|
||||
|
||||
|
||||
def test_validate_time_in_force(default_conf, caplog) -> None:
|
||||
conf = deepcopy(default_conf)
|
||||
conf['order_time_in_force'] = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc',
|
||||
}
|
||||
validate_config_consistency(conf)
|
||||
assert log_has_re(r"DEPRECATED: Using 'buy' and 'sell' for time_in_force is.*", caplog)
|
||||
assert conf['order_time_in_force']['entry'] == 'gtc'
|
||||
assert conf['order_time_in_force']['exit'] == 'gtc'
|
||||
|
||||
conf = deepcopy(default_conf)
|
||||
conf['order_time_in_force'] = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc',
|
||||
}
|
||||
conf['trading_mode'] = 'futures'
|
||||
with pytest.raises(OperationalException,
|
||||
match=r"Please migrate your time_in_force settings .* 'entry' and 'exit'\."):
|
||||
validate_config_consistency(conf)
|
||||
|
||||
|
||||
def test_load_config_test_comments() -> None:
|
||||
"""
|
||||
Load config with comments
|
||||
|
Reference in New Issue
Block a user