Update webhook configuration
This commit is contained in:
parent
6d9218cb34
commit
6a0110aa3c
@ -152,8 +152,8 @@ Mandatory parameters are marked as **Required**, which means that they are requi
|
|||||||
| `webhook.url` | URL for the webhook. Only required if `webhook.enabled` is `true`. See the [webhook documentation](webhook-config.md) for more details. <br> **Datatype:** String
|
| `webhook.url` | URL for the webhook. Only required if `webhook.enabled` is `true`. See the [webhook documentation](webhook-config.md) for more details. <br> **Datatype:** String
|
||||||
| `webhook.webhookbuy` | Payload to send on buy. Only required if `webhook.enabled` is `true`. See the [webhook documentation](webhook-config.md) for more details. <br> **Datatype:** String
|
| `webhook.webhookbuy` | Payload to send on buy. Only required if `webhook.enabled` is `true`. See the [webhook documentation](webhook-config.md) for more details. <br> **Datatype:** String
|
||||||
| `webhook.webhookbuycancel` | Payload to send on buy order cancel. Only required if `webhook.enabled` is `true`. See the [webhook documentation](webhook-config.md) for more details. <br> **Datatype:** String
|
| `webhook.webhookbuycancel` | Payload to send on buy order cancel. Only required if `webhook.enabled` is `true`. See the [webhook documentation](webhook-config.md) for more details. <br> **Datatype:** String
|
||||||
| `webhook.webhooksell` | Payload to send on sell. Only required if `webhook.enabled` is `true`. See the [webhook documentation](webhook-config.md) for more details. <br> **Datatype:** String
|
| `webhook.webhookexit` | Payload to send on exit. Only required if `webhook.enabled` is `true`. See the [webhook documentation](webhook-config.md) for more details. <br> **Datatype:** String
|
||||||
| `webhook.webhooksellcancel` | Payload to send on sell order cancel. Only required if `webhook.enabled` is `true`. See the [webhook documentation](webhook-config.md) for more details. <br> **Datatype:** String
|
| `webhook.webhookexitcancel` | Payload to send on exit order cancel. Only required if `webhook.enabled` is `true`. See the [webhook documentation](webhook-config.md) for more details. <br> **Datatype:** String
|
||||||
| `webhook.webhookstatus` | Payload to send on status calls. Only required if `webhook.enabled` is `true`. See the [webhook documentation](webhook-config.md) for more details. <br> **Datatype:** String
|
| `webhook.webhookstatus` | Payload to send on status calls. Only required if `webhook.enabled` is `true`. See the [webhook documentation](webhook-config.md) for more details. <br> **Datatype:** String
|
||||||
| `api_server.enabled` | Enable usage of API Server. See the [API Server documentation](rest-api.md) for more details. <br> **Datatype:** Boolean
|
| `api_server.enabled` | Enable usage of API Server. See the [API Server documentation](rest-api.md) for more details. <br> **Datatype:** Boolean
|
||||||
| `api_server.listen_ip_address` | Bind IP address. See the [API Server documentation](rest-api.md) for more details. <br> **Datatype:** IPv4
|
| `api_server.listen_ip_address` | Bind IP address. See the [API Server documentation](rest-api.md) for more details. <br> **Datatype:** IPv4
|
||||||
|
@ -57,7 +57,14 @@ While we may drop support for the current interface sometime in the future, we w
|
|||||||
|
|
||||||
Please follow the [Strategy migration](strategy_migration.md) guide to migrate your strategy to the new format to start using the new functionalities.
|
Please follow the [Strategy migration](strategy_migration.md) guide to migrate your strategy to the new format to start using the new functionalities.
|
||||||
|
|
||||||
### webhooks - `buy_tag` has been renamed to `enter_tag`
|
### webhooks - changes with 2022.4
|
||||||
|
|
||||||
|
#### `buy_tag` has been renamed to `enter_tag`
|
||||||
|
|
||||||
This should apply only to your strategy and potentially to webhooks.
|
This should apply only to your strategy and potentially to webhooks.
|
||||||
We will keep a compatibility layer for 1-2 versions (so both `buy_tag` and `enter_tag` will still work), but support for this in webhooks will disappear after that.
|
We will keep a compatibility layer for 1-2 versions (so both `buy_tag` and `enter_tag` will still work), but support for this in webhooks will disappear after that.
|
||||||
|
|
||||||
|
#### Naming changes
|
||||||
|
|
||||||
|
All "sell" occurances in webhook context have been replaced with "exit" configurations.
|
||||||
|
As a result `webhooksell` became `webhookexit`, `webhooksellfill` became `webhookexitfill` and `webhooksellcancel` became `webhookexitcancel`
|
||||||
|
@ -41,6 +41,18 @@ You can use the quick summary as checklist. Please refer to the detailed section
|
|||||||
* `order_time_in_force` buy -> entry, sell -> exit.
|
* `order_time_in_force` buy -> entry, sell -> exit.
|
||||||
* `order_types` buy -> entry, sell -> exit.
|
* `order_types` buy -> entry, sell -> exit.
|
||||||
* `unfilledtimeout` buy -> entry, sell -> exit.
|
* `unfilledtimeout` buy -> entry, sell -> exit.
|
||||||
|
* Terminology changes
|
||||||
|
* Sell reasons changed to reflect the new naming of "exit" instead of sells. Be careful in your strategy if you're using `exit_reason` checks.
|
||||||
|
* `sell_signal` -> `exit_signal`
|
||||||
|
* `custom_sell` -> `custom_exit`
|
||||||
|
* `force_sell` -> `force_exit`
|
||||||
|
* `emergency_sell` -> `emergency_exit`
|
||||||
|
* Webhook terminology changed from "sell" to "exit".
|
||||||
|
* `webhooksell` -> `webhookexit`
|
||||||
|
* `webhooksellfill` -> `webhookexitfill`
|
||||||
|
* `webhooksellcancel` -> `webhookexitcancel`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Extensive explanation
|
## Extensive explanation
|
||||||
|
|
||||||
|
@ -25,18 +25,18 @@ Sample configuration (tested using IFTTT).
|
|||||||
"value2": "at {open_rate:8f}",
|
"value2": "at {open_rate:8f}",
|
||||||
"value3": ""
|
"value3": ""
|
||||||
},
|
},
|
||||||
"webhooksell": {
|
"webhookexit": {
|
||||||
"value1": "Selling {pair}",
|
"value1": "Exiting {pair}",
|
||||||
"value2": "limit {limit:8f}",
|
"value2": "limit {limit:8f}",
|
||||||
"value3": "profit: {profit_amount:8f} {stake_currency} ({profit_ratio})"
|
"value3": "profit: {profit_amount:8f} {stake_currency} ({profit_ratio})"
|
||||||
},
|
},
|
||||||
"webhooksellcancel": {
|
"webhookexitcancel": {
|
||||||
"value1": "Cancelling Open Sell Order for {pair}",
|
"value1": "Cancelling Open Exit Order for {pair}",
|
||||||
"value2": "limit {limit:8f}",
|
"value2": "limit {limit:8f}",
|
||||||
"value3": "profit: {profit_amount:8f} {stake_currency} ({profit_ratio})"
|
"value3": "profit: {profit_amount:8f} {stake_currency} ({profit_ratio})"
|
||||||
},
|
},
|
||||||
"webhooksellfill": {
|
"webhookexitfill": {
|
||||||
"value1": "Sell Order for {pair} filled",
|
"value1": "Exit Order for {pair} filled",
|
||||||
"value2": "at {close_rate:8f}.",
|
"value2": "at {close_rate:8f}.",
|
||||||
"value3": ""
|
"value3": ""
|
||||||
},
|
},
|
||||||
@ -160,8 +160,9 @@ Possible parameters are:
|
|||||||
* `current_rate`
|
* `current_rate`
|
||||||
* `enter_tag`
|
* `enter_tag`
|
||||||
|
|
||||||
### Webhooksell
|
### Webhookexit
|
||||||
The fields in `webhook.webhooksell` are filled when the bot sells a trade. Parameters are filled using string.format.
|
|
||||||
|
The fields in `webhook.webhookexit` are filled when the bot exits a trade. Parameters are filled using string.format.
|
||||||
Possible parameters are:
|
Possible parameters are:
|
||||||
|
|
||||||
* `trade_id`
|
* `trade_id`
|
||||||
@ -183,9 +184,9 @@ Possible parameters are:
|
|||||||
* `open_date`
|
* `open_date`
|
||||||
* `close_date`
|
* `close_date`
|
||||||
|
|
||||||
### Webhooksellfill
|
### Webhookexitfill
|
||||||
|
|
||||||
The fields in `webhook.webhooksellfill` are filled when the bot fills a sell order (closes a Trae). Parameters are filled using string.format.
|
The fields in `webhook.webhookexitfill` are filled when the bot fills a exit order (closes a Trade). Parameters are filled using string.format.
|
||||||
Possible parameters are:
|
Possible parameters are:
|
||||||
|
|
||||||
* `trade_id`
|
* `trade_id`
|
||||||
@ -208,9 +209,9 @@ Possible parameters are:
|
|||||||
* `open_date`
|
* `open_date`
|
||||||
* `close_date`
|
* `close_date`
|
||||||
|
|
||||||
### Webhooksellcancel
|
### Webhookexitcancel
|
||||||
|
|
||||||
The fields in `webhook.webhooksellcancel` are filled when the bot cancels a sell order. Parameters are filled using string.format.
|
The fields in `webhook.webhookexitcancel` are filled when the bot cancels a exit order. Parameters are filled using string.format.
|
||||||
Possible parameters are:
|
Possible parameters are:
|
||||||
|
|
||||||
* `trade_id`
|
* `trade_id`
|
||||||
|
@ -330,9 +330,9 @@ CONF_SCHEMA = {
|
|||||||
'webhookbuy': {'type': 'object'},
|
'webhookbuy': {'type': 'object'},
|
||||||
'webhookbuycancel': {'type': 'object'},
|
'webhookbuycancel': {'type': 'object'},
|
||||||
'webhookbuyfill': {'type': 'object'},
|
'webhookbuyfill': {'type': 'object'},
|
||||||
'webhooksell': {'type': 'object'},
|
'webhookexit': {'type': 'object'},
|
||||||
'webhooksellcancel': {'type': 'object'},
|
'webhookexitcancel': {'type': 'object'},
|
||||||
'webhooksellfill': {'type': 'object'},
|
'webhookexitfill': {'type': 'object'},
|
||||||
'webhookstatus': {'type': 'object'},
|
'webhookstatus': {'type': 'object'},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -14,8 +14,6 @@ class RPCMessageType(Enum):
|
|||||||
SHORT_FILL = 'short_fill'
|
SHORT_FILL = 'short_fill'
|
||||||
SHORT_CANCEL = 'short_cancel'
|
SHORT_CANCEL = 'short_cancel'
|
||||||
|
|
||||||
# TODO: The below messagetypes should be renamed to "exit"!
|
|
||||||
# Careful - has an impact on webhooks, therefore needs proper communication
|
|
||||||
SELL = 'sell'
|
SELL = 'sell'
|
||||||
SELL_FILL = 'sell_fill'
|
SELL_FILL = 'sell_fill'
|
||||||
SELL_CANCEL = 'sell_cancel'
|
SELL_CANCEL = 'sell_cancel'
|
||||||
|
@ -43,23 +43,25 @@ class Webhook(RPCHandler):
|
|||||||
def send_msg(self, msg: Dict[str, Any]) -> None:
|
def send_msg(self, msg: Dict[str, Any]) -> None:
|
||||||
""" Send a message to telegram channel """
|
""" Send a message to telegram channel """
|
||||||
try:
|
try:
|
||||||
|
whconfig = self._config['webhook']
|
||||||
|
# DEPRECATED: Sell terminology
|
||||||
if msg['type'] in [RPCMessageType.BUY, RPCMessageType.SHORT]:
|
if msg['type'] in [RPCMessageType.BUY, RPCMessageType.SHORT]:
|
||||||
valuedict = self._config['webhook'].get('webhookbuy', None)
|
valuedict = whconfig.get('webhookbuy', None)
|
||||||
elif msg['type'] in [RPCMessageType.BUY_CANCEL, RPCMessageType.SHORT_CANCEL]:
|
elif msg['type'] in [RPCMessageType.BUY_CANCEL, RPCMessageType.SHORT_CANCEL]:
|
||||||
valuedict = self._config['webhook'].get('webhookbuycancel', None)
|
valuedict = whconfig.get('webhookbuycancel', None)
|
||||||
elif msg['type'] in [RPCMessageType.BUY_FILL, RPCMessageType.SHORT_FILL]:
|
elif msg['type'] in [RPCMessageType.BUY_FILL, RPCMessageType.SHORT_FILL]:
|
||||||
valuedict = self._config['webhook'].get('webhookbuyfill', None)
|
valuedict = whconfig.get('webhookbuyfill', None)
|
||||||
elif msg['type'] == RPCMessageType.SELL:
|
elif msg['type'] == RPCMessageType.SELL:
|
||||||
valuedict = self._config['webhook'].get('webhooksell', None)
|
valuedict = whconfig.get('webhookexit', whconfig.get('webhooksell', None))
|
||||||
elif msg['type'] == RPCMessageType.SELL_FILL:
|
elif msg['type'] == RPCMessageType.SELL_FILL:
|
||||||
valuedict = self._config['webhook'].get('webhooksellfill', None)
|
valuedict = whconfig.get('webhookexitfill', whconfig.get('webhookexitfill', None))
|
||||||
elif msg['type'] == RPCMessageType.SELL_CANCEL:
|
elif msg['type'] == RPCMessageType.SELL_CANCEL:
|
||||||
valuedict = self._config['webhook'].get('webhooksellcancel', None)
|
valuedict = whconfig.get('webhookexitcancel',
|
||||||
|
whconfig.get('webhooksellcancel', None))
|
||||||
elif msg['type'] in (RPCMessageType.STATUS,
|
elif msg['type'] in (RPCMessageType.STATUS,
|
||||||
RPCMessageType.STARTUP,
|
RPCMessageType.STARTUP,
|
||||||
RPCMessageType.WARNING):
|
RPCMessageType.WARNING):
|
||||||
valuedict = self._config['webhook'].get('webhookstatus', None)
|
valuedict = whconfig.get('webhookstatus', None)
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError('Unknown message type: {}'.format(msg['type']))
|
raise NotImplementedError('Unknown message type: {}'.format(msg['type']))
|
||||||
if not valuedict:
|
if not valuedict:
|
||||||
|
@ -36,17 +36,17 @@ def get_webhook_dict() -> dict:
|
|||||||
"value4": "leverage {leverage:.1f}",
|
"value4": "leverage {leverage:.1f}",
|
||||||
"value5": "direction {direction}"
|
"value5": "direction {direction}"
|
||||||
},
|
},
|
||||||
"webhooksell": {
|
"webhookexit": {
|
||||||
"value1": "Selling {pair}",
|
"value1": "Selling {pair}",
|
||||||
"value2": "limit {limit:8f}",
|
"value2": "limit {limit:8f}",
|
||||||
"value3": "profit: {profit_amount:8f} {stake_currency} ({profit_ratio})"
|
"value3": "profit: {profit_amount:8f} {stake_currency} ({profit_ratio})"
|
||||||
},
|
},
|
||||||
"webhooksellcancel": {
|
"webhookexitcancel": {
|
||||||
"value1": "Cancelling Open Sell Order for {pair}",
|
"value1": "Cancelling Open Sell Order for {pair}",
|
||||||
"value2": "limit {limit:8f}",
|
"value2": "limit {limit:8f}",
|
||||||
"value3": "profit: {profit_amount:8f} {stake_currency} ({profit_ratio})"
|
"value3": "profit: {profit_amount:8f} {stake_currency} ({profit_ratio})"
|
||||||
},
|
},
|
||||||
"webhooksellfill": {
|
"webhookexitfill": {
|
||||||
"value1": "Sell Order for {pair} filled",
|
"value1": "Sell Order for {pair} filled",
|
||||||
"value2": "at {close_rate:8f}",
|
"value2": "at {close_rate:8f}",
|
||||||
"value3": ""
|
"value3": ""
|
||||||
@ -249,11 +249,11 @@ def test_send_msg_webhook(default_conf, mocker):
|
|||||||
webhook.send_msg(msg=msg)
|
webhook.send_msg(msg=msg)
|
||||||
assert msg_mock.call_count == 1
|
assert msg_mock.call_count == 1
|
||||||
assert (msg_mock.call_args[0][0]["value1"] ==
|
assert (msg_mock.call_args[0][0]["value1"] ==
|
||||||
default_conf["webhook"]["webhooksell"]["value1"].format(**msg))
|
default_conf["webhook"]["webhookexit"]["value1"].format(**msg))
|
||||||
assert (msg_mock.call_args[0][0]["value2"] ==
|
assert (msg_mock.call_args[0][0]["value2"] ==
|
||||||
default_conf["webhook"]["webhooksell"]["value2"].format(**msg))
|
default_conf["webhook"]["webhookexit"]["value2"].format(**msg))
|
||||||
assert (msg_mock.call_args[0][0]["value3"] ==
|
assert (msg_mock.call_args[0][0]["value3"] ==
|
||||||
default_conf["webhook"]["webhooksell"]["value3"].format(**msg))
|
default_conf["webhook"]["webhookexit"]["value3"].format(**msg))
|
||||||
# Test sell cancel
|
# Test sell cancel
|
||||||
msg_mock.reset_mock()
|
msg_mock.reset_mock()
|
||||||
msg = {
|
msg = {
|
||||||
@ -299,11 +299,11 @@ def test_send_msg_webhook(default_conf, mocker):
|
|||||||
webhook.send_msg(msg=msg)
|
webhook.send_msg(msg=msg)
|
||||||
assert msg_mock.call_count == 1
|
assert msg_mock.call_count == 1
|
||||||
assert (msg_mock.call_args[0][0]["value1"] ==
|
assert (msg_mock.call_args[0][0]["value1"] ==
|
||||||
default_conf["webhook"]["webhooksellfill"]["value1"].format(**msg))
|
default_conf["webhook"]["webhookexitfill"]["value1"].format(**msg))
|
||||||
assert (msg_mock.call_args[0][0]["value2"] ==
|
assert (msg_mock.call_args[0][0]["value2"] ==
|
||||||
default_conf["webhook"]["webhooksellfill"]["value2"].format(**msg))
|
default_conf["webhook"]["webhookexitfill"]["value2"].format(**msg))
|
||||||
assert (msg_mock.call_args[0][0]["value3"] ==
|
assert (msg_mock.call_args[0][0]["value3"] ==
|
||||||
default_conf["webhook"]["webhooksellfill"]["value3"].format(**msg))
|
default_conf["webhook"]["webhookexitfill"]["value3"].format(**msg))
|
||||||
|
|
||||||
for msgtype in [RPCMessageType.STATUS,
|
for msgtype in [RPCMessageType.STATUS,
|
||||||
RPCMessageType.WARNING,
|
RPCMessageType.WARNING,
|
||||||
|
Loading…
Reference in New Issue
Block a user