stable/docs/includes/protections.md

156 lines
5.7 KiB
Markdown
Raw Normal View History

2020-10-14 05:40:44 +00:00
## Protections
2020-11-27 16:51:58 +00:00
!!! Warning "Beta feature"
This feature is still in it's testing phase. Should you notice something you think is wrong please let us know via Discord, Slack or via Issue.
2020-11-27 09:29:45 +00:00
Protections will protect your strategy from unexpected events and market conditions by temporarily stop trading for either one pair, or for all pairs.
2020-11-27 16:14:28 +00:00
All protection end times are rounded up to the next candle to avoid sudden, unexpected intra-candle buys.
2020-10-14 05:40:44 +00:00
2020-11-11 19:54:24 +00:00
!!! Note
Not all Protections will work for all strategies, and parameters will need to be tuned for your strategy.
!!! Tip
Each Protection can be configured multiple times with different parameters, to allow different levels of protection (short-term / long-term).
2020-12-07 07:22:12 +00:00
### Available Protections
2020-10-14 05:40:44 +00:00
2020-11-11 19:54:24 +00:00
* [`StoplossGuard`](#stoploss-guard) Stop trading if a certain amount of stoploss occurred within a certain time window.
* [`MaxDrawdown`](#maxdrawdown) Stop trading if max-drawdown is reached.
2020-11-11 19:54:24 +00:00
* [`LowProfitPairs`](#low-profit-pairs) Lock pairs with low profits
* [`CooldownPeriod`](#cooldown-period) Don't enter a trade right after selling a trade.
2020-10-14 05:40:44 +00:00
2020-12-07 07:22:12 +00:00
### Common settings to all Protections
* `method` - Protection name to use.
2020-12-07 07:22:12 +00:00
* `stop_duration` (minutes) - how long should protections be locked.
* `lookback_period` (minutes) - Only trades that completed after `current_time - lookback_period` will be considered (may be ignored by some Protections).
* `trade_limit` - How many trades are required at minimum (not used by all Protections).
2020-12-07 07:22:12 +00:00
2020-10-14 05:40:44 +00:00
#### Stoploss Guard
2020-12-07 07:22:12 +00:00
`StoplossGuard` selects all trades within `lookback_period` (in minutes), and determines if the amount of trades that resulted in stoploss are above `trade_limit` - in which case trading will stop for `stop_duration`.
2020-11-25 10:11:55 +00:00
This applies across all pairs, unless `only_per_pair` is set to true, which will then only look at one pair at a time.
2020-10-14 05:40:44 +00:00
The below example stops trading for all pairs for 2 hours (120min) after the last trade if the bot hit stoploss 4 times within the last 24h.
2020-10-14 05:40:44 +00:00
```json
2020-11-11 19:54:24 +00:00
"protections": [
{
2020-10-14 05:40:44 +00:00
"method": "StoplossGuard",
"lookback_period": 1440,
2020-11-11 07:00:10 +00:00
"trade_limit": 4,
"stop_duration": 120,
2020-11-25 10:11:55 +00:00
"only_per_pair": false
2020-11-11 19:54:24 +00:00
}
],
2020-10-14 05:40:44 +00:00
```
!!! Note
`StoplossGuard` considers all trades with the results `"stop_loss"` and `"trailing_stop_loss"` if the resulting profit was negative.
2020-11-11 19:54:24 +00:00
`trade_limit` and `lookback_period` will need to be tuned for your strategy.
2020-10-14 05:40:44 +00:00
#### MaxDrawdown
`MaxDrawdown` uses all trades within `lookback_period` (in minutes) to determine the maximum drawdown. If the drawdown is below `max_allowed_drawdown`, trading will stop for `stop_duration` (in minutes) after the last trade - assuming that the bot needs some time to let markets recover.
The below sample stops trading for 12 hours (720min) if max-drawdown is > 20% considering all trades within the last 2 days (2880min).
```json
"protections": [
{
"method": "MaxDrawdown",
"lookback_period": 2880,
"trade_limit": 20,
"stop_duration": 720,
"max_allowed_drawdown": 0.2
},
],
```
2020-11-11 06:49:30 +00:00
#### Low Profit Pairs
2020-12-07 07:22:12 +00:00
`LowProfitPairs` uses all trades for a pair within `lookback_period` (in minutes) to determine the overall profit ratio.
2020-11-11 06:49:30 +00:00
If that ratio is below `required_profit`, that pair will be locked for `stop_duration` (in minutes).
The below example will stop trading a pair for 60 minutes if the pair does not have a required profit of 2% (and a minimum of 2 trades) within the last 6 hours (360min).
2020-11-11 06:49:30 +00:00
```json
2020-11-11 07:00:10 +00:00
"protections": [
{
2020-11-11 19:54:24 +00:00
"method": "LowProfitPairs",
"lookback_period": 360,
"trade_limit": 2,
2020-11-11 06:49:30 +00:00
"stop_duration": 60,
"required_profit": 0.02
2020-11-11 07:00:10 +00:00
}
],
2020-11-11 06:49:30 +00:00
```
2020-11-11 07:00:10 +00:00
#### Cooldown Period
`CooldownPeriod` locks a pair for `stop_duration` (in minutes) after selling, avoiding a re-entry for this pair for `stop_duration` minutes.
```json
"protections": [
{
"method": "CooldownPeriod",
"stop_duration": 60
}
],
```
2020-12-07 07:22:12 +00:00
!!! Note
2020-11-11 07:00:10 +00:00
This Protection applies only at pair-level, and will never lock all pairs globally.
2020-12-07 07:22:12 +00:00
This Protection does not consider `lookback_period` as it only looks at the latest trade.
2020-11-11 07:00:10 +00:00
2020-10-14 05:40:44 +00:00
### Full example of Protections
2020-11-11 07:00:10 +00:00
All protections can be combined at will, also with different parameters, creating a increasing wall for under-performing pairs.
All protections are evaluated in the sequence they are defined.
The below example:
* Locks each pair after selling for an additional 10 minutes (`CooldownPeriod`), giving other pairs a chance to get filled.
* Stops trading if the last 2 days had 20 trades, which caused a max-drawdown of more than 20%. (`MaxDrawdown`).
* Stops trading if more than 4 stoploss occur for all pairs within a 1 day (1440min) limit (`StoplossGuard`).
* Locks all pairs that had 4 Trades within the last 6 hours (`60 * 6 = 360`) with a combined profit ratio of below 0.02 (<2%) (`LowProfitPairs`).
* Locks all pairs for 120 minutes that had a profit of below 0.01 (<1%) within the last 24h (`60 * 24 = 1440`), a minimum of 4 trades.
2020-10-14 05:40:44 +00:00
```json
"protections": [
2020-11-11 07:00:10 +00:00
{
"method": "CooldownPeriod",
"stop_duration": 10
},
{
"method": "MaxDrawdown",
"lookback_period": 2880,
"trade_limit": 20,
"stop_duration": 720,
"max_allowed_drawdown": 0.2
},
2020-10-14 05:40:44 +00:00
{
"method": "StoplossGuard",
"lookback_period": 1440,
2020-11-11 07:00:10 +00:00
"trade_limit": 4,
"stop_duration": 120,
"only_per_pair": false
2020-11-11 07:00:10 +00:00
},
{
2020-11-11 19:54:24 +00:00
"method": "LowProfitPairs",
2020-11-11 07:00:10 +00:00
"lookback_period": 360,
"trade_limit": 2,
2020-11-11 07:00:10 +00:00
"stop_duration": 60,
"required_profit": 0.02
},
{
2020-11-11 19:54:24 +00:00
"method": "LowProfitPairs",
2020-11-11 07:00:10 +00:00
"lookback_period": 1440,
"trade_limit": 4,
2020-11-11 07:00:10 +00:00
"stop_duration": 120,
"required_profit": 0.01
2020-10-14 05:40:44 +00:00
}
],
```