Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change string into a QuickFix message?

I am trying to read my FIX logs and to parse them with the cracker that I wrote in python. However, this does not work because in my cracker I have calls like message.getHeader() which are QuickFix methods. They unsurprisingly return an error:

AttributeError: 'str' object has no attribute 'getHeader'

The logs are all strings, but the cracker is embedded within QuickFix and so uses QF methods. Is there any way to take the string and transform it into a QF message so I can just call crack(message) on it, or do I have to rewrite my cracker for this special case?

like image 592
Wapiti Avatar asked Mar 16 '23 05:03

Wapiti


2 Answers

The following code should work.

import quickfix as qfix
import quickfix44 as q44
message = q44.ExecutionReport()
message.setString(input_string, True, qfix.DataDictionary('CustomDictionary.xml'))

'message' object will be updated in place and you should be able to use it as a quickfix Message object

like image 156
smart.aleck Avatar answered Mar 25 '23 08:03

smart.aleck


The way that I do it in C# is to read tag 35 to see what message type I need to create. Then, I create that message type, and use the setString method to populate it. Something like this:

if (line.Contains("35=8"))
{
    message = new QuickFix44.ExecutionReport();
}
else if(line.Contains("35=AS"))
{
    message = new QuickFix44.AllocationReport();
}
 . . . . and so on

message.setString(line, true, dictionary);
application.fromApp(message, sessionId); //The cracker takes care of it from here

where dictionary is my data dictionary. Is a similar method available in the Python bindings?

like image 36
dsolimano Avatar answered Mar 25 '23 06:03

dsolimano