Forex | Subscribe to Streaming Adapters

Streaming data is delivered through five Lightstreamer data adapters under the STREAMINGALL adapter set. Each adapter is addressed by a single ID.{numericId} item; the adapter selector tells the server which kind of entity the id refers to.

Adapters

DataAdapter Item Event Fields
PRICES ID.{MarketId} OnForexPriceTick MarketId, TickDate, Bid, Offer, Price, High, Low, Change, Direction, AuditId, StatusSummary
ORDERS ID.{ClientAccountId} OnForexOrderUpdate / OnForexPositionUpdate OrderId, MarketId, TradingAccountId, Status, Direction, Quantity, Price, Commission, Swap, RealisedPnL, UpdateType, Reference
QUOTES ID.{ClientAccountId} OnForexQuote QuoteId, OrderId, MarketId, Price, Quantity, Status, StatusReason, TypeId, RequestDateTime, ApprovalDateTime
CLIENTACCOUNTMARGIN ID.{ClientAccountId} OnForexAccountMargin Cash, Margin, MarginIndicator, NetEquity, OpenTradeEquity, TradeableFunds, PendingFunds, TradingResource, TotalMarginRequirement, Currency
TRADEMARGIN ID.{TradingAccountId} OnForexAccountMargin Same field set as CLIENTACCOUNTMARGIN, scoped to one trading account.

Note: the item id is always the numeric MarketId, ClientAccountId or TradingAccountId. The adapter selector in the TLCP SUB frame (PRICES / ORDERS / QUOTES / CLIENTACCOUNTMARGIN / TRADEMARGIN) decides which dataset is streamed for that id. There is no PRICE.{id} or similar legacy prefix.

Helper Methods

The main client wraps the Lightstreamer SUB / UNSUB plumbing. The common ones are:

Sample

Subscribe to EUR/USD price ticks


oForex := TsgcWSAPI_Forex.Create(nil);
oForex.Credentials.UserName := '<username>';
oForex.Credentials.Password := '<password>';
oForex.Credentials.AppKey  := '<appkey>';
oForex.OnForexPriceTick := ForexPriceTick;
oForex.Connect;

// EUR/USD market id
oForex.WatchMarket(401484830);

procedure ForexPriceTick(Sender: TObject; const aTick: TsgcWSForexPriceTick);
begin
  // aTick.MarketId, aTick.Bid, aTick.Offer, aTick.Price, aTick.AuditId ...
end;