Documentation

Getting Started

We provide clean forex and CFD data via easy-to-use delivery methods. We use TCP Socket and FIX protocol, making it easier to receive data. Authentication is over a secure FIX protocol, and responses are in string format with numerical tags.

Following are a few simple steps to start receiving data. We will set up your trial connection in a few hours.

  1. 1. Set up a Trial : Start a FIX Trial
  2. 2. Copy code from the below examples : Copy Code.
  3. 3. Receive an email with connection details : Get your connection details
  4. 4. Start receiving data : Connect to API

Authentication

You need to include your API key with the initial request when you start your connection. You can find your api key under your account once you log in.

Our streaming data API documentation is extensive and you can see below all the available routes, currencies and CFDs available to help you integrate our data within your applications. If you are new to WebSockets and SocketIO visit our tutorial page that explains sockets in greater detail.

Available Currencies for streaming data via FIX API

We support over 60+ currency pairs via FIX. You can access a list of currencies available by visiting our FIX currencies list page.

We also provide data for CFDs. See the full CFD list page. Also check the opening and closing times for the CFDs Opening and Closing Times PDF. Also, you can see below the list of all the CFDs we provide through our WebSockets (USD at the end of the CFD code does not imply that data is in dollar value. The below codes only applicable for SocketIO. For Websocket simply take USD off at the end. For example UK100 to get CFDs off Websocket /feedadv endpoint):

Commodities: COPPERUSD (Copper), OILUSD (US OIL), UKOILUSD (UK OIL), NATGASUSD (Natural Gas)

Indices: UK100USD (FTSE), SPX500USD, FRA40USD (CAC), GER30USD (DAX), JPN225USD (Nikkei), NAS100USD (Nasdaq), USA30USD (Dow), HKG33USD (Hang Seng), AUS200USD

Equities: AAPLUSD (Apple), FBUSD (Facebook), AMZNUSD (Amazon), NFLXUSD (Netflix), TSLAUSD (Tesla), GOOGLUSD (Alphabet), BABAUSD (Alibaba), TWTRUSD (Twitter), BACUSD (Bank of America), BIDUUSD (Baidu)

Python Example using QuickFIX

This example implementation is written in Python and uses the QuickFIX libraries we will install these using the command "pip install quickfix"

You can download all source code from GitHub Python FIX Demo Client

                        import sys
import argparse
import quickfix as fix
import quickfix44 as fix44



ECHO_DEBUG= True
sessionID = 0


class Application(fix.Application):
        orderID = 0
        execID = 0
        global sessionID

        def gen_ord_id(self):
            global orderID
            orderID+=1
            return orderID


        def onCreate(self, sessionID):
            return

        def onLogon(self, sessionIDIn):


            mktcodes = ["GBPUSD", "EURUSD", "CCCCCC"]

            reqID = 1
            for mkt in mktcodes:

                message = fix.Message()
                header = message.getHeader();
                header.setField(fix.MsgType("R")) #35
                message.setField(644, "99999999")  # ReqId
                message.setField(146, "1")  # ReqId # 644
                message.setField(55, "GBPUSD")  # 55=SMBL
                message.setField(263, "1")  # SubscriptionRequestType
                message.setField(262, "12356") #Request Type
                message.setField(264, "1")  # Market Depth
                fix.Session.sendToTarget(message, self.sessionID)
            return

        def onLogout(self, sessionID):
            return

        def toAdmin(self, message, sessionID):
            self.sessionID = sessionID
            print(" toAdmin " + str(message))
            if(message.getHeader().getField(fix.MsgType().getField()) == "A"):
                print(" login Message " + str(sessionID))
                message.setField(fix.Username("chris"))
                message.setField(fix.Password("tradermade"))
            return

        def fromAdmin(self, sessionID, message):
            print("fromAdmin: %s" % message.toString())

            return

        def toApp(self, sessionID, message):
            print("ToApp: %s" % message.toString())
            return

        def fromApp(self, message, sessionID):
            print(" FromApp: %s " + str(message))
            symbol = message.getField(fix.Symbol().getField())
            print(symbol)
            # bid = message.getField(fix.BidPx().getField())
            # ask = message.getField(fix.OfferPx().getField())
            #
            # print(symbol + " " + bid + " " + ask )
            return


        def genOrderID(self):
            self.orderID = self.orderID+1
            return self.orderID


        def genExecID(self):
            self.execID = self.execID+1
            return self.execID

        def requestQuote(self):
            print("Creating the following order: ")
            message = fix.Message()
            header = message.getHeader();
            header.setField(fix.MsgType("R"))
            message.setField(55, 'CCCCCC')  # 55=SMBL ?
            fix.Session.sendToTarget(message, self.sessionID)


