From sgcWebSockets 2022.7.0 XTB WebSocket API is supported, XTB provides access to over 2100 financial markets including FX, indices, shares, commodities and more.
The WebSocket protocol allows 2 types of requests: Streaming commands (receive live updates) and Retrieve Trading Data (send a request to server retrieving some information).
You can configure the following properties in the XTB property.
When the client successfully connects to XTB servers, the event OnXTBConnect is fired. If there is any error while trying to connect, the event OnXTBError will be fired with the error details.
After the event OnXTBConnect is fired, then you can start to send and receive messages from XTB servers.
oClient := TsgcWebSocketClient.Create(nil); oXTB := TsgcWSAPI_XTB.Create(nil); oXTB.Client := oClient; oXTB.XTB.User := 'user_0001'; oXTB.XTB.Password := 'secret_0001'; oClient.Active := True; procedure OnXTBConnect(Sender: TObject; const aStreamSessionId: string); begin DoLog('#XTB Connected'); end; procedure OnXTBError(Sender: TObject; aCode, aDescription, aRawMessage: string); begin DoLog('#error: ' + aDescription); end;
Find below a compiled demo for Windows to test the XTB Client Features.
When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.