Skip to content

Multiple FIX Versions

Richard Warburton edited this page Oct 17, 2019 · 8 revisions

Artio instances can support multiple versions of the FIX protocol concurrently within the same instance. This is only supported as an initiator (client) - using Artio as a FIX acceptor (server) currently only supports using one, configurable, version of FIX for a given instance. This feature is useful for buy-side users who wish to trade on multiple different venues that use different FIX versions.

Multiple concurrent FIX versions require changes to the way that you generate codecs, how you initiate Sessions, and potentially to session customisation.

Codec Generation

Artio has an interface for each FIX session message that it handles or operates on. These interfaces all have the prefix Abstract, for example AbstractLogonDecoder is the interface for the LogonDecoder implementation. The interface used to refer to a specific FIX dictionary version is called the FixDictionary and there is a FixDictionaryImpl generated for each dictionary version.

The CodecGenerationTool needs to be run for different FIX protocol version that you want to support. You must specify a parent package that the codecs will be generated in by using the fix.codecs.parent_package system property and these packages should be different to each other. You should ensure that all of the required codecs are on the runtime classpath for both the Artio Library and Engine.

The examples below show how to set this package to uk.co.real_logic.artio.fixt.

Commandline Example

java -Dfix.codecs.parent_package=uk.co.real_logic.artio.fixt -cp "artio-codecs/build/libs/artio-codecs-${ARTIO-VERSION}.jar" \
uk.co.real_logic.artio.dictionary.CodecGenerationTool  \
/path/to/generated-src/directory \ 
src/main/resources/your_fix_dictionary_file.xml

Maven Example

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>java</goal>
            </goals>
            <phase>generate-sources</phase>
        </execution>
    </executions>

    <configuration>
        <mainClass>uk.co.real_logic.artio.dictionary.CodecGenerationTool</mainClass>
        <arguments>
            <argument>${project.build.directory}/generated-sources/java</argument>
            <argument>src/main/resources/your_fix_dictionary_file.xml</argument>
        </arguments>
        <systemProperties>
            <systemProperty>
                <key>fix.codecs.parent_package</key>
                <value>uk.co.real_logic.artio.fixt</value>
            </systemProperty>
        </systemProperties>
    </configuration>
</plugin>

Gradle Example

task generateCodecs(type: JavaExec) {
    main = 'uk.co.real_logic.artio.dictionary.CodecGenerationTool'
    classpath = sourceSets.main.runtimeClasspath
    systemProperty("fix.codecs.parent_package", "uk.co.real_logic.artio.fixt")
    args = ['/path/to/generated-src/directory', 'src/main/resources/your_fix_dictionary_file.xml']
    outputs.dir '/path/to/generated-src/directory'
}

Initiating a Session.

In order to specify which fix dictionary version is used for a given session you should set the fixDictionary property of the SessionConfiguration used to initiate the connection with the FixDictionaryImpl class for that version. For example the following code would set use the dictionary generated into uk.co.real_logic.artio.fixt.

import uk.co.real_logic.artio.fixt.FixDictionaryImpl;

sessionConfiguration.fixDictionary(FixDictionaryImpl.class)

SessionCustomisationStrategy

When implementing a SessionCustomisationStrategy that supports different FIX versions you will be passed the interfaces AbstractLogonEncoder and AbstractLogoutEncoder. The types of these interfaces can be compared using Java's instanceof keyword and downcasted appropriately in order to apply modifications that are relevant to a specific FIX dictionary version. For example the following customisation strategy only set the applVerID field if the Logon message is for a FIXT protocol version.

import uk.co.real_logic.artio.fixt.builder.LogonEncoder;
import uk.co.real_logic.artio.fixt.ApplVerID;

class FixTSessionCustomisationStrategy implements SessionCustomisationStrategy
{
    private final ApplVerID applVerID;

    FixTSessionCustomisationStrategy(final ApplVerID applVerID)
    {
        this.applVerID = applVerID;
    }

    public void configureLogon(final AbstractLogonEncoder abstractLogon, final long sessionId)
    {
        if (abstractLogon instanceof LogonEncoder)
        {
            final LogonEncoder logon = (LogonEncoder)abstractLogon;
            logon.defaultApplVerID(applVerID.representation());
        }
    }

    public void configureLogout(final AbstractLogoutEncoder logout, final long sessionId)
    {
    }
}
Clone this wiki locally