def main(config_file):
    try:
            settings = fix.SessionSettings( config_file )




            application = Application()
            storeFactory = fix.FileStoreFactory( settings )
            logFactory = fix.FileLogFactory( settings )
            initiator = fix.SocketInitiator( application, storeFactory, settings, logFactory )

            initiator.start()

            while 1:
                input1 = input(" Input \n")
                if input1 == 'q':
                    print("Request Quote")
                    application.requestQuote()
                if input1 == '2':
                    sys.exit(0)
                if input1 == 'd':
                    import pdb
                    pdb.set_trace()
                else:
                    print("Valid input is 1 for order, 2 for exit")
                    continue

    except fix.ConfigError as e:
            print(e)

if __name__=='__main__':
    parser = argparse.ArgumentParser(description='FIX Client')
    parser.add_argument('-c', '--configfile', default="clientLocal.cfg",help='file to read the config from')
    args = parser.parse_args()
    main(args.configfile)
                            
                    

Below is the Client Configuration code. You will need to insert your SocketConnectionHost, SocketConnectionPort, SenderCompID, TargetCompID, Username, and Password into this. It is possible to set RefreshOnLogin if required. You get this information when you register for a trial.

                        
# This is a client (initiator)

[DEFAULT]
FileStorePath=./session/
ConnectionType=initiator
StartTime=00:01:00
EndTime=23:59:00
HeartBtInt=30
UseDataDictionary=Y
DataDictionary=FIX44.xml
ValidateUserDefinedFields=N
ValidateIncomingMessage=Y
RefreshOnLogon=Y
FileLogPath=./Logs
SSL_PROTOCOL = all
#ClientCertificateFile=keystore/tradermade.pem


[SESSION]
BeginString=FIX.4.4
SocketConnectHost=fix-marketdata.tradermade.com
SocketConnectPort=9883
SenderCompID=SENDER_COMP_ID
TargetCompID=TARGET_COMP_ID

[LOGGING]

ScreenLogEvents=N
ScreenLogShowIncoming=N
ScreenLogShowOutgoing=N
ScreenLogShowHeartBeats=N

[ACCOUNT]
Username=USERNAME
Password=PASSWORD

                        
                    

Add the following code into your section in our pom.xml. This step will download the libraries from the Maven repository.

Once you have this project set up you should be able to run "python client.py" and you should see the financial data.

Java Example using QuickFIX/J

This example implementation is written in Java and uses the QuickFIX/J libraries. For this example, we will acquire them from the Maven repository. But they can also be downloaded from www.quickfixj.org or cloned from GitHub.

You can download all source code from GitHub Java FIX Demo Client

This tutorial will assume that you have Java programming knowledge and experience setting up a Maven project.

This tutorial assumes that you have contacted TraderMade support and have the login credentials required to connect to the service.

Below is the ClientApplication Code. This example is a simple class that will make a connection to the TraderMade FIX server and returns data for requested instruments.

                        
import ch.qos.logback.classic.Level;
import quickfix.*;
import quickfix.field.*;
import quickfix.fix44.QuoteRequest;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.StringTokenizer;

public class ClientApplication implements Application {


 private String username;
 private String password;
 private String symbols;

 private static volatile SessionID  sessionID;


 public void onCreate(SessionID sessionID) {
     System.out.println("OnCreate");
 }


 public void onLogon(SessionID sessionID) {
     System.out.println("OnLogon");
     ClientApplication.sessionID = sessionID;
     Session s = Session.lookupSession(sessionID);
     StringTokenizer symbolsTokens = new StringTokenizer(symbols, " ");
     while(symbolsTokens.hasMoreTokens()){
	     MarketDataRequest>/span>  qr = new MarketDataRequest();
	     qr.setString(Symbol.FIELD, symbolsTokens.nextToken());
	     s.send(qr);
     }
 }


 public void onLogout(SessionID sessionID) {
     System.out.println("OnLogout");
 }

 public void toAdmin(Message message, SessionID sessionID) {
     System.out.println("ToAdmin");
     if (message instanceof quickfix.fix44.Logon) {
         try {
             System.out.println(" Login " + username + " " + password);
             message.setString(quickfix.field.Username.FIELD, username);
             message.setString(quickfix.field.Password.FIELD, password);
             System.out.println(" Logon " + message.toString());
         }
         catch (Exception ex) {
             throw new RuntimeException();
         }
     }else if (message instanceof quickfix.fix44.QuoteRequest) {
         System.out.println(" Sent Quote Request ");
     }
 }

