Skip to content

DefaultConnectionHandler

QuantConnect.Brokerages.DefaultConnectionHandler

Bases: Object, IConnectionHandler

A default implementation of IConnectionHandler which signals disconnection if no data is received for a given time span and attempts to reconnect automatically.

connection_lost

connection_lost: _EventContainer[
    Callable[[Object, EventArgs], Any], Any
]

Event that fires when a connection loss is detected

connection_restored

connection_restored: _EventContainer[
    Callable[[Object, EventArgs], Any], Any
]

Event that fires when a lost connection is restored

reconnect_requested

reconnect_requested: _EventContainer[
    Callable[[Object, EventArgs], Any], Any
]

Event that fires when a reconnection attempt is required

maximum_idle_time_span

maximum_idle_time_span: timedelta

The elapsed time with no received data after which a connection loss is reported

minimum_seconds_for_next_reconnection_attempt

minimum_seconds_for_next_reconnection_attempt: int

The minimum time in seconds to wait before attempting to reconnect

maximum_seconds_for_next_reconnection_attempt

maximum_seconds_for_next_reconnection_attempt: int

The maximum time in seconds to wait before attempting to reconnect

connection_id

connection_id: str

The unique Id for the connection

is_connection_lost

is_connection_lost: bool

Returns true if the connection has been lost

dispose

dispose() -> None

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

enable_monitoring

enable_monitoring(is_enabled: bool) -> None

Enables/disables monitoring of the connection

Parameters:

Name Type Description Default
is_enabled bool

True to enable monitoring, false otherwise

required

initialize

initialize(connection_id: str) -> None

Initializes the connection handler

Parameters:

Name Type Description Default
connection_id str

The connection id

required

keep_alive

keep_alive(
    last_data_received_time: Union[datetime, date],
) -> None

Notifies the connection handler that new data was received

Parameters:

Name Type Description Default
last_data_received_time Union[datetime, date]

The UTC timestamp of the last data point received

required

on_connection_lost

on_connection_lost() -> None

Event invocator for the connection_lost event

This codeEntityType is protected.

on_connection_restored

on_connection_restored() -> None

Event invocator for the connection_restored event

This codeEntityType is protected.

on_reconnect_requested

on_reconnect_requested() -> None

Event invocator for the reconnect_requested event

This codeEntityType is protected.