Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting fields from quickfix message

I am using quickfix with python. Looking at the doc page here tells us how to get fields. Say a message = fix.message (with quickfix as fix) comes in from the counterparty. I can get the 35 (MsgType) field by calling

message.getHeader().getField(fix.MsgType())

which returns, for example, 35=X.

My question is: is there any method which just returns X? Or do I have to slice everything (like 35=X[3:], which returns X) and know the length of all the strings therefore?

like image 477
Wapiti Avatar asked Oct 12 '15 20:10

Wapiti


2 Answers

The answer is to get the field by first calling message.getHeader().getField(fix.MsgType()) then get the value by calling fix.MsgType().getValue().

like image 92
Wapiti Avatar answered Oct 12 '22 23:10

Wapiti


I use a little util function

def get_field_value(self, fobj, msg):
    if msg.isSetField(fobj.getField()):
        msg.getField(fobj)
        return fobj.getValue()
    else:
        return None

that I call like this

clordid = get_field_value(fix.ClOrdID(), message)

for header fields, would look like this

def get_header_field_value(self, fobj, msg):
    if msg.getHeader().isSetField(fobj.getField()):
        msg.getHeader().getField(fobj)
        return fobj.getValue()
    else:
        return None
like image 26
shaz Avatar answered Oct 13 '22 00:10

shaz