mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
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.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.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.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.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.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
|
||||
| `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
|
||||
|
|
|
@ -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.
|
||||
|
||||
### 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.
|
||||
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_types` 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
|
||||
|
||||
|
|
|
@ -25,18 +25,18 @@ Sample configuration (tested using IFTTT).
|
|||
"value2": "at {open_rate:8f}",
|
||||
"value3": ""
|
||||
},
|
||||
"webhooksell": {
|
||||
"value1": "Selling {pair}",
|
||||
"webhookexit": {
|
||||
"value1": "Exiting {pair}",
|
||||
"value2": "limit {limit:8f}",
|
||||
"value3": "profit: {profit_amount:8f} {stake_currency} ({profit_ratio})"
|
||||
},
|
||||
"webhooksellcancel": {
|
||||
"value1": "Cancelling Open Sell Order for {pair}",
|
||||
"webhookexitcancel": {
|
||||
"value1": "Cancelling Open Exit Order for {pair}",
|
||||
"value2": "limit {limit:8f}",
|
||||
"value3": "profit: {profit_amount:8f} {stake_currency} ({profit_ratio})"
|
||||
},
|
||||
"webhooksellfill": {
|
||||
"value1": "Sell Order for {pair} filled",
|
||||
"webhookexitfill": {
|
||||
"value1": "Exit Order for {pair} filled",
|
||||
"value2": "at {close_rate:8f}.",
|
||||
"value3": ""
|
||||
},
|
||||
|
@ -160,8 +160,9 @@ Possible parameters are:
|
|||
* `current_rate`
|
||||
* `enter_tag`
|
||||
|
||||
### Webhooksell
|
||||
The fields in `webhook.webhooksell` are filled when the bot sells a trade. Parameters are filled using string.format.
|
||||
### Webhookexit
|
||||
|
||||
The fields in `webhook.webhookexit` are filled when the bot exits a trade. Parameters are filled using string.format.
|
||||
Possible parameters are:
|
||||
|
||||
* `trade_id`
|
||||
|
@ -183,9 +184,9 @@ Possible parameters are:
|
|||
* `open_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:
|
||||
|
||||
* `trade_id`
|
||||
|
@ -208,9 +209,9 @@ Possible parameters are:
|
|||
* `open_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:
|
||||
|
||||
* `trade_id`
|
||||
|
|
|
@ -330,9 +330,9 @@ CONF_SCHEMA = {
|
|||
'webhookbuy': {'type': 'object'},
|
||||
'webhookbuycancel': {'type': 'object'},
|
||||
'webhookbuyfill': {'type': 'object'},
|
||||
'webhooksell': {'type': 'object'},
|
||||
'webhooksellcancel': {'type': 'object'},
|
||||
'webhooksellfill': {'type': 'object'},
|
||||
'webhookexit': {'type': 'object'},
|
||||
'webhookexitcancel': {'type': 'object'},
|
||||
'webhookexitfill': {'type': 'object'},
|
||||
'webhookstatus': {'type': 'object'},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -14,8 +14,6 @@ class RPCMessageType(Enum):
|
|||
SHORT_FILL = 'short_fill'
|
||||
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_FILL = 'sell_fill'
|
||||
SELL_CANCEL = 'sell_cancel'
|
||||
|
|
|
@ -43,23 +43,25 @@ class Webhook(RPCHandler):
|
|||
def send_msg(self, msg: Dict[str, Any]) -> None:
|
||||
""" Send a message to telegram channel """
|
||||
try:
|
||||
|
||||
whconfig = self._config['webhook']
|
||||
# DEPRECATED: Sell terminology
|
||||
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]:
|
||||
valuedict = self._config['webhook'].get('webhookbuycancel', None)
|
||||
valuedict = whconfig.get('webhookbuycancel', None)
|
||||
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:
|
||||
valuedict = self._config['webhook'].get('webhooksell', None)
|
||||
valuedict = whconfig.get('webhookexit', whconfig.get('webhooksell', None))
|
||||
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:
|
||||
valuedict = self._config['webhook'].get('webhooksellcancel', None)
|
||||
valuedict = whconfig.get('webhookexitcancel',
|
||||
whconfig.get('webhooksellcancel', None))
|
||||
elif msg['type'] in (RPCMessageType.STATUS,
|
||||
RPCMessageType.STARTUP,
|
||||
RPCMessageType.WARNING):
|
||||
valuedict = self._config['webhook'].get('webhookstatus', None)
|
||||
valuedict = whconfig.get('webhookstatus', None)
|
||||
else:
|
||||
raise NotImplementedError('Unknown message type: {}'.format(msg['type']))
|
||||
if not valuedict:
|
||||
|
|
|
@ -36,17 +36,17 @@ def get_webhook_dict() -> dict:
|
|||
"value4": "leverage {leverage:.1f}",
|
||||
"value5": "direction {direction}"
|
||||
},
|
||||
"webhooksell": {
|
||||
"webhookexit": {
|
||||
"value1": "Selling {pair}",
|
||||
"value2": "limit {limit:8f}",
|
||||
"value3": "profit: {profit_amount:8f} {stake_currency} ({profit_ratio})"
|
||||
},
|
||||
"webhooksellcancel": {
|
||||
"webhookexitcancel": {
|
||||
"value1": "Cancelling Open Sell Order for {pair}",
|
||||
"value2": "limit {limit:8f}",
|
||||
"value3": "profit: {profit_amount:8f} {stake_currency} ({profit_ratio})"
|
||||
},
|
||||
"webhooksellfill": {
|
||||
"webhookexitfill": {
|
||||
"value1": "Sell Order for {pair} filled",
|
||||
"value2": "at {close_rate:8f}",
|
||||
"value3": ""
|
||||
|
@ -249,11 +249,11 @@ def test_send_msg_webhook(default_conf, mocker):
|
|||
webhook.send_msg(msg=msg)
|
||||
assert msg_mock.call_count == 1
|
||||
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"] ==
|
||||
default_conf["webhook"]["webhooksell"]["value2"].format(**msg))
|
||||
default_conf["webhook"]["webhookexit"]["value2"].format(**msg))
|
||||
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
|
||||
msg_mock.reset_mock()
|
||||
msg = {
|
||||
|
@ -299,11 +299,11 @@ def test_send_msg_webhook(default_conf, mocker):
|
|||
webhook.send_msg(msg=msg)
|
||||
assert msg_mock.call_count == 1
|
||||
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"] ==
|
||||
default_conf["webhook"]["webhooksellfill"]["value2"].format(**msg))
|
||||
default_conf["webhook"]["webhookexitfill"]["value2"].format(**msg))
|
||||
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,
|
||||
RPCMessageType.WARNING,
|
||||
|
|
Loading…
Reference in New Issue
Block a user