Ejemplo n.º 1
0
    def get_data_coordinate(
            self,
            measure: DataMeasure,
            dimensions: Optional[DataDimensions] = None,
            frequency: DataFrequency = DataFrequency.ANY
    ) -> BaseDataCoordinate:
        """
        Get data coordinate

        :param measure: measure to get as series
        :param dimensions: dimensions to query (e.g. tenor)
        :param frequency: data frequency to query
        :return: DataCoordinate

        **Usage**

        Get a given data coordinate for the asset and measure

        **Examples**

        Get close price series:

        >>> from gs_quant.markets.securities import SecurityMaster
        >>> from gs_quant.data import DataMeasure
        >>>
        >>> gs = SecurityMaster.get_asset("GS", AssetIdentifier.TICKER)
        >>> gs.get_data_coordinate(DataMeasure.CLOSE_PRICE)

        **See also**

        :class:`DataMeasure`

        """
        asset_id = self.get_identifier(AssetIdentifier.MARQUEE_ID)
        data_providers = GsDataApi.get_data_providers(asset_id)
        available = data_providers.get(measure.value, {})

        daily_dataset_id = available.get(DataFrequency.DAILY)
        rt_dataset_id = available.get(DataFrequency.REAL_TIME)

        dimensions = dimensions or {}
        dimensions['assetId'] = asset_id

        if frequency == DataFrequency.DAILY:
            return DataCoordinate(dataset_id=daily_dataset_id,
                                  measure=measure,
                                  dimensions=dimensions)
        if frequency == DataFrequency.REAL_TIME:
            return DataCoordinate(dataset_id=rt_dataset_id,
                                  measure=measure,
                                  dimensions=dimensions)
Ejemplo n.º 2
0
    def get_data_coordinate(self,
                            measure: Union[DataMeasure, str],
                            dimensions: Optional[DataDimensions] = None,
                            frequency: DataFrequency = DataFrequency.DAILY,
                            availability=None) -> DataCoordinate:
        id_ = self.get_marquee_id()
        dimensions = dimensions or {}
        dimensions[self.data_dimension] = id_
        measure = measure if isinstance(measure, str) else measure.value
        available: Dict = GsDataApi.get_data_providers(id_, availability).get(measure, {})

        if frequency == DataFrequency.DAILY:
            daily_dataset_id = available.get(DataFrequency.DAILY)
            return DataCoordinate(dataset_id=daily_dataset_id, measure=measure, dimensions=dimensions,
                                  frequency=frequency)
        if frequency == DataFrequency.REAL_TIME:
            rt_dataset_id = available.get(DataFrequency.REAL_TIME)
            return DataCoordinate(dataset_id=rt_dataset_id, measure=measure, dimensions=dimensions, frequency=frequency)