parent
245e39e523
commit
3629892fc3
@ -40,7 +40,9 @@ All protection end times are rounded up to the next candle to avoid sudden, unex
|
|||||||
|
|
||||||
#### Stoploss Guard
|
#### Stoploss Guard
|
||||||
|
|
||||||
`StoplossGuard` selects all trades within `lookback_period` in minutes (or in candles when using `lookback_period_candles`), and determines if the amount of trades that resulted in stoploss are above `trade_limit` - in which case trading will stop for `stop_duration` in minutes (or in candles when using `stop_duration_candles`).
|
`StoplossGuard` selects all trades within `lookback_period` in minutes (or in candles when using `lookback_period_candles`).
|
||||||
|
If `trade_limit` or more trades resulted in stoploss, trading will stop for `stop_duration` in minutes (or in candles when using `stop_duration_candles`).
|
||||||
|
|
||||||
This applies across all pairs, unless `only_per_pair` is set to true, which will then only look at one pair at a time.
|
This applies across all pairs, unless `only_per_pair` is set to true, which will then only look at one pair at a time.
|
||||||
|
|
||||||
The below example stops trading for all pairs for 4 candles after the last trade if the bot hit stoploss 4 times within the last 24 candles.
|
The below example stops trading for all pairs for 4 candles after the last trade if the bot hit stoploss 4 times within the last 24 candles.
|
||||||
|
@ -58,13 +58,13 @@ class StoplossGuard(IProtection):
|
|||||||
SellType.STOPLOSS_ON_EXCHANGE.value)
|
SellType.STOPLOSS_ON_EXCHANGE.value)
|
||||||
and trade.close_profit < 0)]
|
and trade.close_profit < 0)]
|
||||||
|
|
||||||
if len(trades) > self._trade_limit:
|
if len(trades) < self._trade_limit:
|
||||||
self.log_once(f"Trading stopped due to {self._trade_limit} "
|
return False, None, None
|
||||||
f"stoplosses within {self._lookback_period} minutes.", logger.info)
|
|
||||||
until = self.calculate_lock_end(trades, self._stop_duration)
|
|
||||||
return True, until, self._reason()
|
|
||||||
|
|
||||||
return False, None, None
|
self.log_once(f"Trading stopped due to {self._trade_limit} "
|
||||||
|
f"stoplosses within {self._lookback_period} minutes.", logger.info)
|
||||||
|
until = self.calculate_lock_end(trades, self._stop_duration)
|
||||||
|
return True, until, self._reason()
|
||||||
|
|
||||||
def global_stop(self, date_now: datetime) -> ProtectionReturn:
|
def global_stop(self, date_now: datetime) -> ProtectionReturn:
|
||||||
"""
|
"""
|
||||||
|
@ -83,7 +83,7 @@ def test_stoploss_guard(mocker, default_conf, fee, caplog):
|
|||||||
"method": "StoplossGuard",
|
"method": "StoplossGuard",
|
||||||
"lookback_period": 60,
|
"lookback_period": 60,
|
||||||
"stop_duration": 40,
|
"stop_duration": 40,
|
||||||
"trade_limit": 2
|
"trade_limit": 3
|
||||||
}]
|
}]
|
||||||
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||||
message = r"Trading stopped due to .*"
|
message = r"Trading stopped due to .*"
|
||||||
@ -136,7 +136,7 @@ def test_stoploss_guard_perpair(mocker, default_conf, fee, caplog, only_per_pair
|
|||||||
default_conf['protections'] = [{
|
default_conf['protections'] = [{
|
||||||
"method": "StoplossGuard",
|
"method": "StoplossGuard",
|
||||||
"lookback_period": 60,
|
"lookback_period": 60,
|
||||||
"trade_limit": 1,
|
"trade_limit": 2,
|
||||||
"stop_duration": 60,
|
"stop_duration": 60,
|
||||||
"only_per_pair": only_per_pair
|
"only_per_pair": only_per_pair
|
||||||
}]
|
}]
|
||||||
|
Loading…
Reference in New Issue
Block a user