Webhooks

Webhooks make it easy for algorithmic traders to integrate notifications into their automated trading systems. Rather than receiving an alert via SMS or email, TrendSpider can be configured to send an HTTP POST request to any URL.

Webhooks for Alerts (Dynamic and Multi-Factor)

It’s easy to get started using web hooks:

  1. Click on the User Icon in the upper-right corner of the screen.
  2. Select Account & Settings.
  3. Check the Webhook box under Email and SMS.
  4. Input the URL where POST requests should be sent.

Webhook option

Webhooks send a POST request with a body equal to each alert’s description. If the description contains valid JSON, the content-type header is set to "application/json", otherwise it’s set to "text/plain". The Alert dialog will display “valid JSON” below the description field if the field contains valid JSON.

Add alert name

The Webhook supports the following variables in descriptions:

  • %alert_name% returns the name of the alert.
  • %alert_symbol% returns the symbol.
  • %alert_note% returns the notes for the alert.
  • %price_action_event% returns one of: touch, break_through, bounce, script_returned_true.
  • %last_price% returns the price of an asset for the moment when the alert has fired.

An example POST request might look like this:

HTTP POST https://webhook.site/1902dc91-ffdb-4322-9c65-5df94cec5f34?symbol=AAPL
Content-Type: application/json
X-requester: trendspider
X-reason: alert-webhook

{"event":"alert_triggered","which":"Alert Name","other_param":42}

The requests timeout after five seconds. All Webhooks are sent from a specific host with the IP address 3.12.143.24, which can be whitelisted to maximize reliability.

Example: Deliver Alert Triggers to Discord

In your Notification settings on TrendSpider, paste the URL of the webhook (the one which Discord gives you, it usually looks like "https://discord.com/api/webhooks/111....10/9Na....e87a" — these lengthy parts would be different, but the overall look would be similar).

According to Discord's documentation, they need your webhook receiving something like {"content": "Look ma, my webhook just worked"}. Paste that into your alert's "Description" or "Your Note" input on TrendSpider.

Wait for your alert to fire and confirm that you've got a message delivered to your Discord.

After that, you can customize your alert message suing variables listed above. E.g., {"content": "Alert triggered: %alert_name% on %alert_symbol%, %price_action_event%"}

Webhooks for Trading Bots

Unlike Alerts, every Trading Bot can have its very own set of webhooks (both URL and Body). Here's a list of variables supported in Trading Bots Webhooks.

  • %bot_name% returns name of the Trading Bot.
  • %bot_symbol% returns the symbol.
  • %bot_timeframe% returns human-friendly time frame of your Trading Bot (i.e., "15 min" or "Daily").
  • %bot_status% returns an up-to-date status of the bot; one of: in_position, not_in_position.
  • %last_price% returns the price of an asset for the moment when the Trading Bot has fired.

Example: Deliver Trading Bot Triggers to Discord

In your Edit Trading Bot dialog, paste the URL of the webhook (the one which Discord gives you into the Entry or Exit webhook URLs (or both). This URL usually looks like "https://discord.com/api/webhooks/111....10/9Na....e87a" — these lengthy parts would be different, but the overall look would be similar).

According to Discord's documentation, they need your webhook receiving something like {"content": "Now I'm an algo trader"}. Paste that into your Trading Bot's Webhook Body in the Edit Trading Bot dialog.

Wait for your Trading Bot to fire and confirm that you've got a message delivered to your Discord. After that, you can customize your alert message suing variables listed above. E.g., {"content": "Bot %bot_name% on %bot_symbol%, %bot_timeframe%: signal triggered, now %bot_status%"}

Sep 26, 2024

Contact Us

Not finding what you're looking for? Contact Us Directly