module connection
Abstract connection module.
class ConnectionState
Connection status enum.
class ConnectionRole
Role of the connection INITIATOR / ACCEPTOR.
class AsyncFIXConnection
AsyncFIX bidirectional connection.
Attributes:
connection_state
: Current connection_stateconnection_role
: Current connection_role ACCEPTOR | INITIATORlog
: logger
method __init__
__init__(
protocol: FIXProtocolBase,
sender_comp_id: str,
target_comp_id: str,
journaler: Journaler,
host: str,
port: int,
heartbeat_period: int = 30,
logger: Logger | None = None
)
AsyncFIX bidirectional connection.
Args:
protocol
: FIX protocolsender_comp_id
: initiator SenderCompIDtarget_comp_id
: acceptor TargetCompIDjournaler
: fix messages journaling enginehost
: endpoint hostport
: endpoint portheartbeat_period
: heartbeat interval in secondslogger
: logger instance (by default logging.getLogger())start_tasks
: True - starts socket/heartbeat asyncio tasks, False - no tasks (this is useful in debugging / testing)
property connection_role
Current connection role.
property connection_state
Current connection state.
property heartbeat_period
Current connection heartbeat period in seconds.
property protocol
Underlying FIXProtocolBase of a connection.
method connect
connect()
Transport initialization method.
method disconnect
disconnect(disconn_state: ConnectionState, logout_message: str = None)
Disconnect session and closes the socket.
Args:
disconn_state
: connection state after disconnectionlogout_message
: if not None, sends Logout() message to peer with (58=logout_message)
method heartbeat_timer_task
heartbeat_timer_task()
Heartbeat watcher task.
method on_connect
on_connect()
(AppEvent) Underlying socket connected.
method on_disconnect
on_disconnect()
(AppEvent) Underlying socket disconnected.
method on_logon
on_logon(is_healthy: bool)
(AppEvent) Logon(35=A) received from peer.
Args:
is_healthy
: True - if connection_state is ACTIVE
method on_logout
on_logout(msg: FIXMessage)
(AppEvent) Logout(35=5) received from peer.
Args:
msg
: Logout(35=5) FIXMessage
method on_message
on_message(msg: FIXMessage)
(AppEvent) Business message was received.
Typically excludes session messages
Args:
msg
: generic incoming FIXMessage
method on_state_change
on_state_change(connection_state: ConnectionState)
(AppEvent) On ConnectionState change.
Args:
connection_state
: new connection state
method reset_seq_num
reset_seq_num()
Resets session and journal seq nums to 1.
method send_msg
send_msg(msg: FIXMessage)
Sends message to the peer.
Args:
msg
: fix message
Raises:
FIXConnectionError
: raised if connection state does not allow sending
method send_test_req
send_test_req()
Sends TestRequest(35=1) and sets TestReqID for expected response from peer.
Raises:
FIXConnectionError
: if another TestRequest() is pending
method should_replay
should_replay(historical_replay_msg: FIXMessage) → bool
(AppLevel) Checks if historical_replay_msg from Journaler should be replayed.
Args:
historical_replay_msg
: message from Journaler log
Returns: True - replay, False - msg skipped (replaced by SequenceReset(35=4))
method socket_read_task
socket_read_task()
Main socket reader task (decode raw messages and calls _process_message).
This file was automatically generated via lazydocs.