module codec

FIX Message encoding / decoding module.


class Codec

Encoding / decoding engine.

Attributes:

  • protocol: FIX protocol
  • SOH: encoded message separator

method __init__

__init__(protocol: FIXProtocolBase)

Codec init.

Args:

  • protocol: FIX protocol used in encoding/decoding

method current_datetime

current_datetime() → str

FIX complaint date-time string (UTC now).


method decode

decode(
    rawmsg: bytes,
    silent: bool = True
) → tuple[FIXMessage | None, int, bytes | None]

Decodes message from socket.

Args:

  • rawmsg: message bytes
  • silent: no errors raised, returns non

Returns: if OK - (FIXMessage, bytes_processed, valid_raw_msg_bytes) if ERR - (None, n_bytes_skip, None)


method encode

encode(msg: FIXMessage, session: FIXSession, raw_seq_num: bool = False) → str

Encodes FIXMessage into serialized message.

Args:

  • msg: generic FIXMessage
  • session: current session (for seq num)
  • raw_seq_num: if True - uses MsgSeqNum from msg

Returns: encoded message (string)

Raises:

  • EncodingError: when failed MsgSeqNum conditions for some types of messages

This file was automatically generated via lazydocs.