SCT Feeder¶
SCT Feeder connects to a ScaleTrade server over its manager TCP interface. It uses one independent connection for quotes and another for history operations. Each connection authenticates and checks its own health, so a history request or reconnect does not invalidate the quote connection.
Authentication¶
Use api_token for a service integration when the manager API token is
available. Set the raw token value; do not prepend Bearer. The feeder sends
it as the TCP request field __token and validates the connection with an
authenticated GetServerTime request. If the supplied API token is rejected,
the feeder reports the authentication failure and retries with backoff. It
does not fall back to the manager password.
An API token is checked together with the parent manager's permissions. A
scoped token used for quotes must permit GetServerTime and Subscribe when
symbols is configured, or GetServerTime and SubscribeAll when it is not.
If the feeder also imports chart history, allow GetChartData as well. The
interactive history protocol described below uses the same permission. An
expired or revoked API token must be replaced in the feeder configuration.
For compatibility, when api_token is omitted or empty, the feeder authenticates each
TCP connection independently with AuthManager using manager_id and
password. The resulting session token is local to that connection. When its JWT expiry
claim is available, the feeder reconnects and authenticates before expiry;
heartbeat failures also trigger recovery.
Configuration¶
The following object is passed as the feeder's config field. Fields marked
optional may be omitted; defaults are shown below.
{
"host": "trade.example.com",
"port": "443",
"api_token": "<manager-api-token>",
"symbols": ["EURUSD", "GBPUSD"],
"subscription_refresh_seconds": 60,
"history_retries": 3,
"history_wait_seconds": 300,
"manager_id": 42,
"password": "<manager-password>",
"notify_every_symbols": 30,
"queue_size": 1024,
"max_line_bytes": 67108864,
"no_spread": false,
"enable_watcher": false
}
| Field | Type | Default | Description |
|---|---|---|---|
host |
string | "localhost" |
Server hostname or IP address. |
port |
string | "443" |
TCP port, represented as a string. The port value does not enable TLS. |
api_token |
string | omitted | Manager API token. When nonempty, takes precedence over password authentication. Keep it secret. |
symbols |
array of strings | omitted | Optional exact, case-sensitive upstream symbol names to subscribe to. When absent, the feeder uses SubscribeAll. When present, the list must be nonempty; duplicate names are removed. |
subscription_refresh_seconds |
integer | 60 |
Interval for repeating the subscription request and checking its acknowledgement; range 1–86400. |
history_retries |
integer | 3 |
Number of retries after the initial failed history request; range 0–20. |
history_wait_seconds |
integer | 300 |
Recovery window for each history symbol (an in-flight request retains its own timeout); range 1–86400. |
manager_id |
integer | 0 |
Manager ID for legacy AuthManager authentication. Used when api_token is omitted or empty. |
password |
string | empty | Manager password for legacy AuthManager authentication. Used when api_token is omitted or empty. |
notify_every_symbols |
integer | 30 |
Retained for compatibility with existing feeder configurations; range 1–65535, currently unused. |
queue_size |
integer | 1024 |
Maximum number of queued quote ticks; range 1–1000000. Non-tick event arrays are not placed in this queue. |
max_line_bytes |
integer | 67108864 |
Maximum inbound TCP frame size in bytes; range 1024–268435456. |
no_spread |
boolean | false |
If true, the delivered ask is set to the bid after quote validation. |
enable_watcher |
boolean | false |
Enable the optional tick watchdog. |
The four connection timing fields are top-level feeder fields, outside
config:
| Field | Type | Default | Description |
|---|---|---|---|
timeout |
integer | 15 |
TCP request/heartbeat timeout in seconds; range 1–65535. |
timeout_reconnect |
integer | 15 |
Base reconnect delay in seconds; range 1–65535. |
timeout_sleep |
integer | 60 |
Upper reconnect delay in seconds; range 1–65535. |
attempts_sleep |
integer | 10 |
Number of consecutive failed attempts before using the upper reconnect delay; range 1–65535. |
Example complete AddFeed request:
{
"command": "AddFeed",
"name": "SCT market data",
"module_name": "st_feeder",
"description": "Primary quote source",
"config": {
"host": "trade.example.com",
"port": "443",
"api_token": "<manager-api-token>",
"symbols": ["EURUSD", "GBPUSD"]
},
"enable": 1,
"mode": 0,
"timeout": 15,
"timeout_reconnect": 15,
"timeout_sleep": 60,
"attempts_sleep": 10
}
Connection and recovery behavior¶
The feeder retries DNS, connection, authentication and subscription failures
until stopped. Reconnect delay grows exponentially from timeout_reconnect and
is capped at the larger of timeout_reconnect and timeout_sleep; after
attempts_sleep consecutive failures it uses that cap. A small random jitter
reduces synchronized reconnect attempts. The failure count resets after the
quote connection has authenticated and received a successful subscription
acknowledgement.
Quote health is checked with an authenticated GetServerTime request even
when no quote ticks arrive. Lack of ticks alone does not indicate a dead
connection, which allows quiet markets and market closures. The feeder reports
the quote subscription as ready only after the server acknowledges it. A
periodic subscription refresh detects lost subscriptions. With symbols, the
server response's skipped_chanels list is treated as a partial subscription
and causes a logged recovery attempt; the feeder does not claim that skipped symbols
are subscribed.
The feeder accepts quote event arrays in the format:
["t", "EURUSD", 1.08321, 1.08334, 1794900000]
Only valid tick events enter the bounded quote queue. Stale events from a
previous TCP connection are ignored after a reconnect. last_tick reflects
the local Unix receipt time of a tick successfully passed to the host; ctm
inside the event remains the upstream quote timestamp.
Feeder state¶
GetState returns the SDK FeederStateRecord without changing its layout or
version:
| Field | Meaning |
|---|---|
state |
Raw SCT Feeder state: 0 disconnected, 1 connecting, 2 authenticating, 3 subscribing, 4 ready, 5 backing off, 6 stopped. |
last_tick |
Unix receipt time of the last tick successfully delivered to the host; 0 if none has been delivered. |
last_ping |
Unix receipt time of the last successful authenticated GetServerTime response; 0 if none has succeeded. |
The host exposes state as the feeder's raw state value; it should not infer
additional platform-wide meanings from these numbers.
History actions¶
Legacy history actions¶
The feeder supports GetHistoryBySymbol and GetHistoryBySymbolsList through
ExecCustomActionFeeder. History data is fetched using GetChartData with
frame 1M. A temporary connection or request failure is retried according to
history_retries, while connection recovery is awaited up to
history_wait_seconds for each symbol. Stopping the feeder completes a pending
history operation so the host can release its in-progress state. Completion logs
report success and failure counts. Ranges are not split into chunks; response
frames remain subject to max_line_bytes.
Single-symbol request:
{
"command": "ExecCustomActionFeeder",
"index": 7,
"action": "GetHistoryBySymbol",
"symbol": "EURUSD",
"source": "EURUSD",
"from": 1794787200,
"to": 1794873600
}
Multiple-symbol request:
{
"command": "ExecCustomActionFeeder",
"index": 7,
"action": "GetHistoryBySymbolsList",
"from": 1794787200,
"to": 1794873600,
"symbols": [
{"symbol": "EURUSD", "source": "EURUSD"},
{"symbol": "GBPUSD", "source": "GBPUSD"}
]
}
Both actions require nonnegative integer Unix timestamps with from <= to and at least one nonempty local/source mapping. The current
server wrapper returns status 200 when the feeder accepts an action and adds
data: "OK" alongside the feeder's response fields. For example, the complete
TCP response to the two-symbol request is:
{"extID":"request-id","status":200,"data":{"progress":"pending","symbols":2,"data":"OK"}}
Here symbols is the number of requested local/source mappings. The response
means the asynchronous operation was queued; it does not assert that all
symbols have completed successfully or that history was imported. If another history operation is already
in progress, the feeder returns RET_OK_NONE; the current server wrapper
reports that plugin result as status 500 with error: "INVALID_EXEC_ACTION_PLUGIN".
Invalid action parameters return RET_BAD_REQUEST from the SDK callback and
are also reported by the wrapper as status 500 with
error: "INVALID_EXEC_ACTION_PLUGIN". The endpoint validates that index is
present before calling the feeder; a missing index returns status 400 with
error: "INVALID_DATA".
Interactive history actions¶
New SCT Feeder versions opt in through ExecCustomActionFeeder; the server
first checks the capability action. Older feeder builds do not implement these
actions and remain compatible through the legacy path. Capability detection is
explicit: an unknown action, an error, or a response without the required
protocol fields is treated as legacy, never as interactive support.
The server passes the action name and the JSON payload to the existing feeder
CustomAction callback; the examples below show those two parts separately.
Capability action is HistorySyncCapabilities; its request payload is empty:
{}
{"protocol":1,"chunked_fetch":true,"max_chunk_seconds":86400}
The capability response fields are protocol (supported protocol version),
chunked_fetch (whether bounded history chunks are supported), and
max_chunk_seconds (maximum requested chunk duration). A feeder must advertise
these fields before the server schedules interactive jobs.
Start or read a bounded fetch¶
HistorySyncFetch starts one bounded request. The chunk duration does not
exceed one day or the maximum advertised by this feeder. source is the feeder's source symbol name;
from and to are inclusive Unix timestamps in UTC seconds, aligned to closed
M1 bars.
Action: HistorySyncFetch
{"protocol":1,"job_id":"hs-000041","chunk_id":"hs-000041-EURUSD-0","source":"EURUSD","from":1794787200,"to":1794873540}
The action returns a status object. While a remote request is pending, poll
HistorySyncStatus with the same identifiers. A ready response contains at
most 1,440 candle rows in [open, high, low, close, volume, time] order. Rows
are closed M1 bars, sorted by timestamp, unique, and within the requested
range. Repeated status reads return the same ready chunk until it is released.
{"protocol":1,"job_id":"hs-000041","chunk_id":"hs-000041-EURUSD-0","state":"ready","attempt":1,"error":"","rows":[[1.08321,1.08340,1.08310,1.08334,12,1794787200],[1.08334,1.08351,1.08330,1.08348,9,1794787260]]}
Action result fields:
| Field | Type | Description |
|---|---|---|
protocol |
integer | Protocol version, 1. |
job_id |
string | Server job identifier supplied in the request. |
chunk_id |
string | Unique identifier for this symbol/time chunk. |
state |
string | waiting_source, fetching, ready, failed, or cancelled. |
attempt |
integer | Current or most recent fetch attempt. |
error |
string | Error detail; empty when there is no error. |
rows |
array, optional | Present when state is ready; candle arrays use [open, high, low, close, volume, time]. |
Status request:
Action: HistorySyncStatus
{"protocol":1,"job_id":"hs-000041","chunk_id":"hs-000041-EURUSD-0"}
The response has the same fields and shape as HistorySyncFetch.
Release a chunk¶
Once the server has consumed or rejected a completed chunk, it releases that buffer:
Action: HistorySyncRelease
{"protocol":1,"job_id":"hs-000041","chunk_id":"hs-000041-EURUSD-0"}
{"protocol":1,"released":true}
The feeder clears only the matching completed buffer. released is true
when that buffer was released.
Cancel an active fetch¶
Action: HistorySyncCancel
{"protocol":1,"job_id":"hs-000041"}
{"protocol":1,"cancelled":true}
Cancellation affects only the matching history fetch; it must not stop quote subscriptions. A late callback from the cancelled request is ignored. Legacy batch history and an interactive fetch cannot run concurrently on the same feeder. An unsupported or busy action must not mutate another active fetch.
These action names and payloads are server-to-feeder protocol details; the BO
client uses the Mng*HistorySync* job commands and does not call them directly.
The interactive fetch actions do not invoke the SDK's candle import callback.
The server owns staging, validation and commit so the job's status and imported
candle counts reflect server-side persistence. Legacy GetHistoryBySymbol and
GetHistoryBySymbolsList retain their current behavior and payloads.