testplan.common.utils.sockets.fix package

Submodules

testplan.common.utils.sockets.fix.client module

Fix TCP client module.

class testplan.common.utils.sockets.fix.client.Client(msgclass, codec, host, port, sender, target, version='FIX.4.2', sendersub=None, interface=None, logger=None, tls_config: Optional[testplan.common.utils.sockets.tls.TLSConfig] = None)[source]

Bases: object

A Basic FIX Client Connects to a FIX server via the FIX session protocol.

address

Returns the host and port information of socket.

close()[source]

Close the connection.

connect()[source]

Transport connection.

rawsend(msg)[source]

Raw send (without stamping any session tags).

rawsend_tsp(msg)[source]

Raw send (without stamping any session tags).

receive(timeout=30)[source]

Receive a FIX message.

send(msg)[source]

Regular send.

sendlogoff(custom_tags=None)[source]

Send logoff message.

sendlogon(custom_tags=None)[source]

Send logon message.

testplan.common.utils.sockets.fix.parser module

FIX messages parser.

class testplan.common.utils.sockets.fix.parser.FixParser[source]

Bases: object

A barebones FIX parser

class State[source]

Bases: enum.Enum

State enum for FixParser

NotStarted = 0
ReadingBody = 3
ReadingCheckSum = 4
ReadingHeader = 1
ReadingLength = 2
consume(buf)[source]

Consume buf and return the number of bytes to read

testplan.common.utils.sockets.fix.parser.tagsoverride(msg, override)[source]

Merge in a series of tag overrides, with None signaling deletes of the original messages tags

testplan.common.utils.sockets.fix.utils module

Utils for FIX.

testplan.common.utils.sockets.fix.utils.utc_timestamp()[source]
Returns:a UTCTimestamp (see FIX spec)
Return type:str

testplan.common.utils.sockets.fix.server module

Fix TCP server module.

class testplan.common.utils.sockets.fix.server.ConnectionDetails(connection, name=None, queue=None, in_seqno=1, out_seqno=1)[source]

Bases: object

Contains all information required for each connection to the server

class testplan.common.utils.sockets.fix.server.Server(msgclass, codec, host='localhost', port=0, version='FIX.4.2', logger=None, tls_config: Optional[testplan.common.utils.sockets.tls.TLSConfig] = None)[source]

Bases: object

A server that can send and receive FIX messages over the FIX session protocol. Supports multiple connections.

The server stamps every outgoing message with the senderCompID and targetCompID for the corresponding connection.

active_connections()[source]

Returns a list of currently active connections

Returns:List of active connection names (each a tuple of sender and target)
Return type:list of tuple of str and str
flush()[source]

Flush the receive queues.

host

Input host provided.

ip

IP retrieved from socket.

is_connection_active(conn_name)[source]

Checks whether the given connection is currently active.

Parameters:conn_name (tuple of str and str) – Connection name to be checked if active
Returns:True if the given connection is active. False otherwise
Return type:bool
port

Port retrieved after binding.

receive(conn_name=(None, None), timeout=30)[source]

Receive a FIX message from the given connection.

The connection name defaults to (None, None). In this case, the server will try to find the one and only available connection. This will fail if there are more connections available or if the initial connection is no longer active.

Parameters:
  • conn_name (tuple of str and str) – Connection name to receive message from
  • timeout (int) – timeout in seconds
Returns:

Fix message received

Return type:

FixMessage

send(msg, conn_name=(None, None))[source]

Send the given Fix message through the given connection.

The message will be enriched with session tags and sequence numbers. The connection name - (sender, target) - defaults to (None, None). In this case, the server will try to find the one and only available connection. This will fail if there are more connections available or if the initial connection is no longer active.

Parameters:
  • msg (FixMessage) – Message to be sent.
  • conn_name (tuple of str and str) – Connection name to send message to. This is the tuple (sender id, target id)
Returns:

Fix message sent

Return type:

FixMessage

start(timeout=30)[source]

Start the FIX server.

stop()[source]

Close the connection.

Module contents