Giter VIP home page Giter VIP logo

pyfixmsg's People

Contributors

bingenito avatar canbascilms avatar francoisverbeek avatar johnchiotis avatar kelliott55 avatar raoyitao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyfixmsg's Issues

If component tag is located inside group, parsing of raw message works incorrect

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

ValueError when encountering XML comments (using lxml)

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>'

Could not pip install?

I could not pip install pyfixmsg on MacOS M1. Not sure if it is about the OS, architecture, or the library itself

Parsing works incorrect, if repeated group started with other rgroup

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'}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.