trade29.sc.SCBridge.subscribe_to_market_depth#
- SCBridge.subscribe_to_market_depth(key: str, number_of_levels: int = 5, include_pulling_stacking: bool = False, update_frequency: int = -1, include_market_by_order=False) int #
Subscribes to constant snapshots of market depth data from chart with study with given key.
This method returns an integer request_id that can be used to filter the bridge’s response queue to market depth data from the corresponding chart.
- Parameters:
- keystr
Key that matches the key given to the target Study in SierraChart.
- number_of_levelsint, default 5
The number of levels of market depth data to request.
- include_pulling_stackingbool, default False
Whether or not to include columns for pulling/stacking data.
- 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.
- include_market_by_orderbool, default False
Whether or not to include columns for market by order data. Market by order needs to be enabled in Sierra Charts global settings for this to work. Refer to step 1 of the Sierra Chart guide for how to do this.
- 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 MarketDepthResponse. It can be observed as a dataframe by calling
response.as_df()
where a dataframe with columns for Side, Price, BidVolume, AskVolume, BidPullingStacking, AskPullingStacking, and MBO will be given.
Examples
from trade29.sc.bridge import SCBridge bridge = SCBridge() request_id = bridge.subscribe_to_market_depth('xx') response_queue = bridge.get_response_queue() while True: msg = response_queue.get() if msg.request_id == request_id: msg.as_df()