Market State Event¶
The server sends a JSON market-state event when a symbol's calculated market state or reason changes. It is sent through the existing TCP symbol channel and uses the existing subscription and access checks. Subscribe to a symbol channel (for example, EURUSD) or use SubscribeAll; clients without an authorized subscription do not receive the event. Subscription commands and market-data access details are covered in Quotes.
Message format¶
{
"event": "market.state",
"type": 1,
"data": {
"symbol": "EURUSD",
"sym_index": 12,
"previous_state": 1,
"previous_reason": 0,
"market_state": 0,
"market_reason": 3,
"calculated_at": 1790848800,
"next_recalc_at": 1790848860,
"market_state_revision": 42
}
}
type is the existing event code 1 (EV_RECORD_UPDATE). The data fields are:
| Field | Type | Description |
|---|---|---|
symbol |
string | Symbol name associated with the event. |
sym_index |
integer | Server symbol index. |
previous_state |
integer | State before this change: 0 closed, 1 open. |
previous_reason |
integer | Reason before this change, using the values below. |
market_state |
integer | New state: 0 closed, 1 open. |
market_reason |
integer | New reason, using the values below. |
calculated_at |
integer | Unix time in seconds when the state was calculated. |
next_recalc_at |
integer | Unix time in seconds for the current cached next-minute recalculation boundary. |
market_state_revision |
uint64 | Process-local increasing revision for the cached state tuple. |
State reasons¶
| Value | Name | Meaning |
|---|---|---|
0 |
None |
No specific closed-state reason. |
1 |
Holiday |
The symbol is closed by a holiday. |
2 |
WorkTimeClosed |
Global work time is closed. |
3 |
SymbolSessionClosed |
The symbol's configured trade session is closed. |
4 |
Disabled |
Trading is disabled for the symbol; valid quotes may still arrive. |
5 |
QuoteUnavailable |
The configured quote policy is unavailable and requests a closed market state. |
The state, reason, and revision are published as one coherent cached tuple. The process-local revision increases whenever the market-state cache recalculates, including a refresh whose state and reason are unchanged; it does not increment for every quote tick. Events are emitted only when the state or reason changes. Initial cache population does not itself emit an event. Quote ticks do not imply an opening; retain the market state until an authoritative snapshot or state event changes it.
For a complete initial view, subscribe first and then request GetSymbols. Buffer events received while the snapshot is in flight, apply the snapshot, and then merge buffered and later events by symbol and market_state_revision, ignoring updates older than the revision already stored. A snapshot and event with the same revision describe the same cached tuple. On disconnect, discard the client-side revision baseline; after reconnect, subscribe again and fetch a new snapshot. This ordering closes the snapshot/subscription gap. Event delivery follows the existing TCP subscription/access policy; this JSON event does not change the compact TCP m manager event or the WebSocket compact m message.