Tips to connect FIXParser Pro with QuickFIX C++

author
By FIXParser

2024-12-18

FIXParser Pro

The FIX protocol is widely used in the financial industry for electronic trading. In this article, we'll explore how to connect a TypeScript application using the FIXParser library to QuickFIX, an open-source FIX engine written in C++. We'll break down the process and provide code to illustrate key steps. By the end of this guide, you'll understand how to set up communication between the two systems.

Overview

In this setup, we have two key components:

  • QuickFIX (C++): A FIX engine that is responsible for handling the FIX protocol on the server side. It is a well-established library used by many financial institutions.
  • FIXParser: Please note that this example requires FIXParser Pro

We will simulate a client-server communication where:

  • QuickFIX will act as the server.
  • FIXParser will act as the client, sending and receiving messages.

Prerequisites

  • QuickFIX Installation: Ensure QuickFIX is installed and set up correctly on your machine. You can download it from QuickFIX GitHub repository.
  • Node.js and TypeScript: Ensure you have Node.js and TypeScript installed on your machine. You can get them from Node.js official site and TypeScript official site.
  • FIXParser library: We will use the FIXParser library to parse and construct FIX messages in our TypeScript application. Install it via npm:



  • Network Configuration: QuickFIX and FIXParser will communicate via TCP/IP. Both systems should be able to connect to each other over the network. You'll need to configure QuickFIX to listen on a specific port (e.g., 5001) and ensure that the TypeScript/FIXParser application can connect to that port.

QuickFIX Server Setup

QuickFIX, as the server, will listen for incoming FIX messages. The configuration and setup of QuickFIX is a broad topic, but here's a simplified example of how to set it up:

  • Configure QuickFIX settings: Create a configuration file quickfix.cfg for QuickFIX:



    This configuration file tells QuickFIX to:

    • Act as a FIX acceptor (server)
    • Listen for connections on port 5001
    • Use FIX.4.4 as the FIX version
    • Define SenderCompID and TargetCompID for message routing.
  • Launch QuickFIX: After configuring QuickFIX, you can start the QuickFIX engine using the following command:



    This will start QuickFIX and it will listen for incoming FIX messages on port 5001.

FIXParser Client Setup (TypeScript)

Next, we'll use FIXParser in a TypeScript client to connect to the QuickFIX server. Here's how you can do it.

  • Install dependencies: Ensure fixparser and other required libraries are installed in your TypeScript project:



  • Create the TypeScript Client: Create a file, e.g., fixClient.ts, and begin by importing required modules and setting up the network connection.



    Explanation of the TypeScript Client:

    • TCP Connection: FIXParser establishes a TCP connection to the QuickFIX server.
    • Logon Message: The client sends a "Logon" message to QuickFIX when the connection is established. This message is a fundamental part of the FIX protocol that establishes a session between two parties.
    • createMessage: The fixParser.createMessage() function is used to construct and serialize the FIX message. The message is then sent to the QuickFIX server.
    • Send Order: The Message class is returned from fixParser.createMessage() and can be sent with fixParser.send(newOrderSingle)
    • Logout: Once we have sent the order, we end the session.

    Run the example with a Typescript runner such as tsx or ts-node.