Monday, January 23, 2012

Quickfix

1. CFLAGS="-march=pentium4 -O2 -pipe -fomit-frame-pointer -msse2 -mfpmath=sse -s" CXXFLAGS="-march=pentium4 -O2 -pipe -msse2 -mfpmath=sse -s" ./configure --enable-static --with-mysql=/usr
2. make -j2
3. create quickfix mysql user
4. quickfix/src/sql/mysql/create.sh quickfix
5. CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)

INCLUDE_DIRECTORIES( include )
LINK_DIRECTORIES( ext_libs )

ADD_EXECUTABLE( main main.cpp )

TARGET_LINK_LIBRARIES( main pthread xml2 z libquickfix.a )
6. main.cpp
#include <cstdio>

#include "quickfix/FileStore.h"
#include "quickfix/NullStore.h"

#include "quickfix/FileLog.h"
#include "quickfix/Session.h"
#include "quickfix/SocketAcceptor.h"
#include "quickfix/SocketInitiator.h"
#include "quickfix/SessionSettings.h"
#include "quickfix/Application.h"

#include "quickfix/SessionID.h"

namespace FIX
{

class MyApplication : public FIX::Application
{
public:

~MyApplication()
{
    puts("MyApp dtor called");
};

void onCreate( const SessionID& )
{
    puts("MyApp onCreate called");
};

void onLogon( const SessionID& )
{
    puts("MyApp onLogon called");
};

void onLogout( const SessionID& )
{
    puts("MyApp onLogout called");
};

void toAdmin( Message&, const SessionID& )
{
    puts("MyApp toAdmin called");
};

void toApp( Message&, const SessionID& )
    throw( DoNotSend )
{
    puts("MyApp toApp called");
};

void fromAdmin( const Message&, const SessionID& )
    throw( FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon )
{
    puts("MyApp fromAdmin called");
};

void fromApp( const Message&, const SessionID& )
    throw( FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType )
{
    puts("MyApp fromApp called");
};

}; /* class */

} /* namespace FIX */

int main(int argc, char **argv)
{
    printf("hello world\n");


    try
    {
      if (argc < 2)
      {
          return 1;
      }

      std::string fileName = argv[1];

      FIX::SessionSettings settings(fileName);

      FIX::MyApplication application;

      FIX::FileStoreFactory storeFactory(settings);
      FIX::FileLogFactory logFactory(settings);

      FIX::SocketInitiator initiator
        (application, storeFactory, settings, logFactory /*optional*/);
      initiator.start();
      // while( condition == true ) { do something; }

      sleep(5);

      initiator.stop();

    }
    catch(FIX::ConfigError& e)
    {
      std::cout << e.what();
            return 1;
    }



    return 0;
}

7. cmake . ; make
8. app.ini
 # default settings for sessions
[DEFAULT]
#DefaultApplVerID=FIX.4.4
ConnectionType=initiator
ReconnectInterval=60
SenderCompID=hhhhhhhhhhh
FileStorePath=logs
FileLogPath=logs
MySQLLogUser=bbbbbbbbb
MySQLLogPassword=aaaaaaaaaaa
#SocketUseSSL=Y
TimeZone=Europe
StartTime=00:00:00
EndTime=23:59:59

# session definition
[SESSION]
# inherit ConnectionType, ReconnectInterval and SenderCompID from default
BeginString=FIX.4.4
TargetCompID=MBT
StartTime=12:30:00
EndTime=23:30:00
HeartBtInt=20
# non-SSL
SocketConnectPort=xyz
# SSL
#SocketConnectPort=xyz
SocketConnectHost=111.222.333.444
DataDictionary=spec/FIX44.xml

9. emerge stunnel

No comments:

Post a Comment