Exemplo n.º 1
0
    def get_asset_metrics(
        self,
        assets: Union[List[str], str],
        metrics: Union[List[str], str],
        frequency: Optional[str] = None,
        page_size: Optional[int] = None,
        paging_from: Optional[Union[PagingFrom, str]] = None,
        start_time: Optional[Union[datetime, date, str]] = None,
        end_time: Optional[Union[datetime, date, str]] = None,
        start_height: Optional[int] = None,
        end_height: Optional[int] = None,
        start_inclusive: Optional[bool] = None,
        end_inclusive: Optional[bool] = None,
        timezone: Optional[str] = None,
    ) -> DataCollection:
        """
        Returns asset metrics books for specified assets, metrics, date range and frequency.

        :param assets: list of asset names
        :param metrics: list of metric names
        :param frequency: frequency of the returned timeseries, for e.g 1s, 1b, 1d, etc.
        :param page_size: number of items returned per page,
        typically you don't want to change this parameter unless you are interested in a first retuned item only.
        :param paging_from: Defines where you want to start receiving items from, 'start' or 'end' of the timeseries.
        :param start_time: Start time of the timeseries.
        :param end_time: End time of the timeseries.
        :param start_height: Start block of the timeseries (only applicable when querying with frequency 1b).
        :param end_height: End block of the timeseries (only applicable when querying with frequency 1b).
        :param start_inclusive: Flag to define if start timestamp must be included in the timeseries if present.
        :param end_inclusive: Flag to define if end timestamp must be included in the timeseries if present.
        :param timezone: timezone of the start/end times in db format for example: "America/Chicago".
        Default value is "UTC". For more details check out API documentation page.
        :return: Asset Metrics timeseries.
        """

        params: Dict[str, Any] = {
            "assets": assets,
            "metrics": metrics,
            "frequency": frequency,
            "page_size": page_size or self._page_size,
            "paging_from": paging_from,
            "start_time": start_time,
            "end_time": end_time,
            "start_height": start_height,
            "end_height": end_height,
            "start_inclusive": start_inclusive,
            "end_inclusive": end_inclusive,
            "timezone": timezone,
        }
        return DataCollection(self._get_data, "timeseries/asset-metrics",
                              params)
Exemplo n.º 2
0
    def get_market_candles(
        self,
        markets: Union[List[str], str],
        frequency: Optional[str] = None,
        page_size: Optional[int] = None,
        paging_from: Optional[Union[PagingFrom, str]] = None,
        start_time: Optional[Union[datetime, date, str]] = None,
        end_time: Optional[Union[datetime, date, str]] = None,
        start_inclusive: Optional[bool] = None,
        end_inclusive: Optional[bool] = None,
        timezone: Optional[str] = None,
    ) -> DataCollection:
        """
        Returns market candles for specified markets, frequency and date range.

        :param markets: list of market names
        :param frequency: frequency of the returned timeseries, for e.g 5m, 1h, 1d, etc.
        :param page_size: number of items returned per page,
        typically you don't want to change this parameter unless you are interested in a first retuned item only.
        :param paging_from: Defines where you want to start receiving items from, 'start' or 'end' of the timeseries.
        :param start_time: Start time of the timeseries.
        :param end_time: End time of the timeseries.
        :param start_inclusive: Flag to define if start timestamp must be included in the timeseries if present.
        :param end_inclusive: Flag to define if end timestamp must be included in the timeseries if present.
        :param timezone: timezone of the start/end times in db format for example: "America/Chicago".
        Default value is "UTC". For more details check out API documentation page.
        :return: Market Candles timeseries.
        """

        params: Dict[str, Any] = {
            "markets": markets,
            "frequency": frequency,
            "page_size": page_size or self._page_size,
            "paging_from": paging_from,
            "start_time": start_time,
            "end_time": end_time,
            "start_inclusive": start_inclusive,
            "end_inclusive": end_inclusive,
            "timezone": timezone,
        }
        return DataCollection(self._get_data, "timeseries/market-candles",
                              params)