Skip to content

Mismatch method call and method displayed. #31

Description

@Scrier

I am using simplefix version 1.0.14. And it gives me error calling get with the nth parameter.

    Traceback (most recent call last):
      File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 954, in _bootstrap_inner
        self.run()
      File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 892, in run
        self._target(*self._args, **self._kwargs)
      File "/Users/recapital/Git/tt-fix/client.py", line 59, in run
        self._reader.on_message(msg)
      File "/Users/recapital/Git/tt-fix/message_handler.py", line 31, in on_message
        self.handle_logon(message)
      File "/Users/recapital/Git/tt-fix/message_handler.py", line 39, in handle_logon
        logon.decode(message)
      File "/Users/recapital/Git/tt-fix/tt_messages.py", line 9517, in decode
        if (val := message.get(FIELD_ENCRYPT_METHOD, nth)) is not None:
    TypeError: <lambda>() takes 1 positional argument but 2 were given

Here is the code called:

    def decode(self, message: FixMessage, nth: int = 1):
        if (val := message.get(FIELD_ENCRYPT_METHOD, nth)) is not None:
            self.encrypt_method = EncryptMethod(int(val))

Here is the field constant:

FIELD_ENCRYPT_METHOD = b'98'

And here is the get method in simplefix:

    def get(self, tag, nth=1):
        """Return n-th value for tag.

        :param tag: FIX field tag number.
        :param nth: Index of tag if repeating, first is 1.
        :return: None if nothing found, otherwise value matching tag.

        Defaults to returning the first matching value of 'tag', but if
        the 'nth' parameter is overridden, can get repeated fields."""

        tag = fix_tag(tag)
        nth = int(nth)

        for t, v in self.pairs:
            if t == tag:
                nth -= 1
                if nth == 0:
                    return v

        return None

It works if I don't pass the nth parameter, but providing this (that I have to due to repetitions) gives this weird error.

Message that I received before the decode error.
8=FIX.4.4|9=00080|35=A|49=NOTHING|56=CAPITALAS_MD|34=1|52=20210622-13:59:02.752|98=0|108=30|141=Y|10=085

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions