Performance Thresholds and Market Valuation in a Bot Kill Switch
Summary
The document explains a kill switch that stops a trading bot when its calculated performance crosses a user-set profit or loss threshold. The threshold can be configured in the bot or its client settings file, and the performance calculation follows the same method as the history command. The example illustrates how a change in market price can alter reported performance even when the bot makes no further trades, potentially triggering the stop condition.
This is a risk control for limiting continued strategy operation after a specified performance level is reached. Its behavior depends on how performance is calculated and on changing market prices, so the trigger does not necessarily correspond to a new trade or a realized loss. The example shows a decline in reported return after ETH's end price falls, but it does not establish how the feature performs across strategies or market conditions. Users need to choose a threshold appropriate to their setup and understand the performance measure being monitored.
Key ideas
- A kill switch stops the bot when its calculated performance reaches a configured profit or loss threshold.
- The threshold can be changed through bot configuration or the client settings file.
- Market price changes can affect the bot's reported performance without additional trades.
- The trigger reflects the performance calculation used by the history command.
Tags
Full text
# kill switch
Automatically stops the bot when it reaches a certain performance threshold, which can be either positive or negative. This feature uses the same performance calculation methodology as the [history](../history.md) command.
```
Select your kill-switch mode (kill_switch_enabled/kill_switch_disabled) >>>
At what profit/loss rate would you like the bot to stop? (e.g. -5 equals 5 percent loss) >>>
```
You can always reconfigure this feature in two ways:
1. Inside Hummingbot run command `config kill_switch_mode` and/or `config kill_switch_mode.kill_switch_rate`.
2. Edit the `conf_client.yml` file located inside the `hummingbot_conf` folder using a text editor.
!!! Note
In past versions of Hummingbot (1.5.0 and below), the `conf_client.yml` file is named `conf_global.yml`
Note that when the market prices changes, so does the bot's performance and may trigger the kill switch. For example, we executed 13 trades and our performance are shown below.
```json
kill_switch_mode:
kill_switch_rate: -5.0
```
```
Inventory:
Market Asset Starting Current Net Delta Trade Delta
0 binance ETH 10.0000 11.0000 1.0000 3.0000
1 binance USDT 500.0000 297.1580 -202.8420 -610.6340
Markets:
Market Pair Start Price End Price Trades Trade Value Delta
0 binance ETHUSDT 203.913 202.7150000000 13 -2.48900000 USDT
Performance:
Started: 2020-05-26 10:28:03
Duration: 0 days 00:07:06
Total Trade Value Delta: -2.489 USDT
Return %: -0.0985 %
```
After a while, the end price changed from 202.715 to 200.54 and so did our bot's performance even without making more trades. Since `kill_switch_rate` is set to `-0.3` this will stop the strategy.
```
Inventory:
Market Asset Starting Current Net Delta Trade Delta
0 binance ETH 10.0000 11.0000 1.0000 3.0000
1 binance USDT 500.0000 297.1580 -202.8420 -610.6340
Markets:
Market Pair Start Price End Price Trades Trade Value Delta
0 binance ETHUSDT 203.913 200.5400000000 13 -9.01400000 USDT
Performance:
Started: 2020-05-26 10:28:03
Duration: 0 days 02:09:13
Total Trade Value Delta: -9.014 USDT
Return %: -0.3598 %
```
```
[Kill switch triggered]
Current profitability is -0.003550034854458. Stopping the bot...
kill_switch - Kill switch threshold reached. Stopping the bot...
```Shown in full with attribution under the source's licence. Licence: Apache-2.0
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.