API FXCM

FXCM

 

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.

 

Connection

To use the REST API, you will need:

 

 


// ... 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.Demo := false;
 
// ... connect to server
oClient.Active := True;

Messages

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);
begin
  // ... here we receive all messages from server
end;

 

Methods