View as Markdown

Health

How Tickwire decides whether an account is working.

A running terminal isn’t necessarily a working one. A terminal can be alive while logged out, stuck on a dialog, or connected to a broker whose price feed has stopped. So Tickwire measures health from work that succeeded, using three independent signals:

  1. Broker link: the connection state the terminal itself reports.
  2. Account reads: when we last read the account successfully. That shows the broker is answering, not just that a socket is open.
  3. Price movement: whether any symbol in the terminal’s Market Watch has a new price.

The ladder

StatusMeaningWhat to do
healthyConnected, the account is readable, and prices are moving (prices_live true, or null just after start)Nothing
degradedConnected and readable, but no Market Watch price has moved for 30 s (prices_live false). reason_codes holds prices_staleThe market is likely closed, or the broker’s feed paused. Reads work; new market orders are refused with quote_stale (see below)
disconnectedTerminal up, but no broker link, or no account read in the last 60 s, or still reconciling after a restart (reconciling is true)Usually the broker. We reconnect automatically and escalate if it persists. After a restart it clears once positions and orders are read again
downWe can’t read the terminal at all, or the account isn’t runningA running account: ours to fix, and you’ll get a webhook. An account that isn’t running: reason_code says why (see below)

A health snapshot

curl -s https://api.tickwire.io/users/current/accounts/acc_7Qx/health -H "auth-token: $TW_KEY"
{
  "status": "healthy",
  "connected": true,
  "read_only": false,
  "trading_enabled": true,
  "reasons": [],
  "last_account_read_age_s": 2.1,
  "last_tick_age_s": 0.4,
  "last_action_age_s": 812.0,
  "prices_live": true,
  "last_price_at": "2026-09-23T11:02:12.6Z",
  "last_price_symbol": "EURUSD",
  "last_price_age_s": 0.4,
  "symbols_checked": 14,
  "prices_reason": null,
  "broker_time": "2026-09-23 14:02:11.480",
  "broker_utc_offset_minutes": 180,
  "checked_at": "2026-09-23T11:02:13Z",
  "reconciling": false,
  "restart_recovery": {
    "reconciled": true,
    "reconciled_at": "2026-09-23T08:15:40Z",
    "durable_idempotency": true,
    "durable_idempotency_error": null,
    "last_error": null,
    "unknown_outcomes": []
  }
}
  • The HTTP status is 200 while the account is healthy or degraded, and 503 otherwise. The body is the same either way, so you can read why. A monitor that only checks the status code sees a quiet market as 200: read status to tell degraded from healthy.
  • trading_enabled is true only if an order could be accepted right now: connected, not an investor login, and trading switched on in the terminal.
  • reasons explains any status other than healthy in plain words. reason_codes gives stable codes to branch on: prices_stale when prices are not moving.
  • reconciling is true after the terminal restarts, until positions and orders have been read again. Until then the status is disconnected and the first reason starts “reconciling after restart”. restart_recovery shows that state, and lists any order whose outcome was unknown when the restart happened.
  • restart_recovery.unknown_outcomes also lists orders whose outcome became unknown while running, for example a lost broker reply (sandbox login 1032). These entries have source: "while_running"; ones left by a restart have source: "restart". A call sent without an Idempotency-Key is listed too, with idempotency_key: null and a ref. They don’t change status. On the next connected check Tickwire reads positions and orders and adds the matching ones as evidence, with reconciled_at. An entry stays listed until it expires (24 hours), because its outcome stays unknown.
  • broker_time is the time on the broker’s clock, as YYYY-MM-DD HH:mm:ss.SSS. It has no offset. It is not UTC.
  • broker_utc_offset_minutes is how far the broker’s clock is east of UTC, in minutes. 180 means UTC+3, and a negative number means west of UTC. It is null when the offset is not known. Tickwire never guesses it.
  • The ages let you apply your own, stricter thresholds. last_tick_age_s is the age of the account’s reference symbol (EURUSD where the broker has it); last_price_age_s is the age of the newest price in the whole Market Watch.
  • A quote older than four days never counts as a live price. Some brokers serve a cached quote from years ago right after login.

When prices stop moving

The account is still connected and readable, but its status is degraded, with reason code prices_stale. It is not down, and no disconnect alert fires, because the broker link is up. A market order at a price that is not moving could fill far from what you saw, so Tickwire refuses it (below).

  • The terminal checks every symbol in its Market Watch (up to 64), not one pair. A price counts as moving when the symbol’s tick time goes forward.
  • prices_live is true when some symbol moved in the last 30 s, false when none did, and null while it can’t tell yet (just after start, or when the check failed).
  • When it is false, prices_reason says so in plain words, for example: “Connected. No price has changed in any of the 14 Market Watch symbols for 12 min. The market is likely closed, or the broker’s feed has paused.”
  • There is no calendar. Tickwire does not guess from the day or the time whether a market is open: a crypto symbol trading on a Saturday makes prices_live true, and a frozen feed on a Wednesday makes it false.
  • On /users/current/…, healthStatus carries the same fields as one object: {connected, connectedToBroker, quoteStreamingHealthy, synchronized, healthy, message, pricesLive, lastPriceAt, lastPriceSymbol, symbolsChecked}. The dashboard shows “Connected · no live prices (market likely closed)”.
  • On /users/current/…, healthStatus.healthy is false while prices are stale, and healthStatus.status is degraded with reasonCodes: ["prices_stale"]. connectedToBroker stays true.

Market orders at a stale quote

A new market order (buy or sell at market) is checked against a fresh quote for its symbol before anything is sent. It is refused when:

  • no Market Watch price has moved for 30 s (prices_live false), or
  • this symbol’s price has not changed for 5 minutes while we watched it, or
  • the symbol’s quote is days old (a cached quote, as some brokers serve after login).

