trade29.sc.SCBridge.subscribe_to_account_updates#
- SCBridge.subscribe_to_account_updates(key: str, update_frequency: int = -1) int #
Subscribes to constant updates on the account position; including name, balance, currency, and alot more.
Given a key, this method subscribes to information on the account selected in the chart on which the SC-dX study with the matching key is applied. With the returned request id, the bridge’s response queue can be filtered for updates.
- Parameters:
- keystr
The key matching the key given to the SC-dX custom study in Sierra Chart.
- update_frequencyint, default -1
Frequency at which to send updates in milliseconds. Any value less than the chart update frequency will use the chart update frequency.
- Returns:
- int
A request id that can be used to filter the SCBridge’s
get_response_queue()
for account updates in the form ofAccountStatusResponse
.
Examples
from trade29.sc import SCBridge bridge = SCBridge() # Subscribe to updates on the account request_id = bridge.subscribe_to_account_updates(key = 'xx') response_queue = bridge.get_response_queue() while True: msg = response_queue.get() if msg.request_id == request_id: print(f"name: {msg.trade_account}, currency: {msg.currency_code}, cash_bal: {msg.current_cash_balance}")