DataGrid¶
- class DataGrid(name, rows, columns, *, id_=None, entitlements=None, polling_time=None, sorts=None, filters=None, multiColumnGroups=None, **kwargs)[source]¶
DataGrid is a object for fetching Marquee data and applying processors (functions). DataGrids can be persisted via the DataGrid API and utilized on the Marquee Markets platform.
- Parameters:
name (
str
) – Name of the DataGridrows (
List
[Union
[DataRow
,RowSeparator
]]) – List of DataGrid rows for the gridcolumns (
List
[DataColumn
]) – List of DataGrid columns for the gridid – Unique identifier of the grid
entitlements (
Union
[Entitlements
,Entitlements
,None
]) – Marquee entitlements of the grid for the Marquee Market’s platformsorts (
Optional
[List
[DataGridSort
]]) – Optional list of DataGridSort. Use this if you want to sort your columns.filters (
Optional
[List
[DataGridFilter
]]) – Optional list of DataGridFilter. Use this to filter column’s data.multiColumnGroups (
Optional
[List
[MultiColumnGroup
]]) – Optional list of MultiColumnGroup. Useful to group columns for heatmaps.
Usage
To create a DataGrid, we define two components, rows and columns:
>>> from gs_quant.markets.securities import Asset, AssetIdentifier >>> from gs_quant.data.coordinate import DataMeasure, DataFrequency >>> from gs_quant.analytics.processors import LastProcessor >>> >>> GS = Asset.get("GS UN", AssetIdentifier.BLOOMBERG_ID) >>> AAPL = Asset.get("AAPL UW", AssetIdentifier.BLOOMBERG_ID) >>> rows = [ >>> DataRow(GS), >>> DataRow(AAPL) >>> ] >>> trade_price = DataCoordinate( >>> measure=DataMeasure.TRADE_PRICE, >>> frequency=DataFrequency.REAL_TIME, >>> ) >>> >>> col_0 = DataColumn(name="Name", processor=EntityProcessor(field="short_name")) >>> col_1 = DataColumn(name="Last", processor=LastProcessor(trade_price)) >>> columns = [ col_0, col_1 ] >>> >>> datagrid = DataGrid(name="Example DataGrid", rows=rows, columns=columns) >>> datagrid.initialize() >>> datagrid.poll() >>> print(datagrid.to_frame())
Documentation
Full Documentation and examples can be found here: https://developer.gs.com/docs/gsquant/tutorials/Data/DataGrid/
Methods
- __init__(name, rows, columns, *, id_=None, entitlements=None, polling_time=None, sorts=None, filters=None, multiColumnGroups=None, **kwargs)[source]¶
- add_filter(filter_, index=None)[source]¶
Add a filter to the grid response :param filter_: DataGridFilter :type index:
Optional
[int
] :param index: index of the sort object to be added, defaults to end of filters list :return: None
- add_sort(sort, index=None)[source]¶
Add a sort to the grid response :type sort:
DataGridSort
:param sort: DataGridSort :type index:Optional
[int
] :param index: index of the sort object to be added, defaults to end of sorts list :return: None
- create()[source]¶
Creates a new DataGrid even if the DataGrid already exists. If the DataGrid has already been persisted, the DataGrid id will be replaced with the newly persisted DataGrid. :return: New DataGrid unique identifier
- get_id()[source]¶
Get the unique DataGrid identifier. Will only exists if the DataGrid has been persisted.
- Return type:
Optional
[str
]
- initialize()[source]¶
Initializes the DataGrid.
Iterates over all rows and columns, preparing cell structures. Cells then contain a graph and data queries to leaf processors.
Upon providing data to a leaf, the leaf processor is calculated and propagated up the graph to the cell level.
- Return type:
None
- poll()[source]¶
Poll the data queries required to process this grid. Set the results at the leaf processors
- Return type:
None
- save()[source]¶
Saves the DataGrid. If the DataGrid has already been created, the DataGrid will be updated. If the DataGrid has not been created it will be added to the DataGrid service. :rtype:
str
:return: Unique identifier of the DataGrid
- set_filters(filters)[source]¶
Set the filters parameter of the grid response :type filters:
List
[DataGridFilter
] :param filters: value of grid sorts :return: None
- set_primary_column_index(index)[source]¶
Sets the primary column index which affects which row will expand to fill any additional horizontal space. :type index:
int
:param index: index of the column to make primary :return: None
- set_sorts(sorts)[source]¶
Set the sorts parameter of the grid response :type sorts:
List
[DataGridSort
] :param sorts: value of grid sorts :return: None
- to_frame()[source]¶
Returns the results of the DataGrid data fetching and applied processors. :rtype:
DataFrame
:return: DataFrame of results
Properties
- polling_time¶