Configuring QuantReplay - Quod-Financial/quantreplay GitHub Wiki

To run QuantReplay, it requires several configuration files. When starting Docker Compose for the first time, the Docker container automatically creates the necessary files in the cfg directory:

  • market_simulator.xml — main configuration file for QuantReplay;

  • configSim.txt — QuickFIX configuration file QuickFIX documentation;

  • the directory with QuickFIX AppDataDictionary and TransportDataDictionary files of FIX 5.0 SP2 version.

If files are already present, they are not changed.

The path to the QuantReply XML file configuration is passed to the binary as the -f command line option.

QuantReplay instance configuration

Section Node Required Description

<mktsimulator>

<venue>

Y

Defines a venue_id that is being simulated by a simulator instance. Must be present in the database venue table.

<config>

Y

Specifies a full path to the QuickFIX engine .txt configuration file. See: QuickFIX instance configuration

<mktsimulator><database>

<name>

Y

Sets a database name that QuantReplay connects to.

<user>

Y

Sets a database user name.

<password>

Y

Sets a database user password.

<host>

Y

Sets a database server IP address/hostname.

<port>

Y

Sets a database server port number.

<mktsimulator><logger>

<level>

Y

Specifies a log level for the instance. Possible values:

  • DEBUG;

  • INFO;

  • WARN;

  • ERROR.

<maxSize>

Y

Specifies a maximal size (in MB) of a single log file.

<maxFiles>

Y

Specifies a maximal number of log files before starting a log rotation.

<mktsimulator><http>

<peerHostResolution>

N

Specifies how the QuantReplay instance must resolve a hostname to redirect HTTP requests to other instances. This setting is crucial for running QuantReplay instances on different hosts, i.e., in different Docker containers.

Possible values:

  • localhost — use localhost hostname — the default value.

  • venue — use venue_id as hostname.

For instance, the request should be redirected to the venue with ID MYVENUE, and its REST port is 9010. If localhost is set, REST API will be redirected to the localhost:9010. If the venue is set, the REST API request will be redirected to MYVENUE:9010.

Note:

If MYVENUE:9010 is unreachable or cannot be resolved into an IP address, the redirection will fail.

Ensure that the market simulator containers are running as services in Docker Compose and are connected to the same network. Additionally, their service names must match the venue ID.

<checkApiVersion>

N

Turn on or off the check for the equality of the incoming REST API requests' optional X-API-Version HTTP header value and the major version of the simulator.

If they are not equal, the simulator will respond with status code 412, "Precondition Failed".

If the header is not present, the simulator will not check the version.

Possible values:

  • true — turn on the check — the default value.

  • false — turn off the check.

An example of the XML configuration file:

<mktsimulator>
    <!-- A path to a QuickFIX configuration file -->
    <config>/market-simulator/quod/data/cfg/configSim.txt</config>

    <!-- VenueID of the venue that is simulated by a MktSimulator instance -->
    <venue>XETRA</venue>

    <!-- Database connection configuration -->
    <database>
        <name>simdb</name>
        <user>sim</user>
        <password>sim</password>
        <host>market-simulator-database</host>
        <port>5432</port>
    </database>

    <!-- Rotating logger configuration -->
    <logger>
        <!-- Available levels: [DEBUG, INFO, WARN, ERROR] -->
        <level>INFO</level>

        <!-- Maximal size (MB) of a single log file -->
        <maxSize>5</maxSize>

        <!-- Maximal number of log files -->
        <maxFiles>10</maxFiles>
    </logger>

    <HTTP>
        <!-- Specifies how the market simulator instance must resolve
             a hostname to redirect HTTP requests to other instances.
             Possible values:
                * localhost (default) - use localhost hostname
                * venue - use VenueID as hostname -->
        <peerHostResolution>venue</peerHostResolution>
        <!-- Turn on or off the check the equality of
             the incoming REST API requests' optional X-API-Version HTTP header value and
             the major version of the simulator.
             If they are not equal, the simulator will respond with status code 412, "Precondition Failed".
             If the header is not present, the simulator will not check the version.
             Possible values:
                * true - turn on the check - the default value.
                * false - turn off the check. -->
        <checkApiVersion>true</checkApiVersion>
    </http>
</mktsimulator>

