Skip to content

NotificationManager

QuantConnect.Notifications.NotificationManager

NotificationManager(live_mode: bool)

Bases: Object

Local/desktop implementation of messaging system for Lean Engine.

Initialize the messaging system

messages

messages: ConcurrentQueue[Notification]

Public access to the messages

email

email(
    address: str,
    subject: str,
    message: str,
    data: str,
    headers: Any,
) -> bool
email(
    address: str,
    subject: str,
    message: str,
    data: str = ...,
    headers: Dictionary[str, str] = None,
) -> bool

Send an email to the address specified for live trading notifications.

Parameters:

Name Type Description Default
subject str

Subject of the email

required
message str

Message body, up to 10kb

required
data str

Data attachment (optional)

...
address str

Email address to send to, if null will default to users email

required
headers Any | Dictionary[str, str]

Optional email headers to use

None

ftp

ftp(
    hostname: str,
    username: str,
    password: str,
    file_path: str,
    file_content: List[int],
    port: Optional[int] = None,
) -> bool
ftp(
    hostname: str,
    username: str,
    password: str,
    file_path: str,
    file_content: str,
    port: Optional[int] = None,
) -> bool

Send a file to the FTP specified server using password authentication over unsecure FTP.

Parameters:

Name Type Description Default
hostname str

FTP server hostname

required
username str

The FTP server username

required
password str

The FTP server password

required
file_path str

The path to file on the FTP server

required
file_content List[int] | str

The contents of the file

required
port Optional[int]

The FTP server port. Defaults to 21

None

sftp

sftp(
    hostname: str,
    username: str,
    password: str,
    file_path: str,
    file_content: List[int],
    port: Optional[int] = None,
) -> bool
sftp(
    hostname: str,
    username: str,
    password: str,
    file_path: str,
    file_content: str,
    port: Optional[int] = None,
) -> bool
sftp(
    hostname: str,
    username: str,
    private_key: str,
    private_key_passphrase: str,
    file_path: str,
    file_content: List[int],
    port: Optional[int] = None,
) -> bool
sftp(
    hostname: str,
    username: str,
    private_key: str,
    private_key_passphrase: str,
    file_path: str,
    file_content: str,
    port: Optional[int] = None,
) -> bool

Signature descriptions:

  • Send a file to the FTP specified server using password authentication over SFTP.

  • Send a file to the FTP specified server using password authentication over SFTP using SSH keys.

Parameters:

Name Type Description Default
hostname str

FTP server hostname

required
username str

The FTP server username

required
password Optional[str]

The FTP server password

None
file_path str

The path to file on the FTP server

required
file_content List[int] | str

The contents of the file

required
port Optional[int]

The FTP server port. Defaults to 21

None
private_key Optional[str]

The private SSH key to use for authentication

None
private_key_passphrase Optional[str]

The optional passphrase to decrypt the private key.

None

web

web(address: str, data: Any, headers: Any) -> bool
web(
    address: str,
    data: Any = None,
    headers: Dictionary[str, str] = None,
) -> bool

Signature descriptions:

  • Place REST POST call to the specified address with the specified DATA. Python overload for Headers parameter.

  • Place REST POST call to the specified address with the specified DATA.

Parameters:

Name Type Description Default
address str

Endpoint address

required
data Any

Data to send in body JSON encoded

None
headers Any | Dictionary[str, str]

Optional headers to use

None

sms

sms(phone_number: str, message: str) -> bool

Send an SMS to the phone number specified

Parameters:

Name Type Description Default
phone_number str

Phone number to send to

required
message str

Message to send

required

telegram

telegram(id: str, message: str, token: str = None) -> bool

Send a telegram message to the chat ID specified, supply token for custom bot. Note: Requires bot to have chat with user or be in the group specified by ID.

Parameters:

Name Type Description Default
id str

Chat or group ID to send message to

required
message str

Message to send

required
token str

Bot token to use for this message

None