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?
The answer is to get the field by first calling message.getHeader().getField(fix.MsgType())
then get the value by calling fix.MsgType().getValue()
.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With