Quote Policies TCP API¶
Quote policies define which provider may update a symbol's live price. A
policy is reusable: several symbols can reference the same policy through
quote_policy_id while using their own provider-symbol mapping.
Supported provider types:
| Value | Name | provider_id refers to |
|---|---|---|
1 |
FEEDER |
Feeder index |
2 |
GATEWAY |
Gateway ID |
3 |
PLUGIN |
Plugin index |
Supported modes:
| Value | Name | Behavior |
|---|---|---|
1 |
FIXED |
Accept only the first enabled source after priority sorting. |
2 |
PRIORITY_FAILOVER |
Keep one active source and fail over deterministically when it becomes stale. |
3 |
LATEST |
Accept matching ticks from every configured source. This can mix prices and should be used deliberately. |
System policies¶
| ID | Name | Purpose |
|---|---|---|
1 |
System unconfigured |
Safe default for new symbols. No quotes are accepted. |
2 |
Legacy any source |
Compatibility policy accepting all sources. |
System policies cannot be updated or deleted. During migration, symbols with a
specific legacy feeder share one generated Legacy feeder N policy per feeder;
symbols using legacy feeder = 0 are assigned policy 2. A policy source
identifies only a provider. Provider-specific symbol names are normalized to a
symbol's source name at the feeder or gateway boundary before policy matching.
Failover behavior¶
Sources are sorted by descending priority. In PRIORITY_FAILOVER mode the
first source is primary. The server:
- accepts ticks only from the active source;
- declares it stale using the greater of
failover_after_msand itsstale_after_ms; - switches to the highest-priority healthy source;
- optionally switches back after both
recovery_after_msandminimum_active_mshave elapsed.
Runtime selection and recovery¶
For configured non-legacy policies, the server validates every matching provider tick before using it. In priority-failover mode, a standby source's fully checked quote is cached but not published while another source remains active. A separate monitor polls every 250 ms and can publish a fresh cached quote through the normal downstream path after failover; a new tick is not required at that moment. Fixed and latest modes retain their existing source-selection behavior.
Timeouts use a monotonic host clock. The active source is considered expired after max(failover_after_ms, active_source.stale_after_ms). A candidate must independently satisfy its own stale_after_ms, timestamp bounds, positive/non-crossed price, and configured spread checks. A higher-priority candidate blocked by switch deviation does not hide a lower-priority candidate that passes all checks; the selector tries eligible reserves in priority order. max_future_time_ms and max_past_time_ms are checked against the normalized TickInfo.ctm; zero disables the corresponding timestamp bound. Provider boundaries can normalize timestamps (for example, a gateway may use host receipt time), so this does not guarantee that a raw exchange timestamp was validated.
Automatic switch-back to a higher-priority healthy source waits for both recovery_after_ms and minimum_active_ms; emergency failover does not wait for minimum_active_ms. Stale-price recovery handles two cases. If the published output is stale or all sources are unavailable, at least three fresh, stable samples spanning max(250 ms, recovery_after_ms) can replace the obsolete live price without agreeing with it. If a fallback is still healthy, the recovered source must additionally agree with its fresh live quote within configured jump, switch-deviation, and symbol-percent limits. Rebase relaxes comparisons against the obsolete price baseline; inter-sample bid-jump and percentage checks and positive/non-crossed-price, spread, timestamp, source, and other hard checks remain. This prevents a stale primary price from freezing recovery indefinitely. reject_crossed_price: false does not permit ask < bid; crossed prices remain a hard rejection. A partial tick may fill its missing side only from that same provider's cached quote; it cannot borrow the other provider's live price, and a tick missing both sides is rejected.
A closed holiday, work-time window, or symbol trade session suspends policy selection and discards standby quotes so reopening cannot replay a pre-close price. A policy configuration reset clears standby health and candidates; it does not mean a provider recovered. The legacy Legacy any source system policy keeps its historical fallback and filter behavior.
When a policy is unavailable, unavailable_action controls trading admission and market state:
| Value | Behavior during quote unavailability |
|---|---|
1 |
Freeze quote-based updates and block trade-session admission; market state can remain Open. |
2 |
Block trade-session admission and report market state Closed with reason QuoteUnavailable (market_reason = 5). |
3 |
Freeze quote-based updates while keeping trading admission available. |
The compiled policy snapshot and runtime health state are held in memory. Ticks do not query the database. Policy writes update the cache first and are persisted asynchronously as a transaction.
Commands¶
| Command | Description |
|---|---|
| GetQuotePolicies | Return all policies and ordered sources. |
| SetQuotePolicy | Create or update a policy. |
| DeleteQuotePolicy | Delete an unused non-system policy. |
Policy fields¶
| Field | Type | Description |
|---|---|---|
id |
int | Server-assigned ID. Required for updates. |
name |
string | Policy name. |
mode |
int | 1 fixed, 2 priority failover, 3 latest. |
is_system |
bool | Read-only system-policy marker. |
failover_after_ms |
int | Minimum silence before failover. |
recovery_after_ms |
int | Stable recovery window before automatic switch-back. |
minimum_active_ms |
int | Minimum time a fallback remains active. |
switch_back_mode |
int | 1 automatic, 2 manual, 3 never. |
unavailable_action |
int | 1 freeze and disable trading, 2 market closed, 3 freeze and keep trading. |
reject_crossed_price |
bool | Reject ask prices below bid. |
max_spread_points |
int | Policy spread limit; 0 disables it. |
max_price_jump_points |
int | Policy price-jump limit; 0 disables it. |
max_switch_deviation_points |
int | Maximum deviation while switching; 0 disables it. |
max_future_time_ms |
int | Maximum accepted future timestamp offset. |
max_past_time_ms |
int | Maximum accepted past timestamp offset. |
enabled |
bool | Whether the policy can be assigned and used. |
version |
int | Server-managed revision. |
sources |
array | Ordered provider mappings. Maximum 8 enabled/configured sources. |
Source fields¶
| Field | Type | Description |
|---|---|---|
provider_type |
int | 1 feeder, 2 gateway, 3 plugin. |
provider_id |
int | Positive provider identifier. |
priority |
int | Higher values have higher priority. |
enabled |
bool | Enables this source. |
stale_after_ms |
int | Positive source-health timeout. |
max_spread_points |
int | Per-source override; 0 uses the policy limit. |
max_price_jump_points |
int | Per-source override; 0 uses the policy limit. |
Symbol mappings are separate provider-boundary records, not QuotePolicy
configuration. A record maps provider_symbol to source_name. If no entry
exists, the received name is used unchanged. The existing symbol index then
resolves that source name to one or more internal symbols.
{"provider_symbol":"EUR/USD","source_name":"EURUSD"}
Create mappings with the dedicated feeder or gateway mapping commands. They are
persisted separately from feeder config and gateway provider_config.
Matching is exact and case-sensitive; masks and wildcards are not used.
Disabling or deleting a non-system policy automatically assigns system policy
1 to every affected symbol. The reassignment and policy write are persisted
in one database transaction; individual symbol updates are not required.