sell_profit_only -> exit_profit_only
This commit is contained in:
parent
a07cf45968
commit
66cadcac01
@ -116,8 +116,8 @@ Mandatory parameters are marked as **Required**, which means that they are requi
|
||||
| `ask_strategy.use_order_book` | Enable selling of open trades using [Order Book Asks](#sell-price-with-orderbook-enabled). <br> **Datatype:** Boolean
|
||||
| `ask_strategy.order_book_top` | Bot will use the top N rate in Order Book "price_side" to sell. I.e. a value of 2 will allow the bot to pick the 2nd ask rate in [Order Book Asks](#sell-price-with-orderbook-enabled)<br>*Defaults to `1`.* <br> **Datatype:** Positive Integer
|
||||
| `use_exit_signal` | Use sell signals produced by the strategy in addition to the `minimal_roi`. [Strategy Override](#parameters-in-the-strategy). <br>*Defaults to `true`.* <br> **Datatype:** Boolean
|
||||
| `sell_profit_only` | Wait until the bot reaches `sell_profit_offset` before taking a sell decision. [Strategy Override](#parameters-in-the-strategy). <br>*Defaults to `false`.* <br> **Datatype:** Boolean
|
||||
| `sell_profit_offset` | Sell-signal is only active above this value. Only active in combination with `sell_profit_only=True`. [Strategy Override](#parameters-in-the-strategy). <br>*Defaults to `0.0`.* <br> **Datatype:** Float (as ratio)
|
||||
| `exit_profit_only` | Wait until the bot reaches `sell_profit_offset` before taking a sell decision. [Strategy Override](#parameters-in-the-strategy). <br>*Defaults to `false`.* <br> **Datatype:** Boolean
|
||||
| `sell_profit_offset` | Sell-signal is only active above this value. Only active in combination with `exit_profit_only=True`. [Strategy Override](#parameters-in-the-strategy). <br>*Defaults to `0.0`.* <br> **Datatype:** Float (as ratio)
|
||||
| `ignore_roi_if_enter_signal` | Do not sell if the buy signal is still active. This setting takes preference over `minimal_roi` and `use_exit_signal`. [Strategy Override](#parameters-in-the-strategy). <br>*Defaults to `false`.* <br> **Datatype:** Boolean
|
||||
| `ignore_buying_expired_candle_after` | Specifies the number of seconds until a buy signal is no longer used. <br> **Datatype:** Integer
|
||||
| `order_types` | Configure order-types depending on the action (`"buy"`, `"sell"`, `"stoploss"`, `"stoploss_on_exchange"`). [More information below](#understand-order_types). [Strategy Override](#parameters-in-the-strategy).<br> **Datatype:** Dict
|
||||
@ -194,7 +194,7 @@ Values set in the configuration file always overwrite values set in the strategy
|
||||
* `unfilledtimeout`
|
||||
* `disable_dataframe_checks`
|
||||
* `use_exit_signal`
|
||||
* `sell_profit_only`
|
||||
* `exit_profit_only`
|
||||
* `sell_profit_offset`
|
||||
* `ignore_roi_if_enter_signal`
|
||||
* `ignore_buying_expired_candle_after`
|
||||
|
@ -89,7 +89,7 @@ For example you could implement a 1:2 risk-reward ROI with `custom_exit()`.
|
||||
Using custom_exit() signals in place of stoploss though *is not recommended*. It is a inferior method to using `custom_stoploss()` in this regard - which also allows you to keep the stoploss on exchange.
|
||||
|
||||
!!! Note
|
||||
Returning a (none-empty) `string` or `True` from this method is equal to setting sell signal on a candle at specified time. This method is not called when sell signal is set already, or if sell signals are disabled (`use_exit_signal=False` or `sell_profit_only=True` while profit is below `sell_profit_offset`). `string` max length is 64 characters. Exceeding this limit will cause the message to be truncated to 64 characters.
|
||||
Returning a (none-empty) `string` or `True` from this method is equal to setting sell signal on a candle at specified time. This method is not called when sell signal is set already, or if sell signals are disabled (`use_exit_signal=False` or `exit_profit_only=True` while profit is below `sell_profit_offset`). `string` max length is 64 characters. Exceeding this limit will cause the message to be truncated to 64 characters.
|
||||
|
||||
An example of how we can use different indicators depending on the current profit and also sell trades that were open longer than one day:
|
||||
|
||||
|
@ -73,8 +73,8 @@ def process_temporary_deprecated_settings(config: Dict[str, Any]) -> None:
|
||||
# 'experimental', 'use_exit_signal')
|
||||
process_deprecated_setting(config, 'ask_strategy', 'use_exit_signal',
|
||||
None, 'use_exit_signal')
|
||||
process_deprecated_setting(config, 'ask_strategy', 'sell_profit_only',
|
||||
None, 'sell_profit_only')
|
||||
process_deprecated_setting(config, 'ask_strategy', 'exit_profit_only',
|
||||
None, 'exit_profit_only')
|
||||
process_deprecated_setting(config, 'ask_strategy', 'sell_profit_offset',
|
||||
None, 'sell_profit_offset')
|
||||
process_deprecated_setting(config, 'ask_strategy', 'ignore_roi_if_enter_signal',
|
||||
@ -85,8 +85,8 @@ def process_temporary_deprecated_settings(config: Dict[str, Any]) -> None:
|
||||
# Legacy way - having them in experimental ...
|
||||
process_removed_setting(config, 'experimental', 'use_exit_signal',
|
||||
None, 'use_exit_signal')
|
||||
process_removed_setting(config, 'experimental', 'sell_profit_only',
|
||||
None, 'sell_profit_only')
|
||||
process_removed_setting(config, 'experimental', 'exit_profit_only',
|
||||
None, 'exit_profit_only')
|
||||
process_removed_setting(config, 'experimental', 'ignore_roi_if_enter_signal',
|
||||
None, 'ignore_roi_if_enter_signal')
|
||||
|
||||
|
@ -148,7 +148,7 @@ CONF_SCHEMA = {
|
||||
'trailing_stop_positive_offset': {'type': 'number', 'minimum': 0, 'maximum': 1},
|
||||
'trailing_only_offset_is_reached': {'type': 'boolean'},
|
||||
'use_exit_signal': {'type': 'boolean'},
|
||||
'sell_profit_only': {'type': 'boolean'},
|
||||
'exit_profit_only': {'type': 'boolean'},
|
||||
'sell_profit_offset': {'type': 'number'},
|
||||
'ignore_roi_if_enter_signal': {'type': 'boolean'},
|
||||
'ignore_buying_expired_candle_after': {'type': 'number'},
|
||||
|
@ -460,7 +460,7 @@ def generate_strategy_stats(btdata: Dict[str, DataFrame],
|
||||
'use_custom_stoploss': config.get('use_custom_stoploss', False),
|
||||
'minimal_roi': config['minimal_roi'],
|
||||
'use_exit_signal': config['use_exit_signal'],
|
||||
'sell_profit_only': config['sell_profit_only'],
|
||||
'exit_profit_only': config['exit_profit_only'],
|
||||
'sell_profit_offset': config['sell_profit_offset'],
|
||||
'ignore_roi_if_enter_signal': config['ignore_roi_if_enter_signal'],
|
||||
**daily_stats,
|
||||
|
@ -92,7 +92,7 @@ class StrategyResolver(IResolver):
|
||||
("startup_candle_count", None),
|
||||
("unfilledtimeout", None),
|
||||
("use_exit_signal", True),
|
||||
("sell_profit_only", False),
|
||||
("exit_profit_only", False),
|
||||
("ignore_roi_if_enter_signal", False),
|
||||
("sell_profit_offset", 0.0),
|
||||
("disable_dataframe_checks", False),
|
||||
|
@ -102,7 +102,7 @@ class IStrategy(ABC, HyperStrategyMixin):
|
||||
process_only_new_candles: bool = False
|
||||
|
||||
use_exit_signal: bool
|
||||
sell_profit_only: bool
|
||||
exit_profit_only: bool
|
||||
sell_profit_offset: float
|
||||
ignore_roi_if_enter_signal: bool
|
||||
|
||||
@ -790,8 +790,8 @@ class IStrategy(ABC, HyperStrategyMixin):
|
||||
current_rate = rate
|
||||
current_profit = trade.calc_profit_ratio(current_rate)
|
||||
|
||||
if (self.sell_profit_only and current_profit <= self.sell_profit_offset):
|
||||
# sell_profit_only and profit doesn't reach the offset - ignore sell signal
|
||||
if (self.exit_profit_only and current_profit <= self.sell_profit_offset):
|
||||
# exit_profit_only and profit doesn't reach the offset - ignore sell signal
|
||||
pass
|
||||
elif self.use_exit_signal and not enter:
|
||||
if exit_:
|
||||
|
@ -63,7 +63,7 @@ class {{ strategy }}(IStrategy):
|
||||
|
||||
# These values can be overridden in the "ask_strategy" section in the config.
|
||||
use_exit_signal = True
|
||||
sell_profit_only = False
|
||||
exit_profit_only = False
|
||||
ignore_roi_if_enter_signal = False
|
||||
|
||||
# Number of candles the strategy requires before producing valid signals
|
||||
|
@ -68,7 +68,7 @@ class SampleShortStrategy(IStrategy):
|
||||
|
||||
# These values can be overridden in the "ask_strategy" section in the config.
|
||||
use_exit_signal = True
|
||||
sell_profit_only = False
|
||||
exit_profit_only = False
|
||||
ignore_roi_if_enter_signal = False
|
||||
|
||||
# Number of candles the strategy requires before producing valid signals
|
||||
|
@ -69,7 +69,7 @@ class SampleStrategy(IStrategy):
|
||||
|
||||
# These values can be overridden in the "ask_strategy" section in the config.
|
||||
use_exit_signal = True
|
||||
sell_profit_only = False
|
||||
exit_profit_only = False
|
||||
ignore_roi_if_enter_signal = False
|
||||
|
||||
# Number of candles the strategy requires before producing valid signals
|
||||
|
@ -986,7 +986,7 @@ def test_backtest_start_multi_strat(default_conf, mocker, caplog, testdatadir):
|
||||
|
||||
default_conf.update({
|
||||
"use_exit_signal": True,
|
||||
"sell_profit_only": False,
|
||||
"exit_profit_only": False,
|
||||
"sell_profit_offset": 0.0,
|
||||
"ignore_roi_if_enter_signal": False,
|
||||
})
|
||||
@ -1061,7 +1061,7 @@ def test_backtest_start_multi_strat(default_conf, mocker, caplog, testdatadir):
|
||||
def test_backtest_start_multi_strat_nomock(default_conf, mocker, caplog, testdatadir, capsys):
|
||||
default_conf.update({
|
||||
"use_exit_signal": True,
|
||||
"sell_profit_only": False,
|
||||
"exit_profit_only": False,
|
||||
"sell_profit_offset": 0.0,
|
||||
"ignore_roi_if_enter_signal": False,
|
||||
})
|
||||
@ -1173,7 +1173,7 @@ def test_backtest_start_multi_strat_nomock_detail(default_conf, mocker,
|
||||
# Tests detail-data loading
|
||||
default_conf.update({
|
||||
"use_exit_signal": True,
|
||||
"sell_profit_only": False,
|
||||
"exit_profit_only": False,
|
||||
"sell_profit_offset": 0.0,
|
||||
"ignore_roi_if_enter_signal": False,
|
||||
})
|
||||
|
@ -308,27 +308,27 @@ def test_strategy_override_use_exit_signal(caplog, default_conf):
|
||||
assert log_has("Override strategy 'use_exit_signal' with value in config file: False.", caplog)
|
||||
|
||||
|
||||
def test_strategy_override_use_sell_profit_only(caplog, default_conf):
|
||||
def test_strategy_override_use_exit_profit_only(caplog, default_conf):
|
||||
caplog.set_level(logging.INFO)
|
||||
default_conf.update({
|
||||
'strategy': CURRENT_TEST_STRATEGY,
|
||||
})
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
assert not strategy.sell_profit_only
|
||||
assert isinstance(strategy.sell_profit_only, bool)
|
||||
assert not strategy.exit_profit_only
|
||||
assert isinstance(strategy.exit_profit_only, bool)
|
||||
# must be inserted to configuration
|
||||
assert 'sell_profit_only' in default_conf
|
||||
assert not default_conf['sell_profit_only']
|
||||
assert 'exit_profit_only' in default_conf
|
||||
assert not default_conf['exit_profit_only']
|
||||
|
||||
default_conf.update({
|
||||
'strategy': CURRENT_TEST_STRATEGY,
|
||||
'sell_profit_only': True,
|
||||
'exit_profit_only': True,
|
||||
})
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
assert strategy.sell_profit_only
|
||||
assert isinstance(strategy.sell_profit_only, bool)
|
||||
assert log_has("Override strategy 'sell_profit_only' with value in config file: True.", caplog)
|
||||
assert strategy.exit_profit_only
|
||||
assert isinstance(strategy.exit_profit_only, bool)
|
||||
assert log_has("Override strategy 'exit_profit_only' with value in config file: True.", caplog)
|
||||
|
||||
|
||||
@pytest.mark.filterwarnings("ignore:deprecated")
|
||||
|
@ -1120,8 +1120,8 @@ def test_pairlist_resolving_fallback(mocker):
|
||||
@pytest.mark.parametrize("setting", [
|
||||
("ask_strategy", "use_exit_signal", True,
|
||||
None, "use_exit_signal", False),
|
||||
("ask_strategy", "sell_profit_only", True,
|
||||
None, "sell_profit_only", False),
|
||||
("ask_strategy", "exit_profit_only", True,
|
||||
None, "exit_profit_only", False),
|
||||
("ask_strategy", "sell_profit_offset", 0.1,
|
||||
None, "sell_profit_offset", 0.01),
|
||||
("ask_strategy", "ignore_roi_if_enter_signal", True,
|
||||
@ -1169,7 +1169,7 @@ def test_process_temporary_deprecated_settings(mocker, default_conf, setting, ca
|
||||
|
||||
@pytest.mark.parametrize("setting", [
|
||||
("experimental", "use_exit_signal", False),
|
||||
("experimental", "sell_profit_only", True),
|
||||
("experimental", "exit_profit_only", True),
|
||||
("experimental", "ignore_roi_if_enter_signal", True),
|
||||
])
|
||||
def test_process_removed_settings(mocker, default_conf, setting):
|
||||
|
@ -3416,7 +3416,7 @@ def test_execute_trade_exit_insufficient_funds_error(default_conf_usdt, ticker_u
|
||||
(False, 0.10, 0.22, True, False, ExitType.EXIT_SIGNAL.value, False),
|
||||
(False, 0.10, 0.22, True, False, ExitType.EXIT_SIGNAL.value, True),
|
||||
])
|
||||
def test_sell_profit_only(
|
||||
def test_exit_profit_only(
|
||||
default_conf_usdt, limit_order, limit_order_open, is_short,
|
||||
fee, mocker, profit_only, bid, ask, handle_first, handle_second, exit_type) -> None:
|
||||
patch_RPCManager(mocker)
|
||||
@ -3436,7 +3436,7 @@ def test_sell_profit_only(
|
||||
)
|
||||
default_conf_usdt.update({
|
||||
'use_exit_signal': True,
|
||||
'sell_profit_only': profit_only,
|
||||
'exit_profit_only': profit_only,
|
||||
'sell_profit_offset': 0.1,
|
||||
})
|
||||
freqtrade = FreqtradeBot(default_conf_usdt)
|
||||
|
10
tests/testdata/strategy_SampleStrategy.fthypt
vendored
10
tests/testdata/strategy_SampleStrategy.fthypt
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user