freqtrade_origin/docs/webhook-config.md

189 lines
4.9 KiB
Markdown
Raw Normal View History

2018-07-07 12:13:49 +00:00
# Webhook usage
## Configuration
Enable webhooks by adding a webhook-section to your configuration file, and setting `webhook.enabled` to `true`.
Sample configuration (tested using IFTTT).
```json
"webhook": {
"enabled": true,
"url": "https://maker.ifttt.com/trigger/<YOUREVENT>/with/key/<YOURKEY>/",
"webhookbuy": {
"value1": "Buying {pair}",
"value2": "limit {limit:8f}",
"value3": "{stake_amount:8f} {stake_currency}"
},
2020-02-08 20:02:52 +00:00
"webhookbuycancel": {
2020-02-11 14:58:40 +00:00
"value1": "Cancelling Open Buy Order for {pair}",
2020-02-08 20:02:52 +00:00
"value2": "limit {limit:8f}",
"value3": "{stake_amount:8f} {stake_currency}"
},
"webhookbuyfill": {
"value1": "Buy Order for {pair} filled",
"value2": "at {open_rate:8f}",
"value3": ""
2020-02-08 20:02:52 +00:00
},
2018-07-07 12:13:49 +00:00
"webhooksell": {
"value1": "Selling {pair}",
"value2": "limit {limit:8f}",
2020-03-05 14:44:38 +00:00
"value3": "profit: {profit_amount:8f} {stake_currency} ({profit_ratio})"
2018-07-07 12:13:49 +00:00
},
2020-02-08 20:02:52 +00:00
"webhooksellcancel": {
2020-02-11 14:58:40 +00:00
"value1": "Cancelling Open Sell Order for {pair}",
2020-02-08 20:02:52 +00:00
"value2": "limit {limit:8f}",
2020-03-05 14:44:38 +00:00
"value3": "profit: {profit_amount:8f} {stake_currency} ({profit_ratio})"
2020-02-08 20:02:52 +00:00
},
"webhooksellfill": {
"value1": "Sell Order for {pair} filled",
"value2": "at {close_rate:8f}.",
"value3": ""
},
2018-07-07 12:13:49 +00:00
"webhookstatus": {
"value1": "Status: {status}",
"value2": "",
"value3": ""
}
},
```
The url in `webhook.url` should point to the correct url for your webhook. If you're using [IFTTT](https://ifttt.com) (as shown in the sample above) please insert our event and key to the url.
You can set the POST body format to Form-Encoded (default) or JSON-Encoded. Use `"format": "form"` or `"format": "json"` respectively. Example configuration for Mattermost Cloud integration:
```json
"webhook": {
"enabled": true,
"url": "https://<YOURSUBDOMAIN>.cloud.mattermost.com/hooks/<YOURHOOK>",
"format": "json",
"webhookstatus": {
"text": "Status: {status}"
}
},
```
2021-02-26 18:40:45 +00:00
The result would be POST request with e.g. `{"text":"Status: running"}` body and `Content-Type: application/json` header which results `Status: running` message in the Mattermost channel.
2018-07-07 12:13:49 +00:00
Different payloads can be configured for different events. Not all fields are necessary, but you should configure at least one of the dicts, otherwise the webhook will never be called.
### Webhookbuy
The fields in `webhook.webhookbuy` are filled when the bot executes a buy. Parameters are filled using string.format.
Possible parameters are:
* `trade_id`
2019-04-05 04:47:03 +00:00
* `exchange`
* `pair`
* `limit`
2020-02-08 20:02:52 +00:00
* `amount`
2020-02-08 20:19:07 +00:00
* `open_date`
2019-04-05 04:47:03 +00:00
* `stake_amount`
* `stake_currency`
* `fiat_currency`
2019-06-17 05:03:33 +00:00
* `order_type`
2020-02-08 20:02:52 +00:00
* `current_rate`
### Webhookbuycancel
The fields in `webhook.webhookbuycancel` are filled when the bot cancels a buy order. Parameters are filled using string.format.
Possible parameters are:
* `trade_id`
2020-02-08 20:02:52 +00:00
* `exchange`
* `pair`
* `limit`
* `amount`
2020-02-08 20:19:07 +00:00
* `open_date`
2020-02-08 20:02:52 +00:00
* `stake_amount`
* `stake_currency`
* `fiat_currency`
* `order_type`
* `current_rate`
2018-07-07 12:13:49 +00:00
### Webhookbuyfill
The fields in `webhook.webhookbuyfill` are filled when the bot filled a buy order. Parameters are filled using string.format.
Possible parameters are:
* `trade_id`
* `exchange`
* `pair`
* `open_rate`
* `amount`
* `open_date`
* `stake_amount`
* `stake_currency`
* `fiat_currency`
2018-07-07 12:13:49 +00:00
### Webhooksell
The fields in `webhook.webhooksell` are filled when the bot sells a trade. Parameters are filled using string.format.
Possible parameters are:
* `trade_id`
2019-04-05 04:47:03 +00:00
* `exchange`
* `pair`
* `gain`
* `limit`
* `amount`
* `open_rate`
* `profit_amount`
* `profit_ratio`
* `stake_currency`
* `fiat_currency`
* `sell_reason`
* `order_type`
* `open_date`
* `close_date`
### Webhooksellfill
The fields in `webhook.webhooksellfill` are filled when the bot fills a sell order (closes a Trae). Parameters are filled using string.format.
Possible parameters are:
* `trade_id`
* `exchange`
* `pair`
* `gain`
* `close_rate`
* `amount`
* `open_rate`
2019-04-05 04:47:03 +00:00
* `current_rate`
* `profit_amount`
2020-03-05 14:44:38 +00:00
* `profit_ratio`
2019-04-05 04:47:03 +00:00
* `stake_currency`
* `fiat_currency`
* `sell_reason`
2019-06-17 05:03:33 +00:00
* `order_type`
2019-12-08 13:10:26 +00:00
* `open_date`
* `close_date`
2018-07-07 12:13:49 +00:00
2020-02-08 20:02:52 +00:00
### Webhooksellcancel
The fields in `webhook.webhooksellcancel` are filled when the bot cancels a sell order. Parameters are filled using string.format.
Possible parameters are:
* `trade_id`
2020-02-08 20:02:52 +00:00
* `exchange`
* `pair`
* `gain`
* `limit`
* `amount`
* `open_rate`
* `current_rate`
* `profit_amount`
2020-03-05 14:44:38 +00:00
* `profit_ratio`
2020-02-08 20:02:52 +00:00
* `stake_currency`
* `fiat_currency`
* `sell_reason`
* `order_type`
* `open_date`
2020-02-08 20:19:07 +00:00
* `close_date`
2020-02-08 20:02:52 +00:00
2018-07-07 12:13:49 +00:00
### Webhookstatus
The fields in `webhook.webhookstatus` are used for regular status messages (Started / Stopped / ...). Parameters are filled using string.format.
The only possible value here is `{status}`.