 public void fromAdmin(Message message, SessionID sessionID) throws FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon {
     System.out.println("FromAdmin");
 }

 public void toApp(Message message, SessionID sessionID) throws DoNotSend {
     System.out.println("ToApp: " + message);
 }

 public void fromApp(Message message, SessionID sessionID) {
     try {
         String symbol = message.getString(Symbol.FIELD);
             System.out.println(" FromApp " + message);
             message.getHeader().getString(SendingTime.FIELD);
             double bid = message.getDouble(BidPx.FIELD);
             double ask = message.getDouble(OfferPx.FIELD);
     } catch (FieldNotFound fieldNotFound) {
         fieldNotFound.printStackTrace();
     }
 }


 public ClientApplication(String configFile) {
     try {
         System.out.println(" Config File " + configFile);
         Properties props  = new Properties();
         try {
             props.load(new FileInputStream(configFile));
         } catch (IOException e) {
             e.printStackTrace();
         }
         username = props.getProperty("Username");
         password = props.getProperty("Password");
         symbols = props.getProperty("Symbols");
         System.out.println(" FIX Port " + props.getProperty("SocketConnectPort"));
         System.out.println(" FIX IP " + props.getProperty("SocketConnectHost"));
         System.out.println(" Username " + username + " Password " + password);
         SessionSettings settings = new SessionSettings(configFile);
         MessageStoreFactory messageStoreFactory = new FileStoreFactory(settings);
         LogFactory logFactory = new FileLogFactory(settings);
         MessageFactory messageFactory = new DefaultMessageFactory();
         Initiator initiator = new SocketInitiator(this, messageStoreFactory, settings, logFactory, messageFactory);
         initiator.start();

         String serverIp = props.getProperty("SocketConnectHost");
         String serverPort = props.getProperty("SocketConnectPort");
         System.out.println(" Data Server IP " + serverIp);
         System.out.println(" Data Server Port " + serverPort);
         ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger)
                      org.slf4j.LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
         root.setLevel(Level.OFF);
//            root.setLevel(Level.DEBUG);

         while (sessionID == null) {
             Thread.sleep(1000);
         }

         Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
             public void run() {
                 System.out.print("Logout");
                 Session.lookupSession(sessionID).logout();
             }
         }));
     }catch (Exception e){
         e.printStackTrace();
     }

 }

 public static void main(String[] args){
     String configFile = args[0];
     new ClientApplication(configFile);
 }
}

                        
                    

Below is the Client Configuration code. You will need to insert your SocketConnectionHost, SocketConnectionPort, SenderCompID, TargetCompID, Username, and Password into this. You can also set RefreshOnLogin, and you obtain this information.

                        
[default]
ApplicationID=client2
FileStorePath=messagestore/messages/
ConnectionType=initiator
StartTime=00:01:00
EndTime=23:59:00
HeartBtInt=30
UseDataDictionary=Y
DataDictionary=FIX44.xml
ValidateUserDefinedFields=N
ValidateIncomingMessage=N
RefreshOnLogon=Y
ResetOnLogon=Y

[session]
BeginString=FIX.4.4
SocketConnectHost=SOCKET_CONNECTION_HOST
SocketConnectPort=SOCKET_CONNECTION_PORT
SenderCompID=SENDER_COMP_ID
TargetCompID=CLIENT_COMP_ID
​
[SSL]

#SocketUseSSL=Y
#SocketKeyStore=KEYSTORE_NAME
#SocketKeyStorePassword=KEYSTORE_PASSWORD

[Logging]
FileLogPath=log
ScreenLogEvents=N
ScreenLogShowIncoming=N
ScreenLogShowOutgoing=N
ScreenLogShowHeartBeats=N

[Account]
Username=USERNAME
Password=PASSWORD

Symbols=EURUSD
#Symbols=USDCAD USDCZK USDDKK USDHUF USDILS USDNOK USDPLN USDSGD USDTHB

                        
                    

Add the following code into your section in our pom.xml. This step will download the libraries from the Maven repository.

                            
<dependency>
    <groupId>org.quickfixj</groupId>
    <artifactId>quickfixj-core</artifactId>
    <version>2.1.1</version>
</dependency>

<dependency>
    <groupId>org.quickfixj</groupId>
    <artifactId>quickfixj-messages-fix44</artifactId>
    <version>2.1.1</version>
</dependency>

<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <version>0.9.24</version>
</dependency>
                            
                        

Once you have the code set up, you can run the program. You will need to pass the location of the 'config' file as a parameter, and you should see live price data in the console.