Alerts
ibc.rest.alert.Alerts
Client for managing account alerts via the Interactive Brokers API.
__init__(ib_client, ib_session)
Initializes the Alerts client.
Parameters
ib_client : InteractiveBrokersClient
The InteractiveBrokersClient Python Client.
InteractiveBrokersSession
The IB session handler.
available_alerts(account_id)
Returns Applicant Id with all owner related entities.
Parameters
account_id : str The account ID you want a list of alerts for.
Returns
list[AlertResponse]:
A collection of AlertResponse resources.
Usage
>>> alerts_service = ibc_client.alerts
>>> alerts_service.available_alerts(
account_id=ibc_client.account_number
)
mta_alerts()
Returns the Mobile Trading Assistant Alert.
Overview
Each login user only has one mobile trading assistant (MTA) alert with it's own unique tool id. The tool id cannot be changed. When modified a new order Id is generated. MTA alerts can not be created or deleted. If you call delete /iserver/account/:accountId/alert/:alertId, it will reset MTA to default. See here for more information on MTA alerts.
Returns
list:
A collection of MobileTradingAssistantAlert resource.
Usage
>>> alerts_service = ibc_client.alerts
>>> alerts_service.mta_alerts()
create_or_modify_alert(account_id, alert)
Creates a new alert or modifies an existing one.
Overview
Please note here, if alertId isn't set, it will be a new alert creation, otherwise it will modify the existing alert of alertId.
Parameters
account_id : str The account ID for the alert.
dict
The alert definition payload. Include alertId to modify an existing alert.
Returns
dict: An alert creation/modification response resource.
Usage
>>> alerts_service = ibc_client.alerts
>>> alerts_service.create_or_modify_alert(
account_id=ibc_client.account_number,
alert={
"alertName": "Price Alert",
"alertMessage": "AAPL crossed 150",
"conditions": [
{
"type": 1,
"conidex": "265598",
"operator": ">=",
"triggerMethod": "0",
"value": "150"
}
]
}
)
activate_alert(account_id, alert_id, activate=True)
Activates or deactivates an existing alert.
Parameters
account_id : str The account ID that owns the alert.
str
The alert ID to activate or deactivate.
bool (optional, Default=True)
Set to True to activate, False to deactivate.
Returns
dict: An alert activation response resource.
Usage
>>> alerts_service = ibc_client.alerts
>>> alerts_service.activate_alert(
account_id=ibc_client.account_number,
alert_id='12345',
activate=True
)
delete_alert(account_id, alert_id)
Deletes an existing alert.
Parameters
account_id : str The account ID that owns the alert.
str
The alert ID to delete.
Returns
dict: An alert deletion response resource.
Usage
>>> alerts_service = ibc_client.alerts
>>> alerts_service.delete_alert(
account_id=ibc_client.account_number,
alert_id='12345'
)
alert_details(alert_id)
Returns the details of a specific alert.
Parameters
alert_id : str The alert ID to retrieve.
Returns
AlertResponse: An alert detail resource.
Usage
>>> alerts_service = ibc_client.alerts
>>> alerts_service.alert_details(alert_id='12345')