• Yes, requires OpenSSL
  • No, only Blocking mode
  • Yes, Requires Win8.+

FXCM WebSocket API


From sgcWebSockets 4.2.4 FXCM WebSocket API is supported. FXCM, also known as Forex Capital Markets, is a retail broker for trading on the foreign exchange market. FXCM allows people to speculate on the foreign exchange market and provides trading in contract for difference (CFDs) on major indices and commodities such as gold and crude oil. It is based in London.

FXCM offers a web-based REST API which can be used to establish secure connectivity with FXCM’s trading systems for the purpose of receiving market data and trading.

FXCM sgcWebSockets component uses WebSocket (socket.io) and HTTP as transports to connect to a FXCM Servers.


To use the REST API, you will need:

  • Access Token generated with Trading Station Web https://tradingstation.fxcm.com/.

  • Select which API do you want connect: api-demo.fxcm.com or api.fxcm.com.


// ... create components

oClient := TsgcWebSocketClient.Create(nil);

oFXCM := TsgcWSAPI_FXCM.Create(nil);

oFXCM.Client := oClient;


// ... set properties FXCM

oFXCM.FXCM.AccessToken := 'here your access token';

oFXCM.FXCM.Host := 'api.fxcm.com';

oFXCM.FXCM.Port := 443;



// ... connect to server

oClient.Active := True;



Once authenticated against server, FXCM uses websocket to receive unsolicited messages like price updates and you can request data from server using HTTP methods.


oClient.OnMessage(Connection: TsgcWSConnection; const Text: string);


  // ... here we receive all messages from server





  • GetSymbols: Request a list of all available symbols.

  • SubscribeMarketData: After subscribing, market price updates will be pushed to the client via the socket.

  • SubscribeTradingTables: Subscribes to the updates of the data models. Update will be pushed to client via the socket. Type of update can be determined by "Model" Parameter.

  • SnapshotTradingTables: In case continuous updates of the trading tables is not needed, it is possible to request a one-time snapshot. Gets current content snapshot of the specified data models.

    • Model choices:

      • Offer

      • OpenPosition

      • ClosedPosition

      • Order

      • Summary

      • LeverageProfile

      • Account

      • Properties

  • UpdateSubscriptions: Offers table will show only symbols that we have subscribed to using update_subscriptions.

  • TradingOrder: allows to send open orders, modify, close...

  • GetHistoricalData: Allow user to retrieve candles for a given instrument at a given time frame. If time range is specified, number of candles parameter is ignored, but still required. There is a limit on the number of candles that can be returned in one request.