Skip to content

Guide

Webhook trading bot for stocks: how to set one up

A webhook trading bot for stocks is a program with a URL that waits for an alert, reads the ticker and the side, and places the order at your broker. On Nyria the URL belongs to a strategy. A TradingView alert, a TrendSpider alert or a script of your own posts to it, and a bot places the order in your Charles Schwab, Tradier, tastytrade or Alpaca account, or on Nyria Paper first. No code is needed unless the alert comes from your own script.

Official documentation

Set up the bot

  1. 1

    Create the strategy

    In Nyria, select Create strategy and pick Webhook as the alert source, or TradingView if a chart sends the alert. Choose stocks as the asset type and set what an entry and an exit do on each side.

  2. 2

    Copy the webhook URL

    Open the strategy's Integration tab and copy the URL. It is https://trades.nyria.io/webhooks/ followed by a token that belongs to the strategy. The token is the only authentication, so keep the URL private.

  3. 3

    Post an alert to it

    Paste the URL into a TradingView alert's Webhook URL box, set it as a TrendSpider webhook, or POST to it from your own script. A body with a ticker and an action is enough, such as the one below, and plain text such as AAPL long entry works too.

  4. 4

    Check what Nyria read

    Select Check format, then Check and save. The strategy turns Active once Nyria reads the ticker and the side, and the Logs tab shows what it read for every alert after that. A 200 reply means the alert arrived, not that a broker filled it.

  5. 5

    Deploy a bot on Nyria Paper

    Select Deploy bot, choose Nyria Paper and set a Budget per entry. Stocks trade in whole shares. Let real alerts fire for a week or two and read the Logs tab against what you meant.

  6. 6

    Deploy a bot on your broker

    When the paper log reads right, deploy a second bot and pick the Schwab, Tradier, tastytrade or Alpaca account on the Account step. The next alert becomes an order there.

Messages to copy

A stock entry, as JSON

{ "ticker": "NVDA", "action": "buy" }

The exit

{ "ticker": "NVDA", "action": "sell" }

What a stock webhook can and cannot do

  • The alert names the ticker, the side and whether it opens or closes. It cannot set the size: each bot sizes the order from its Budget per entry.
  • Orders are market or limit. Nyria attaches no stop or take-profit order to an entry, so a position closes when an exit alert arrives.
  • Each webhook takes 10 alerts at once, then one per second. An alert over that limit is dropped with a 429.
  • Anyone who has the URL can post to it. Select Rotate token on the Integration tab to replace it.

Which accounts it trades

  • Charles Schwab, Tradier and tastytrade connect through the broker's own sign-in. Alpaca connects with an API key.
  • Nyria Paper is built in, free on every plan and needs no broker.
  • Nyria cannot move money out of any of them.

Questions

Do I need to write code for a webhook trading bot?
No, when the alert comes from TradingView or TrendSpider. Code is only needed when your own script sends the alert, and the Python guide has a short sender.
Which brokers can a stock webhook trade at?
Charles Schwab, Tradier, tastytrade and Alpaca, plus Nyria Paper for free. Nyria does not connect to other brokers today.
Can the alert say how many shares to buy?
No. The bot sizes each order from the Budget per entry you set when you deploy it, in whole shares.
What does it cost?
Paper is free. Live trading from $15 a month.

Next

Test the strategy on a paper bot first

Paper is free. Live trading from $15 a month.