Skip to content

DefaultBrokerageMessageHandler

QuantConnect.Brokerages.DefaultBrokerageMessageHandler

DefaultBrokerageMessageHandler(
    algorithm: IAlgorithm,
    initial_delay: Optional[timedelta] = None,
    open_threshold: Optional[timedelta] = None,
)
DefaultBrokerageMessageHandler(
    algorithm: IAlgorithm,
    job: AlgorithmNodePacket,
    api: IApi,
    initial_delay: Optional[timedelta] = None,
    open_threshold: Optional[timedelta] = None,
)

Bases: Object, IBrokerageMessageHandler

Provides a default implementation o IBrokerageMessageHandler that will forward messages as follows: Information -> IResultHandler.Debug Warning -> IResultHandler.Error && IApi.SendUserEmail Error -> IResultHandler.Error && IAlgorithm.RunTimeError

Initializes a new instance of the DefaultBrokerageMessageHandler class

Parameters:

Name Type Description Default
algorithm IAlgorithm

The running algorithm

required
initial_delay Optional[timedelta]
None
open_threshold Optional[timedelta]

Defines how long before market open to re-check for brokerage reconnect message

None
job Optional[AlgorithmNodePacket]

The job that produced the algorithm

None
api Optional[IApi]

The api for the algorithm

None

handle_message

handle_message(message: BrokerageMessageEvent) -> None

Handles the message

Parameters:

Name Type Description Default
message BrokerageMessageEvent

The message to be handled

required

handle_order

handle_order(
    event_args: NewBrokerageOrderNotificationEventArgs,
) -> bool

Handles a new order placed manually in the brokerage side

Parameters:

Name Type Description Default
event_args NewBrokerageOrderNotificationEventArgs

The new order event

required

Returns:

Type Description
bool

Whether the order should be added to the transaction handler.