morganstanley / pyfixmsg Goto Github PK
View Code? Open in Web Editor NEWpyfixmsg is a library for parsing, manipulating and serialising FIX messages, primarily geared towards testing.
License: Apache License 2.0
pyfixmsg is a library for parsing, manipulating and serialising FIX messages, primarily geared towards testing.
License: Apache License 2.0
The spec has the following message:
<message name="QuoteRequest" msgtype="R" msgcat="app">
<field name="QuoteReqID" required="Y" />
<group name="NoRelatedSym" required="Y">
<component name="Instrument" required="Y" />
<field name="QuoteRequestType" required="N" />
<field name="OrderQty" required="Y" />
</group>
</message>
and the component looks like:
<component name="Instrument">
<field name="Symbol" required="Y" />
<field name="Product" required="Y" />
</component>
when trying to parse the raw message, I see this
>>> messages[2].strip()
b'8=FIX.4.3\x019=151\x0135=R\x0134=3\x0149=9222237_TEST\x0150=FX\x0152=20200616-18:25:26\x0156=SAXOQ
UOTE_TEST\x01131=1\x01146=3\x0155=AUD/CA\x01460=4\x01303=2\x0155=AUD/CHF\x01460=4\x01303=2\x0155=EUR
/ZAR\x01460=4\x01303=2\x0110=193\x01'
>>>
>>> codec.parse(messages[2].strip(), separator=chr(1))
{8: 'FIX.4.3', 9: '151', 35: 'R', 34: '3', 49: '9222237_TEST', 50: 'FX', 52: '20200616-18:25:26', 56
: 'SAXOQUOTE_TEST', 131: '1', 146: [{55: 'AUD/CA'}], 460: '4', 303: '2', 55: 'EUR/ZAR', 10: '193'}
>>>
Only field "Symbol" has been added into the group
But if I replace the component by the suitable fields like this
<message name="QuoteRequest" msgtype="R" msgcat="app">
<field name="QuoteReqID" required="Y" />
<group name="NoRelatedSym" required="Y">
<field name="Symbol" required="Y" />
<field name="Product" required="Y" />
<field name="QuoteRequestType" required="N" />
<field name="OrderQty" required="Y" />
</group>
</message>
all works as expected
>>> codec2.parse(messages[2].strip(), separator=chr(1))
{8: 'FIX.4.3', 9: '151', 35: 'R', 34: '3', 49: '9222237_TEST', 50: 'FX', 52: '20200616-18:25:26', 56
: 'SAXOQUOTE_TEST', 131: '1', 146: [{55: 'AUD/CA', 460: '4', 303: '2'}, {55: 'AUD/CHF', 460: '4', 30
3: '2'}, {55: 'EUR/ZAR', 460: '4', 303: '2'}], 10: '193'}
>>>
and all fields are placed into the group
Unlike xml.etree.ElementTree.parse(), lxml.etree.parse() reads XML comments and stores them as lxml.etree._Comment objects, with tag == lxml.etree.Comment (the function which creates lxml.etree._Comment objects). This results in the error below:
Traceback (most recent call last):
File "./error_example.py", line 32, in
main()
File "./error_example.py", line 16, in main
spec = FixSpec('FIXFX.xml')
File "../pyfixmsg/reference.py", line 164, in init
(MessageType(e, self) for e in self.tree.findall('messages/message'))}
File "../pyfixmsg/reference.py", line 163, in
self.msg_types = {m.msgtype.encode('ascii'): m for m in
File "../pyfixmsg/reference.py", line 164, in
(MessageType(e, self) for e in self.tree.findall('messages/message'))}
File "../pyfixmsg/reference.py", line 278, in init
self.composition = _extract_composition(element, spec)
File "../pyfixmsg/reference.py", line 198, in _extract_composition
raise ValueError("Could not process element '{}'".format(elem.tag))
ValueError: Could not process element '<built-in function Comment>'
The package works really well for Fix 4.2 and 4.4 which use one single spec file. However Fix above 4.4 uses TransportDataDictionary and AppDataDictionary for two seperate fix spec file as mentioned here http://www.quickfixengine.org/quickfix/doc/html/configuration.html. Is there any plans to support this ?.
I could not pip install pyfixmsg on MacOS M1. Not sure if it is about the OS, architecture, or the library itself
The test below shows the problem:
def test_nested_rgroup_ext(self, spec):
codec = Codec(spec=spec)
msg = b'35=CUS\x0134=3\x01131=some text\x01658=99\x01' \
b'295=2\x01683=2\x01688=1\x01689=1\x01688=2\x01689=2\x01683=1' \
b'\x01688=3\x01689=3\x0110=193\x01'
msg = codec.parse(msg, separator=chr(1))
assert {35: 'CUS',
34: '3',
131: 'some text',
658: '99',
295: [
{683: [{688: '1', 689: '1'}, {688: '2', 689: '2'}]},
{683: [{688: '3', 689: '3'}]}
],
10: '193'} == msg
The actual parsed message look like,
{35: 'CUS', 34: '3', 131: 'some text', 658: '99', 295: [{683: '2'}], 688: '3', 689: '3', 683: '1', 10: '193'}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.