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
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
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
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
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
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
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
- Paste an alert into the alert tester to see how Nyria reads it.
- Write a TradingView message with the alert builder.
- Step by step for one account: how to automate Webhook to Alpaca.
- Step by step for one account: how to automate Webhook to Schwab.
- Step by step for one account: how to automate Webhook to Nyria Paper.
Guides
TradingView webhook not working: a checklist
Six checks, most common first: script type, the URL box, expiry, the message, the bot, and where the reason is logged.
Send alerts from your Python script to your broker
The webhook URL, the documented fields, a minimal requests sender, the response and the Logs tab, paper first.
What is a webhook in trading?
A URL a program posts to when something happens: a TradingView example, what the message needs, a 200 versus a fill, and why the URL is secret.
Test the strategy on a paper bot first
Paper is free. Live trading from $15 a month.