cryptodatapy.extract.adapters.libraries.ccxt_adapter ==================================================== .. py:module:: cryptodatapy.extract.adapters.libraries.ccxt_adapter Attributes ---------- .. autoapisummary:: cryptodatapy.extract.adapters.libraries.ccxt_adapter.logger Classes ------- .. autoapisummary:: cryptodatapy.extract.adapters.libraries.ccxt_adapter.CCXTAdapter Module Contents --------------- .. py:data:: logger .. py:class:: CCXTAdapter(config: Optional[Dict[str, Any]] = None) Bases: :py:obj:`cryptodatapy.extract.adapters.base_adapter.BaseLibraryAdapter` Adapter class for retrieving data from CCTX library-supported exchanges. Implements the BaseAdapter contract via BaseLibraryAdapter. .. py:attribute:: _sync_exchanges :type: Dict[str, ccxt.Exchange] .. py:attribute:: _async_exchanges :type: Dict[str, ccxt.Exchange] .. py:attribute:: credentials .. py:attribute:: assets :type: Optional[Union[pandas.DataFrame, list]] :value: None .. py:attribute:: fields :type: Optional[Union[pandas.DataFrame, list]] :value: None .. py:attribute:: markets :type: Optional[Union[pandas.DataFrame, list]] :value: None .. py:attribute:: exchanges :type: Optional[Union[pandas.DataFrame, list]] :value: None .. py:attribute:: frequencies :type: Optional[Dict[str, Union[str, int]]] :value: None .. py:attribute:: rate_limit :type: Any :value: None .. py:method:: _init_client(exch_name: str = 'binance', is_async: bool = True) -> Any Implementation of the BaseLibraryAdapter abstract method. Maps to the specialized exchange instance fetcher. .. py:method:: _get_exchange_instance(exch_name: str) -> ccxt.async_support.Exchange Retrieves or creates an async CCXT exchange instance with correct credentials. Improved version: Maintains original credential logic but optimized for our async loop. .. py:method:: close_async_exchanges() :async: Closes all async exchange connections. .. py:method:: get_exchanges_info() -> List[str] Gets list of available exchanges from CCXT. :returns: **exchanges_list** -- List of available exchange names. :rtype: list .. py:method:: get_assets_info(exch: str = 'binance', as_list: bool = False, **kwargs) -> Union[pandas.DataFrame, List[str]] Get assets/currencies info for a specific exchange. :param exch: Name of exchange. :type exch: str, default 'binance' :param as_list: Returns assets info for selected exchanges as list. :type as_list: bool, default False .. py:method:: get_markets_info(exch: str = 'binance', quote_ccy: Optional[str] = None, mkt_type: Optional[str] = None, as_list: bool = False, **kwargs) -> Union[pandas.DataFrame, List[str]] Get markets info for a specific exchange with optional filtering. :param exch: Name of exchange. :type exch: str, default 'binance' :param quote_ccy: Quote currency. :type quote_ccy: str, optional, default None :param mkt_type: Market type. :type mkt_type: str, {'spot', 'future', 'perpetual_future', 'option'}, optional, default None :param as_list: Returns markets info as list for selected exchange. :type as_list: bool, default False .. py:method:: get_fields_info(**kwargs) -> List[str] Get list of available fields supported by the CCXT adapter. :returns: **fields** -- List of available fields. :rtype: list .. py:method:: get_frequencies_info(exch: str = 'binance') -> Dict[str, Union[str, int]] Get available timeframes/frequencies for a specific exchange. :param exch: Name of exchange for which to get available frequencies. :type exch: str, default 'binance' :returns: **freq** -- Dictionary with info on available frequencies. :rtype: dictionary .. py:method:: get_rate_limit_info(exch: str = 'binance') -> Dict[str, Any] Get rate limit info (delay in ms) for a specific exchange. :param exch: Name of exchange. :type exch: str, default 'binance' :returns: **rate_limit** -- Dictionary with exchange and required minimal delay between HTTP requests that exchange in milliseconds. :rtype: dictionary .. py:method:: _handle_exception_async(e: Exception, attempt: int, ticker: str) -> bool :async: Handles exceptions raised during async data fetching. :param e: The exception that was raised. :type e: Exception :param attempt: The current attempt number. :type attempt: int :param ticker: The ticker symbol being processed. :type ticker: str :returns: True if the operation should be retried, False otherwise. :rtype: bool .. py:method:: _fetch_ticker_data_async(exch: ccxt.async_support.Exchange, req_params: Dict[str, Any], ticker: str) -> List[Any] :async: Fetches data for a request dictionary and a specific ticker. Handles internal CCXT pagination logic. :param req_params: Request parameters dictionary. :type req_params: Dict[str, Any] :param ticker: Ticker symbol to fetch data for. :type ticker: str :returns: **all_results** -- List of all fetched data points. :rtype: list .. py:method:: _fetch_all_tickers_async(req_params: Dict[str, Any]) -> Dict[str, List[Any]] :async: Fetches data for multiple tickers concurrently with throttling and error handling. .. py:method:: _convert_params_to_vendor(data_req: cryptodatapy.core.data_request.DataRequest) -> Dict[str, Any] CONVERT: Uses CCXTParamConverter to get standard CCXT parameters. .. py:method:: _fetch_raw_data(vendor_params: Dict[str, Any]) -> Dict[str, List[Any]] :async: EXTRACT: Orchestrates the fetching process by bridging the sync DataRequest to the async multi-ticker fetcher. .. py:method:: _transform_raw_response(data_req: cryptodatapy.core.data_request.DataRequest, raw_data: List[Any]) -> pandas.DataFrame TRANSFORM: Uses CCXTWrangler to clean the data. .. py:method:: get_data(data_req: cryptodatapy.core.data_request.DataRequest) -> pandas.DataFrame :async: Main entry point for the adapter.