Mini-FIX

 

Start | Download | Documentation | Contact us 

 

Content

Start
Download
Documentation
Contact
 
 
 
 

Documentation

License (Simplified BSD License)

Copyright (c) 2009, Björn Ahlqvist
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Batch language

Example test case

# Example test case
Send:NewOrderSingle:38=10000|11=$UNIQUE|44=$ASK
Expect:35=8|150=0|39=0|20=0|38=10000|14=0|151=10000|32=0
Expect:35=8|150=1|39=1|20=0|38=10000|14=2000|151=8000|32=2000
Expect:35=8|150=1|39=1|20=0|38=10000|14=3000|151=7000|32=1000
Expect:35=8|150=0|39=0|20=0|38=10000|14=10000|151=0|32=7000

Example reference data download

# Example reference data download
Reset
Connect:localhost:1234
Expect:35=A
Send:SecurityDefinitionRequest:
Send:TestRequest:112=DONE
Wait:35=0|112=DONE
Save:c:\refdata.txt
Quit

Commands

Lines starting with # (hash) are comments.
Command Syntax Description
Send
Send:<Tran>:<Tags>

Will send a transaction to the other side.
<Tran> Name of the transaction to use as a template
<Tags> Tags to override the template transaction

Expect
Expect:<Tags>

Validate the next transaction to arrive and compare the results.
<Tags> Tags and their expected values e.g. 35=8|150|!16|39=0|!150=2

Wait
Wait:<Tags>

Wait for matching transaction to arrive.
<Tags> Tags and their expected values

Wait
Wait:<Tags1:Script1:Tags2:Script2:...>

Wait for matching transaction to arrive. Start named script when matching tags are received.
<Tags1> Tags and their expected values <Script1> Batch script to start of Tags1 matches

Connect
Connect:<Host:Port>

Connect to remote system
<Host:Port> Host address and port to connect to

Listen
Listen:<Port>

Listen to local port
<Port> Port to listen to

Disconnect
Disconnect

Disconnect from remote system. No arguments.

Quit
Quit

Quit program. No arguments.

Save
Save:<Filename>

Save current log to file.
<Filename> Filename of destination file

Execute
Execute:<Batchname>

Stop executing current script and start executing named script.
<Batchname> Name of the batch script to execute

Execute
Execute:<Batchname>:<Repeat-Count>

Stop executing current script and start executing named script Repeat-Count times
<Batchname> Name of the batch script to execute
<Repeat-Count> Times to repeat script

Sleep
Sleep:<Milliseconds>

Wait for Milliseconds milliseconds (1/1000 second)
<Milliseconds> Time to wait

Message
Message:<Text>

Output message in log. If seperated by spaces, special values will be parsed. I.e Message:Using security $SEC[48]
<Text> Message

RandomizeSecurity
RandomizeSecurity

Select a security randomly from the Securities menu

SenderCompId
SenderCompId:<Text>

Change SenderCompId
<Text> New CompId

TargetCompId
TargetCompId:<Text>

Change TargetCompId
<Text> New CompId

Reset
Reset

Reset sequence numbers

Pipe interface

Minifix creates a named pipe called \\.\pipe\minifix
Data writted to it is interpreted as batch commands. Data read from it is the log file. See below for (a primitive) example.

In this example the type command exits after reading the first line. This is because it thinks it reached the end of file. A short example code in C how to read from the pipe without exiting:

           
#include <stdio.h>
#include <windows.h>

void main()
{
        HANDLE h;
        DWORD dummy;
        char ch;

        h = CreateFile(
                "\\\\.\\pipe\\minifix",
                GENERIC_READ,
                0,
                NULL,
                OPEN_EXISTING,
                FILE_ATTRIBUTE_NORMAL,
                NULL);
        printf("h = %p\n",h);

        while(ReadFile(h,&ch,1,&dummy,NULL))
        {
                printf("%c",ch);
        }

        printf("end %d\n",GetLastError());
}

Automation

It is possible to run Mini-FIX unattended using a command line parameter specifying a batch script. See below for example.

Tag special values

Tag value Description
$ASKAsk user for tag value
$UNIQUEGenerate unique number
$LASTUNIQUELast generated unique number
$TIMESTAMPFIX timestamp
$<Tag Number>The contents of tag of select transaction if sent from context menu, e.g. $11 to copy ClOrdID.
$DATECurrent UTC date in YYYYMMDD format
$DATE[Days]Current UTC date in YYYYMMDD format with Days offset e.g. $DATE[3]
$RNDNUM[Low,High/Step]Random number e.g. $RNDNUM[10,12/0.25]
$RNDSTR[First,Next,...,Last]Random a random string e.g. $RNDSTR[EUR,USD,JPY]
$SEC[Tag]Use information from selected security e.g. $SEC[48]
$HBINTHeartbeat interval from session tab
$LASTIN[MsgType,Tag]Value of the last received tag on a message of type MsgType
$LASTOUT[MsgType,Tag]Value of the last sent tag on a message of type MsgType

Replaying files / Load testing

It is possible to use Mini-FIX to e.g. send a large amount of orders quickly. The best way to do this is to first make the transactions you want to use and click on save to save them to a file. The file is text and you then open it in an editor and pick out the parts you want. Then cut-and-paste as many as you like.

A problem arises with tags that need to be unique, e.g. ClOrdID. This is solved by replacing those tag values with a special tag value like $UNIQUE and they will be generated on the fly.

(C) Copyright 2009 Ahlqvist