trade29.sc.SCBridge.subscribe_to_time_and_sales#

SCBridge.subscribe_to_time_and_sales(key: str) int#

Subscribes to time and sales for chart with given key. The initial response returns all currently available records in the time and sales history on SC side and then starts to receive incremental updates as new records arrive on the datafeed.

This method returns a request_id that can be used to filter the bridge’s response queue to find time and sales data from the corresponding chart.

Parameters:
keyint

A string key that matches the key given to the target Study in SierraChart.

Returns:
int

A request ID that can be used to filter the bridge response queue for relevant data. The response will be given as a TimeAndSalesResponse. It can be observed as a dataframe by calling response.as_df() where a pandas.DataFrame with columns for DateTime and TimeAndSales will be given.

Examples

from trade29.sc.bridge import SCBridge

bridge = SCBridge()

request_id = bridge.subscribe_to_time_and_sales('xx')

response_queue = bridge.get_response_queue()

while True:

    msg = response_queue.get()

    if msg.request_id == request_id:
        msg.as_df()