-1

I just started trying to connect to my broker through the FIX protocol.

The broker gave me:

  • an IP:port address to connect to
  • a "sendercompid"
  • a "targetcompid"
  • a password

I would like, as a first test, simply send a logon message to the broker and hopefully receive a message back from it. I would have thought this should be possible with a simple, small python script?

(ie im not interested in installing a fully fledge python engine / or use wrapper for c++ language such as quickfix)

edit: to be more precise: I found on SO example of doing (or trying) such thing in PHP, for instance:

$fp = fsockopen($host, $port, $errno, $errstr, 3.0);

if ($fp)
{
    $request = "8=FIX.4.49=11235=A49=SENDER56=RECEIVER34=152=20130921-18:52:4898=0108=30141=Y553=user554=pass10=124";

    echo $request;

    fwrite($fp, "GET / HTTP/1.0\r\n" .
        "Host: $host\r\n".
        "Connection: close\r\n".
        "Content-Length: " . strlen($request) . "\r\n" .
        "\r\n" .
        $request);

    stream_set_timeout($fp, 2, 0);

    $response = '';
    while (!feof($fp))
    {
        $response .= fread($fp, 1024);
    }

    print "Response: ".$response . "<BR>\n";
    fclose($fp);
}

Do you know which library i can use to simply communicate (ie send/retrieve) message to the FIX server in the same fashion in python?

jim jarnac
  • 4,804
  • 11
  • 51
  • 88
  • And what have you tried so far? SO is not here for writing you code. It's for helping you with code you wrote. – Avihoo Mamka Jul 07 '16 at 07:18
  • I am working with a developper (ie not me doing the code). But we are both newbies to those tasks and basically stuck on the first step: Is there a python library to send message to an ip adress and retrieve response from it? I've been trying to dig in the quickfix lib to extract the code where they are doing that but couldnt find it. Some simple fundamental understanding how that works from you guys would help.Thank you – jim jarnac Jul 07 '16 at 07:23
  • I wouldn't bother going down this road - it sounds like you're trying to write your own FIX engine, which is an enormous can of worms - different versions, data dictionaries, heartbeating, resends, etc. It's a fun exercise, but not for a produciton system. – dsolimano Jul 07 '16 at 20:44
  • Also FIX isn't HTTP based, so not sure why you're sending a HTTP header? – dsolimano Jul 07 '16 at 20:45
  • Thank you dsolimano. My problem with quickfix is that it is quite a vast and messy library... With my system i only want (for starter) to do simple tasks that dont need to be low latency (ie simply connect, heartbeat and monitor price for a handful of symbols). I also know what my broker library is so i wouldn't need to handle multiple versions of FIX. I think i found what i was looking for which is basically to connect with the python socket module. The fixlib is ok quite interesting i find, being much more understandable than the quickfix. – jim jarnac Jul 07 '16 at 22:25
  • There is message sequencing, delivery, integrity, etc. tasks to perform. There are broker specific messages and procedures. There are integration tests that go well beyond basic use. In short, you have a very long way to go... Start by reviewing the FIX Protocol specs. But I would say just use an open source lib for your target lang. – BAR Dec 31 '16 at 02:40

2 Answers2

2

Well, there's no standard python library for that.

You mentioned quickfix, what is a big project that seems maintained, and has documentation.

Looking for other third-party libraries, there is a smaller one, yet only for python2.6 or 2.7, named fixlib and currently hosted on github (the PyPI and bitbucket versions seem to be abandoned; the github version has been active 6 months ago). Major inconvenient: there is no documentation.

Looking at the code of these two libraries shows they are not exactly "small", so if you don't want to use any of them, as you will certainly have to rewrite similar code from scratch, you'd better forget about a "simple and small python script".

zezollo
  • 4,606
  • 5
  • 28
  • 59
2

If you want to do a test in FIX protocol over a FIX connection you can try using the FIXRobot. FIXRobot allows to easily write the tests in python.

heapuser
  • 331
  • 1
  • 3
  • 5