trade29.sc.SCBridge.subscribe_to_order_updates#

SCBridge.subscribe_to_order_updates(key: str, order_id: int) int#

Subscribes to updates on an order’s status.

When an order’s status changed, the status of the order will be pushed to the bridge response queue. The status update includes its ID, status code, price1, price2, quantity, and average fill price.

Parameters:
keystr

The key matching the key given to the SC-dX custom study in Sierra Chart.

order_idint

The ID of the order to check.

Returns:
int

Request ID that can be used to filter the bridge response queue for status updates.

Examples

from trade29.sc import SCBridge, constants

bridge = SCBridge()

order = bridge.submit_order('xx', True, 5, order_type = constants.OrderType.LIMIT, price1 = 50)
order_id = order.order_groups[0].parent_id
# Subscribe to updates on the submitted order
request_id = bridge.subscribe_to_order_updates('xx', order_id)

response_queue = bridge.get_response_queue()

while True:
    msg = response_queue.get()

    if msg.request_id == request_id:
        print(msg.order_status_code)

# Cancel the order in Sierra Chart and check that the CANCELLED status code was printed.