@mywebapi.com/sdk - v0.3.5
    Preparing search index...

    Class MT4V2SignalRClient

    SignalR wrapper around /hubs/mt4/v2. Holds a single HubConnection and exposes typed stream helpers.

    Lifecycle:

    1. new MT4V2SignalRClient(opts) — synchronous; resolves the token provider and pre-computes the hub URL but does NOT open a socket.
    2. Register callbacks via onConnectionStatus() / onTick() — MAY be called before start(). Registering before start() is recommended so no early server push (e.g. the post-handshake OnConnectionStatus) is missed.
    3. await client.start() — opens the connection. Auth token is fetched via the provider's getToken(); tradePlatform is appended to the URL. All callbacks queued before start() are attached to the HubConnection before the socket opens, guaranteeing they are in place before any server push arrives.
    4. Use streamTicks() / streamMarginCallUpdates() / etc. to consume server streams. Each helper returns an AsyncIterable<T> for easy for await use. Stream helpers require an open connection — call them after start().
    5. await client.stop() — closes the connection.
    Index
    • get hubUrlForTest(): string

      The resolved hub URL including the tradePlatform query parameter. Intended for tests and diagnostic tooling.

      Returns string

    • Returns the underlying HubConnection for advanced use (manual .on/.invoke calls not covered by the typed helpers below). Throws if not started yet.

      Returns HubConnection

    • Subscribe to OnConnectionStatus callbacks. The server pushes one such event right after the handshake completes. May be called before or after start() — registering before start() is strongly recommended to avoid missing the initial post-handshake push.

      Parameters

      Returns void

    • Subscribe to OnTick callbacks. Pair with subscribeToTicks(symbol). May be called before or after start() — registering before is recommended so no early server push is missed.

      Parameters

      Returns void

    • Subscribe to OnTicksBatch callbacks. Pair with subscribeToTicksBatch(symbol). A batch carries every tick the server accumulated during one interval; a connection subscribed to batches does not receive per-tick OnTick events. May be called before or after start() — registering before is recommended so no early batch is missed.

      Parameters

      Returns void

    • Open the SignalR connection. Idempotent — calling twice while already connected resolves without action.

      Returns Promise<void>

    • Close the SignalR connection. Safe to call on a connection that was never started or has already been closed.

      Returns Promise<void>

    • Returns an AsyncIterable<TickPayload>. When symbol is omitted, every symbol's ticks flow through.

      Parameters

      • Optionalsymbol: string

      Returns AsyncIterable<TickPayload>

    • Subscribe the connection to a per-symbol tick stream. Server will push OnTick callbacks for every tick of that symbol until unsubscribed.

      Parameters

      • symbol: string

      Returns Promise<void>

    • Subscribe the connection to batched ticks of one symbol. The server sends one OnTicksBatch event every intervalMs milliseconds (20–60000, default 200) or as soon as maxBatchSize ticks are buffered (1–10000, default 200). While subscribed, per-tick OnTick events are not delivered for that symbol. Repeating the call for the same symbol replaces the previous subscription, so the new interval and size take effect. The subscription lasts until unsubscribeFromTicksBatch(symbol) or until the connection closes. Out-of-range values are rejected by the server.

      Parameters

      • symbol: string
      • intervalMs: number = 200
      • maxBatchSize: number = 200

      Returns Promise<void>

    • Resolve a token via this client's token provider. Intended for tests to verify that the shared provider is wired correctly.

      Returns Promise<string>

    • Parameters

      • symbol: string

      Returns Promise<void>

    • Stop the batched tick stream started by subscribeToTicksBatch(symbol).

      Parameters

      • symbol: string

      Returns Promise<void>