Skip to main content

Webhooks and alerts

Any system that can send an HTTP POST can drive Quanify: TradingView alerts, a Python script, or your own server. There is no glue code to write.

Your webhook URL

Creating a strategy gives it a unique URL. Open Webhook Setup on the strategy to copy it. It looks like this:

https://trade.quanify.pro/api/webhooks/<your-token>

The token in that URL is the credential. Anyone holding it can send signals to that strategy, so treat it like a password: do not paste it into a public chart, a screenshot or a shared repository. If you want a second factor, set a webhook password on the strategy and include it in the alert body.

The alert message

Send JSON. The Webhook Setup panel builds the exact message for you, already matching the strategy's settings: if you set a fixed contract size it hard-codes that number, and if you set a webhook password it includes it. Copy it and paste it into your alert.

{
  "action": "{{strategy.order.action}}",
  "ticker": "{{ticker}}",
  "contracts": "{{strategy.order.contracts}}",
  "price": "{{strategy.order.price}}",
  "market_position": "{{strategy.market_position}}",
  "time": "{{timenow}}"
}

The double-brace values are TradingView placeholders; TradingView fills them in when the alert fires. If you are sending from your own code, put real values there instead.

FieldWhat it does
actionbuy or sell. Required.
tickerThe instrument. Required. Resolved to the tradeable contract for you, so you do not have to track front-month rollover.
market_positionlong, short or flat: the position the strategy holds after this order. Required, and it must agree with the action (a long is reached by a buy). This is what lets a flip be told apart from a scale-in.
contractsThe order size, before per-account multipliers are applied. A whole number greater than zero. Required unless market_position is flat. Ignored if the strategy has a fixed contract size set.
priceThe price the alert was generated at. Optional. Passed through and used for the recorded signal, so a strategy can build a record even without a broker attached.
timeWhen TradingView fired the alert. Optional; use {{timenow}}. The engine logs how long the alert took to arrive, so a late entry can be traced to delivery or to the broker. Leaving it out changes nothing else.
passwordOnly needed if you set a webhook password on the strategy.

Two aliases are accepted for systems that already emit them: symbol for ticker and qty for contracts. An optional market_position_size (TradingView's {{strategy.market_position_size}}) tells the engine the exact size the strategy expects to hold afterwards; when it is present the order is simply the difference from what the account holds, which makes partial exits and flips exact. Extra fields are ignored, and the receiver does not care what content type you send, which is why a TradingView alert works unmodified.

Setting the alert up in TradingView

  1. Create an alert on your strategy.
  2. Under notifications, enable the webhook and paste the URL from Webhook Setup.
  3. Paste the JSON from Webhook Setup into the alert's message box.
  4. Save. Fire a test alert and watch Home's Trade Status.

What happens next

  1. The token, and the password if one is set, are checked. The strategy must be powered on.
  2. The payload is validated. A malformed one is refused with the reason in the response body.
  3. An identical signal arriving again within two seconds is treated as a duplicate delivery and not routed twice.
  4. The engine works out which sub-accounts that strategy is routed to and what size each one takes, applying the fixed contract size if there is one and then the per-account multiplier.
  5. Per-account checks run: is the account powered on, is the trader armed, is the account muted, would this grow a position while 2+ entries is off, is a reversal safe while another order is still in flight.
  6. Surviving orders go to the broker as market orders. The signal is recorded for the strategy's forward record either way.

Reading the response

The response is JSON: ok, queued, skipped, dropped and eligible_accounts.

  • ok with eligible_accounts 0 means the signal was accepted and recorded but no enabled, linked account was there to take it: every trader for that strategy is powered off, or every account is muted. The body says so. This is deliberate: returning an error there made TradingView mark the alert as failed and eventually throttle it, which costs you real signals later.
  • 403 strategy disabled: the strategy itself is powered off. Power it on in the Strategy Library.
  • 4xx with a reason: bad token or password, a missing field, an action that does not match the position, a non-integer size.
  • 429: the per-strategy rate limit or daily signal cap was hit.
  • 503: the engine could not take the order for any eligible account. Worth a retry.

Whether an order actually filled is a question for Home, where the position appears within seconds of the broker's confirmation, and for the fill alerts if you have them on.

Keeping the token safe

  • Set a webhook password on any strategy that trades a funded account.
  • Use a separate strategy, and therefore a separate token, per signal source. Deleting one then does not disturb the others.
  • If you think a token has leaked, delete the strategy and create a new one. The new one gets a new token, and you re-point the alert at it.