This article will guide you through using webhooks to operate Gainium bots, including a special focus on concatenating webhook actions on the same alert by sending an array in the webhook payload.
Webhooks are automated messages sent from apps when something happens. They have a message—or payload—and are sent to a unique URL. They're a simple way your online accounts can communicate and get automated messages when something new happens.
Before diving into webhooks, it's essential to understand the various bots Gainium offers, such as grid, DCA, and combo bots. Each bot has unique triggers and actions that can be automated.
To start, create a new bot. There are several places where the bot can accept webhooks, those include:
Depending on where do you enable webhooks, you will have access to certain actions to be automated through them. Once you are happy with the bot configuration, click on “Add new bot,” and a new info box will appear with the webhook information.
Next, head to your webhook provider, in this case we will use TradingView as an example.
On the indicator of your choosing, click on “More” (the three dots at the end of the indicator name), then “Add alert on…”.
You will be presented with the following window. Click on “Webhook URL”.
You may input the webhook URL and the message as shown in your bot info. The alert name can be anything you want. Click on Create, and that's it!
There are different types of webhook actions:
Concatenating actions means executing multiple actions in sequence based on a single alert. In the context of webhooks, this involves sending an array of actions in the webhook payload.
Structure the Payload: When setting up your webhook, structure the payload as an array of actions. Each action should be a distinct object within the array.
Example to start a deal adding funds right away:
[
{ "action": "startDeal", "uuid": "f944e169-2398-482w-4987-10a30eeb477b" },
{ "action": "addFunds", "uuid": "f944e169-2398-482w-4987-10a30eeb477b", "asset": "quote", "qty": "50" }
]
Test the Webhook: Before going live, test the webhook with the array payload to ensure all actions are executed as expected.
Features
Use Cases
Resources
Help & Support
All rights reserved. Copyright © 2024.