cryptodatapy.extract ==================== .. py:module:: cryptodatapy.extract Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/cryptodatapy/extract/data_vendors/index /autoapi/cryptodatapy/extract/datarequest/index /autoapi/cryptodatapy/extract/exchanges/index /autoapi/cryptodatapy/extract/getdata/index /autoapi/cryptodatapy/extract/libraries/index /autoapi/cryptodatapy/extract/web/index Classes ------- .. autoapisummary:: cryptodatapy.extract.DataRequest cryptodatapy.extract.GetData Package Contents ---------------- .. py:class:: DataRequest(source: str = 'ccxt', tickers: Union[str, List[str]] = 'btc', quote_ccy: Optional[str] = None, markets: Optional[Union[str, List[str]]] = None, freq: str = 'd', exch: Optional[str] = None, countries: Optional[Union[str, List[str]]] = None, mkt_type: Optional[str] = 'spot', start_date: Optional[Union[str, datetime.datetime, pandas.Timestamp]] = None, end_date: Optional[Union[str, datetime.datetime, pandas.Timestamp]] = None, fields: Union[str, List[str]] = ['close'], tz: Optional[str] = None, cat: Optional[str] = None, trials: Optional[int] = 3, pause: Optional[float] = 0.1, source_tickers: Optional[Union[str, List[str]]] = None, source_markets: Optional[Union[str, List[str]]] = None, source_freq: Optional[str] = None, source_start_date: Optional[Union[str, int, datetime.datetime, pandas.Timestamp]] = None, source_end_date: Optional[Union[str, int, datetime.datetime, pandas.Timestamp]] = None, source_fields: Optional[Union[str, List[str]]] = None) Data request class which contains parameters for data retrieval. .. py:property:: source Returns data source for data request. .. py:property:: tickers Returns tickers for data request. .. py:property:: quote_ccy Returns quote currency for data request. .. py:property:: markets Returns markets for data request. .. py:property:: freq Returns frequency of observations for data request. .. py:property:: exch Returns exchange for data request. .. py:property:: countries Returns country codes for data request. .. py:property:: mkt_type Returns market type for data request. .. py:property:: start_date Returns start date for data request. .. py:property:: end_date Returns end date for data request. .. py:property:: fields Returns fields for data request. .. py:property:: tz Returns timezone for data request. .. py:property:: cat Returns category for data request. .. py:property:: trials Returns number of trials for data request. .. py:property:: pause Returns number of seconds to pause between data requests. .. py:property:: source_tickers Returns tickers for data request in data source format. .. py:property:: source_markets Returns markets for data request in data source format. .. py:property:: source_freq Returns frequency of data request in data source format. .. py:property:: source_start_date Returns start date for data request in data source format. .. py:property:: source_end_date Returns end date for data request in data source format. .. py:property:: source_fields Returns fields for data request in data source format. .. py:method:: get_req(url: str, params: Dict[str, Union[str, int]], headers: Optional[Dict[str, str]] = None) -> Dict[str, Any] Submits get request to API. :param url: Endpoint url for get request. Base urls are stored in DataCredentials. :type url: str :param params: Dictionary containing parameter values for get request. :type params: dict :param headers: Dictionary containing headers for get request. :type headers: dict, optional, default None :returns: **resp** -- Data response in JSON format. :rtype: dict .. py:class:: GetData(data_req: cryptodatapy.extract.datarequest.DataRequest, api_key: Optional[str] = None) Retrieves data from selected data source. .. py:attribute:: data_req .. py:attribute:: api_key :value: None .. py:method:: get_meta(attr: str = None, method: str = None, **kwargs) -> pandas.DataFrame Get metadata. :param attr: 'base_url', 'api_key', 'max_obs_per_call', 'rate_limit'}, default assets Gets the specified attribute or method from the data source object. :type attr: str, {'categories', 'exchanges', 'indexes', 'assets', 'markets', 'market_types', 'fields', 'frequencies', :param method: 'get_fields_info', 'get_frequencies_info', 'get_rate_limit_info', 'get_onchain_tickers_list', 'get_top_mkt_cap_info'} Gets the specified method from the data source object. :type method: str, {'get_exchanges_info', 'get_indexes_info', 'get_assets_info', 'get_markets_info', :param cat: Category for which to return metadata, e.g. 'crypto', 'fx', 'rates', 'macro', etc. :type cat: str, optional, default None :param exch: Name of exchange for which to return metdata, e.g. 'binance', 'ftx', 'kraken', etc. :type exch: str, default 'binance' :param data_type: Type of data for which to return metadata, e.g. 'on-chain', 'market' or 'off-chain'. :type data_type: str, {'market', 'on-chain', 'off-chain'}, default None :param as_dict: Returns attribute metadata as dictionary. :type as_dict: bool, default False :param as_list: Returns attribute metdata as list. :type as_list: bool, default False :returns: **meta** -- Metadata for selected attribute or method. :rtype: Any .. rubric:: Examples >>> data_req = DataRequest(source='ccxt') >>> GetData(data_req).get_meta(attr='exchanges') '['aax', 'alpaca', 'ascendex', 'bequant', 'bibox', 'bigone', 'binance', 'binancecoinm', 'binanceus', ...]' >>> data_req = DataRequest(source='investpy') >>> GetData(data_req).get_meta(attr='categories') '['fx', 'rates', 'eqty', 'cmdty', 'macro']' >>> data_req = DataRequest(source='ccxt') >>> GetData(data_req).get_meta(method='get_assets_info') id numericId code precision ticker 1INCH 1INCH None 1INCH 8 1INCHDOWN 1INCHDOWN None 1INCHDOWN 8 1INCHUP 1INCHUP None 1INCHUP 8 AAVE AAVE None AAVE 8 .. py:method:: get_series(method: str = 'get_data') -> pandas.DataFrame Get requested data. :param method: 'get_funding_rates', 'get_open_interest', 'get_eqty', 'get_eqty_iex', 'get_etfs', 'get_stocks', 'get_fx', 'get_rates', 'get_cmdty', 'get_crypto', 'get_macro_series'}, default 'get_data' Gets the specified method from the data source object. :type method: str, {'get_data', 'get_ohlcv', 'get_indexes', 'get_onchain', 'get_social', 'get_trades', 'get_quotes', :returns: **df** -- DataFrame with DatetimeIndex (level 0), ticker (level 1), and field (cols) values. :rtype: pd.DataFrame - MultiIndex .. rubric:: Examples >>> data_req = DataRequest(source='ccxt', tickers=['btc', 'eth'], fields=['open', 'high', 'low', 'close', 'volume'], freq='d', exch='ftx', start_date='2017-01-01') >>> GetData(data_req).get_series() open high low close volume date ticker 2020-03-28 BTC 6243.25 6298.5 6028.0 6237.5 3888.9424 ETH 128.995 133.0 125.11 131.04 1751.65972 2020-03-29 BTC 6233.5 6262.5 5869.5 5876.5 114076.5831 ETH 130.98 131.84 123.81 124.33 138449.60906 2020-03-30 BTC 5876.0 6609.0 5856.0 6396.5 224231.1718 >>> data_req = DataRequest(source='glassnode', tickers=['btc', 'eth'], fields=['add_act', 'tx_count', 'issuance'], freq='d', start_date='2016-01-01') >>> GetData(data_req).get_series() add_act tx_count issuance date ticker 2016-01-01 BTC 316489 123957 0.085386 ETH 2350 8232 0.133048 2016-01-02 BTC 419389 148893 0.09197 ETH 2410 9164 0.140147 2016-01-03 BTC 394047 142463 0.091947 .. py:method:: get_series_async(method: str = 'get_data_async') -> pandas.DataFrame :async: Get requested data. :param method: Gets the specified method from the data source object. :type method: str, default 'get_data' :returns: **df** -- DataFrame with DatetimeIndex (level 0), ticker (level 1), and field (cols) values. :rtype: pd.DataFrame - MultiIndex .. rubric:: Examples >>> data_req = DataRequest(source='ccxt', tickers=['btc', 'eth'], fields=['open', 'high', 'low', 'close', 'volume'], freq='d', exch='ftx', start_date='2017-01-01') >>> GetData(data_req).get_series() open high low close volume date ticker 2020-03-28 BTC 6243.25 6298.5 6028.0 6237.5 3888.9424 ETH 128.995 133.0 125.11 131.04 1751.65972 2020-03-29 BTC 6233.5 6262.5 5869.5 5876.5 114076.5831 ETH 130.98 131.84 123.81 124.33 138449.60906 2020-03-30 BTC 5876.0 6609.0 5856.0 6396.5 224231.1718 >>> data_req = DataRequest(source='glassnode', tickers=['btc', 'eth'], fields=['add_act', 'tx_count', 'issuance'], freq='d', start_date='2016-01-01') >>> GetData(data_req).get_series() add_act tx_count issuance date ticker 2016-01-01 BTC 316489 123957 0.085386 ETH 2350 8232 0.133048 2016-01-02 BTC 419389 148893 0.09197 ETH 2410 9164 0.140147 2016-01-03 BTC 394047 142463 0.091947