QuickFIX instance configuration

You need to define common settings and then define each FIX session separately.

Defining Common Settings (mandatory)

Common settings are inherited by each FIX session. Here you need to define:

  • ConnectionType=acceptor — QuantReplay is always setting up a FIX acceptor, you can not configure it to set up an initiator;

  • SocketAcceptPort={your-port-number} — specifies which port has to be used for listening for incoming FIX connections;

  • AppDataDictionary={full-path-to-dict-file} — specifies a full path to the FIX application spec file (it can be found in cfg/default/FIX50SP2_marketsimulator.xml);

  • TransportDataDictionary={full-path-to-dict-file} — specifies a full path to the FIX application spec file (it can be found in cfg/default/FIXT11_marketsimulator.xml);

The optional settings that are nice to have:

  • MillisecondsInTimeStamp={boolean} — Only available for FIX.4.2 and greater. TimestampPrecision overrides the setting. The default value is Y.

    • If set to Y, the timestamp precision is 3 — milliseconds are included in the timestamp.

    • If set to N, the timestamp precision is 0 — seconds. There is a bug in QuickFIX library version 1.15.1 — if set to N, the timestamp precision is 3: https://github.com/quickfix/quickfix/issues/615. It was fixed, but the new version of QuickFIX was not released.

  • TimestampPrecision={integer} — sets the fractional part of all outgoing timestamp FIX fields. Allowable values are 0 to 9.

    • If TimestampPrecision is not defined and MillisecondsInTimeStamp is not defined or equals Y, the precision is set to 3 for all timestamps.

    • If TimestampPrecision is not defined and MillisecondsInTimeStamp equals N, the precision is set to 0 for all timestamps.

    • If TimestampPrecision is set, it overrides MillisecondsInTimeStamp.

There is an example of common settings:

[DEFAULT]
ConnectionType=acceptor
SocketAcceptPort=9051
SocketReuseAddress=Y
SocketNodelay=Y
AppDataDictionary=/market-simulator/quod/data/cfg/default/FIX50SP2_marketsimulator.xml
TransportDataDictionary=/market-simulator/quod/data/cfg/default/FIXT11_marketsimulator.xml
StartTime=00:00:00
EndTime=00:00:00
HeartBtInt=30
Note
Single SocketAcceptPort value

You can see that the port for the FIX acceptor is defined in the general configuration. It means that all FIX sessions will be established on that port. You also may want to specify a port per session.

This approach is valid, but is not recommended, as the number of ports required by the QuantReplay will increase when you define additional FIX sessions.

Defining Order-flow FIX sessions

To define a session, the following settings are needed:

  • specify SenderCompID and TargetCompID;

  • set a file path where the QuickFIX engine will keep FIX messages and sequence numbers;

  • define a strategy to keep/reset messages and sequence numbers.

The example:

[SESSION]
BeginString=FIXT.1.1
SenderCompID=SIM_XETRA
TargetCompID=CLIENT_XETRA_ORDER
DefaultApplVerID=9
FileStorePath=/market-simulator/quod/data/files_store_path_common
PersistMessages=Y
RefreshOnLogon=Y
ResetOnLogon=N
Warning
Resetting/Refreshing on session events

Pay attention that a FIX session is configured to refresh its state in the example. Such a configuration is critical for order-flow sessions as it enables QuickFIX to keep track of sequence numbers and missed messages even after logouts/disconnects. You don’t want to lose your order or execution report messages!

Always specify:

  • PersistMessages=Y

  • RefreshOnLogon=Y

  • ResetOnLogon=N

Defining MarketData-flow sessions

The market data sessions configuration is similar to the order sessions configuration. The single difference is that for the Market Data session, you shall prevent refreshing the sequence numbers from the previous session and disable message persistence (to prevent storage consumption).

Here is an example of MarketData-flow FIX session setup:

[SESSION]
BeginString=FIXT.1.1
SenderCompID=SIM_XETRA
TargetCompID=CLIENT_XETRA_MARKET_DATA
DefaultApplVerID=9
FileStorePath=/market-simulator/quod/data/files_store_path_common
PersistMessages=N
RefreshOnLogon=N
ResetOnLogon=Y
⚠️ **GitHub.com Fallback** ⚠️