trade29.sc.SCBridge.get_chart_data#

SCBridge.get_chart_data(key: str, sg_data: list[SubgraphQuery] = [], base_data: list[SCBaseData] = [], historical_bars: int = 10, include_live_bar: bool = True, include_volume_by_price: bool = False, volume_by_price_include_empty_price_levels: bool = False) ChartDataResponse#

Gets base or subgraph data from a chart

Retrieves the current and historical data for a chart with the given key as a ChartDataResponse once.

Parameters:
keyint

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

sg_datalist of SubgraphQuery, default []

A list of studies’ subgraphs to get as a list of SubgraphQuerys.

base_datalist of SCBaseData, default [constants.SCBaseData.SC_LAST]

A list of base SC data to get.

historical_barsint, default 10

Amount of historical bars to get along with current bar.

include_live_barbool, default True

Whether or not to include the live bar.

include_volume_by_pricebool, default False

Whether or not to include the volume by price data. Note that Maintain Volume At Price Data Enabled must be set to Yes in the SCdX study settings.

volume_by_price_include_empty_price_levelsbool, default False

Whether or not to include vbp entries for prices with no volume.

Returns:
ChartDataResponse

A response with all the requested data. The ChartDataResponse can be converted to a pandas DataFrame with the method ChartDataResponse.as_df(). The resulting dataframe has columns DateTime, BarIndex, IsBarClosed, and then the requested sg_data and base data.

Examples

from trade29.sc import SCBridge, constants

bridge = SCBridge()
# by default will return a dataframe with the last 10 bars of SC_LAST base data.
response = bridge.get_chart_data('xx', base_data=[constants.SCBaseData.SC_LAST])

df = response.as_df()