Elffuss BraidHub

kikocis/freqtrade public

develop · 4.9 KiBRenderedRawPermalink
1# Webhook usage
2
3## Configuration
4
5Enable webhooks by adding a webhook-section to your configuration file, and setting `webhook.enabled` to `true`.
6
7Sample configuration (tested using IFTTT).
8
9```json
10 "webhook": {
11 "enabled": true,
12 "url": "https://maker.ifttt.com/trigger/<YOUREVENT>/with/key/<YOURKEY>/",
13 "webhookbuy": {
14 "value1": "Buying {pair}",
15 "value2": "limit {limit:8f}",
16 "value3": "{stake_amount:8f} {stake_currency}"
17 },
18 "webhookbuycancel": {
19 "value1": "Cancelling Open Buy Order for {pair}",
20 "value2": "limit {limit:8f}",
21 "value3": "{stake_amount:8f} {stake_currency}"
22 },
23 "webhookbuyfill": {
24 "value1": "Buy Order for {pair} filled",
25 "value2": "at {open_rate:8f}",
26 "value3": ""
27 },
28 "webhooksell": {
29 "value1": "Selling {pair}",
30 "value2": "limit {limit:8f}",
31 "value3": "profit: {profit_amount:8f} {stake_currency} ({profit_ratio})"
32 },
33 "webhooksellcancel": {
34 "value1": "Cancelling Open Sell Order for {pair}",
35 "value2": "limit {limit:8f}",
36 "value3": "profit: {profit_amount:8f} {stake_currency} ({profit_ratio})"
37 },
38 "webhooksellfill": {
39 "value1": "Sell Order for {pair} filled",
40 "value2": "at {close_rate:8f}.",
41 "value3": ""
42 },
43 "webhookstatus": {
44 "value1": "Status: {status}",
45 "value2": "",
46 "value3": ""
47 }
48 },
49```
50
51The 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.
52
53You 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:
54
55```json
56 "webhook": {
57 "enabled": true,
58 "url": "https://<YOURSUBDOMAIN>.cloud.mattermost.com/hooks/<YOURHOOK>",
59 "format": "json",
60 "webhookstatus": {
61 "text": "Status: {status}"
62 }
63 },
64```
65
66The 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.
67
68Different 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.
69
70### Webhookbuy
71
72The fields in `webhook.webhookbuy` are filled when the bot executes a buy. Parameters are filled using string.format.
73Possible parameters are:
74
75* `trade_id`
76* `exchange`
77* `pair`
78* `limit`
79* `amount`
80* `open_date`
81* `stake_amount`
82* `stake_currency`
83* `fiat_currency`
84* `order_type`
85* `current_rate`
86
87### Webhookbuycancel
88
89The fields in `webhook.webhookbuycancel` are filled when the bot cancels a buy order. Parameters are filled using string.format.
90Possible parameters are:
91
92* `trade_id`
93* `exchange`
94* `pair`
95* `limit`
96* `amount`
97* `open_date`
98* `stake_amount`
99* `stake_currency`
100* `fiat_currency`
101* `order_type`
102* `current_rate`
103
104### Webhookbuyfill
105
106The fields in `webhook.webhookbuyfill` are filled when the bot filled a buy order. Parameters are filled using string.format.
107Possible parameters are:
108
109* `trade_id`
110* `exchange`
111* `pair`
112* `open_rate`
113* `amount`
114* `open_date`
115* `stake_amount`
116* `stake_currency`
117* `fiat_currency`
118
119### Webhooksell
120
121The fields in `webhook.webhooksell` are filled when the bot sells a trade. Parameters are filled using string.format.
122Possible parameters are:
123
124* `trade_id`
125* `exchange`
126* `pair`
127* `gain`
128* `limit`
129* `amount`
130* `open_rate`
131* `profit_amount`
132* `profit_ratio`
133* `stake_currency`
134* `fiat_currency`
135* `sell_reason`
136* `order_type`
137* `open_date`
138* `close_date`
139
140### Webhooksellfill
141
142The fields in `webhook.webhooksellfill` are filled when the bot fills a sell order (closes a Trae). Parameters are filled using string.format.
143Possible parameters are:
144
145* `trade_id`
146* `exchange`
147* `pair`
148* `gain`
149* `close_rate`
150* `amount`
151* `open_rate`
152* `current_rate`
153* `profit_amount`
154* `profit_ratio`
155* `stake_currency`
156* `fiat_currency`
157* `sell_reason`
158* `order_type`
159* `open_date`
160* `close_date`
161
162### Webhooksellcancel
163
164The fields in `webhook.webhooksellcancel` are filled when the bot cancels a sell order. Parameters are filled using string.format.
165Possible parameters are:
166
167* `trade_id`
168* `exchange`
169* `pair`
170* `gain`
171* `limit`
172* `amount`
173* `open_rate`
174* `current_rate`
175* `profit_amount`
176* `profit_ratio`
177* `stake_currency`
178* `fiat_currency`
179* `sell_reason`
180* `order_type`
181* `open_date`
182* `close_date`
183
184### Webhookstatus
185
186The fields in `webhook.webhookstatus` are used for regular status messages (Started / Stopped / ...). Parameters are filled using string.format.
187
188The only possible value here is `{status}`.