The answer is HTTP 409 with sent: false. Nothing reached the broker, and the idempotency key is freed, so you can send the same request again with the same key once prices move.

{
  "error": "quote_stale",
  "message": "Connected. No price has changed in any of the 14 Market Watch symbols for 12 min. ... Nothing was sent. Retry when prices move, or set allowStaleQuote: true to send it anyway.",
  "sent": false,
  "symbol": "EURUSD",
  "staleScope": "account",
  "quietSeconds": 720.0
}

staleScope is account, symbol or cached. On /users/current/…/trade the body follows that surface’s error shape: error is ConflictError and code is quote_stale, with the same fields.

  • Why 409, not 503: the service works and the request is valid, but it conflicts with the market’s state right now. Many HTTP clients retry a 503 on their own, which could fill the order minutes later at a price nobody chose.
  • To send it anyway, add allowStaleQuote: true to the order (allow_stale_quote also works on the /mt5/{id}/… and /mt4/{id}/… routes). The broker then decides, and on a closed market it rejects the order itself.
  • Never refused for a stale quote: closing a position (full, partial, close-by, close all), pending orders (they fill later, at their own price), and changes to SL/TP or pending orders.
  • A symbol seen for the first time is never refused: there is no evidence yet.

Accounts that aren’t running

An account can exist without a terminal: its deploy failed (for example the broker asked for a one-time password), or you undeployed it. There is nothing to measure, but the answer is still known, so health says so instead of returning 404:

curl -s https://api.tickwire.io/users/current/accounts/acc_7Qx/health -H "auth-token: $TW_KEY"
{
  "status": "down",
  "connected": false,
  "read_only": null,
  "trading_enabled": false,
  "reasons": ["account is not running (state DEPLOY_FAILED)",
              "ERR_OTP_REQUIRED: the broker asks for a one-time password"],
  "last_account_read_age_s": null,
  "last_tick_age_s": null,
  "last_action_age_s": null,
  "broker_time": null,
  "checked_at": "2026-09-23T11:02:13Z",
  "fx_status": "error",
  "deployed": false,
  "state": "DEPLOY_FAILED",
  "reason_code": "ERR_OTP_REQUIRED",
  "error": "ERR_OTP_REQUIRED: the broker asks for a one-time password"
}
  • The answer is 200, not 503. The state is known, and the body says why the account isn’t running. state is the account’s lifecycle state, and reason_code the code at the start of its error (ERR_OTP_REQUIRED, E_AUTH, …), or null when the error has no code or there is none. error is the same text as health.error on the account object.
  • Anything we can’t know without a terminal, such as read_only and the ages, is null.
  • The terminal routes match: GET /mt5/{id}/status (and /mt4/…) is 200 with status: "down" plus deployed, state, reasonCode and error; /healthz and /livez are 503.
  • Agents: GET /v1/agent/accounts/{id}/health says disconnected, with state and reason_code in its evidence.
  • An account that is still deploying answers 503 account_deploying with Retry-After: it may be up in a moment. An account that doesn’t exist, isn’t yours, or isn’t covered by your key is 404 account_not_found. All three give the same answer, so account ids can’t be probed.
  • Other data and trade calls on an account that isn’t running are 409 account_not_deployed (ConflictError on /users/current/…), with the same state and reasonCode. Fix the cause and redeploy it.

How it reaches you

  • Polling: GET …/health, as above.
  • Streaming: health and brokerConnectionStatus frames on the account stream.
  • Webhooks: account.health_changed on every transition, within 60 seconds. See Webhooks.
  • /users/current/… fields: connectionStatus on the account is CONNECTED only when health is healthy and the broker link is up; otherwise DISCONNECTED_FROM_BROKER or DISCONNECTED.
  • /v1 and terminal-route fields: status maps healthy to connected, disconnected to disconnected, and down to error.

Account snapshot

GET /users/current/accounts/{id}/snapshot (agents: GET /v1/agent/accounts/{id}/snapshot) returns everything needed to rebuild your picture of an MT4 or MT5 account in one call: account information, open positions, pending orders, health and the broker’s server time.

{
  "account_id": "acc_7Qx", "platform": "mt5",
  "as_of": "2026-09-23T11:02:13.412Z", "complete": true, "terminal_connected": true,
  "account_information": { "status": "ok", "read_at": "2026-09-23T11:02:13.380Z", "age_ms": 32, "data": { "balance": 10000, "equity": 10012.5 } },
  "positions": { "status": "ok", "read_at": "…", "age_ms": 25, "data": [] },
  "orders": { "status": "ok", "read_at": "…", "age_ms": 18, "data": [] },
  "health": { "status": "ok", "read_at": "…", "age_ms": 9, "data": { "status": "healthy" } },
  "server_time": { "status": "ok", "read_at": "…", "age_ms": 2,
                   "data": { "time": "2026-09-23T11:02:13.410Z", "brokerTime": "2026-09-23 14:02:13.410", "brokerUtcOffsetMinutes": 180 } }
}
  • Each section has its own status: ok (read from a terminal connected to its broker), stale (read, but the terminal was not connected, so values may be out of date) or unavailable (the read failed; data is null and error says why). complete is true only when every section is ok.
  • read_at and age_ms show how fresh each section is. Sections are read one after another, not atomically.
  • data uses the same shapes as the individual routes. brokerUtcOffsetMinutes is explicit and is null until measured; broker time is never assumed to be UTC.
  • The answer is 200 whenever anything could be read, and 503 only when no section could be.

Missing data shows as unknown

If a measurement is missing, the answer is unknown. The status page works the same way: a component without a recent check shows as unknown.