cryptodatapy.extract.adapters.libraries.ccxt_adapter

Attributes

logger

Classes

CCXTAdapter

Adapter class for retrieving data from CCTX library-supported exchanges.

Module Contents

cryptodatapy.extract.adapters.libraries.ccxt_adapter.logger
class cryptodatapy.extract.adapters.libraries.ccxt_adapter.CCXTAdapter(config: Dict[str, Any] | None = None)

Bases: cryptodatapy.extract.adapters.base_adapter.BaseLibraryAdapter

Adapter class for retrieving data from CCTX library-supported exchanges. Implements the BaseAdapter contract via BaseLibraryAdapter.

_sync_exchanges: Dict[str, ccxt.Exchange]
_async_exchanges: Dict[str, ccxt.Exchange]
credentials
assets: pandas.DataFrame | list | None = None
fields: pandas.DataFrame | list | None = None
markets: pandas.DataFrame | list | None = None
exchanges: pandas.DataFrame | list | None = None
frequencies: Dict[str, str | int] | None = None
rate_limit: Any = None
_init_client(exch_name: str = 'binance', is_async: bool = True) Any

Implementation of the BaseLibraryAdapter abstract method. Maps to the specialized exchange instance fetcher.

_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.

async close_async_exchanges()

Closes all async exchange connections.

get_exchanges_info() List[str]

Gets list of available exchanges from CCXT.

Returns:

exchanges_list – List of available exchange names.

Return type:

list

get_assets_info(exch: str = 'binance', as_list: bool = False, **kwargs) pandas.DataFrame | List[str]

Get assets/currencies info for a specific exchange.

Parameters:
  • exch (str, default 'binance') – Name of exchange.

  • as_list (bool, default False) – Returns assets info for selected exchanges as list.

get_markets_info(exch: str = 'binance', quote_ccy: str | None = None, mkt_type: str | None = None, as_list: bool = False, **kwargs) pandas.DataFrame | List[str]

Get markets info for a specific exchange with optional filtering.

Parameters:
  • exch (str, default 'binance') – Name of exchange.

  • quote_ccy (str, optional, default None) – Quote currency.

  • mkt_type (str, {'spot', 'future', 'perpetual_future', 'option'}, optional, default None) – Market type.

  • as_list (bool, default False) – Returns markets info as list for selected exchange.

get_fields_info(**kwargs) List[str]

Get list of available fields supported by the CCXT adapter.

Returns:

fields – List of available fields.

Return type:

list

get_frequencies_info(exch: str = 'binance') Dict[str, str | int]

Get available timeframes/frequencies for a specific exchange.

Parameters:

exch (str, default 'binance') – Name of exchange for which to get available frequencies.

Returns:

freq – Dictionary with info on available frequencies.

Return type:

dictionary

get_rate_limit_info(exch: str = 'binance') Dict[str, Any]

Get rate limit info (delay in ms) for a specific exchange.

Parameters:

exch (str, default 'binance') – Name of exchange.

Returns:

rate_limit – Dictionary with exchange and required minimal delay between HTTP requests that exchange in milliseconds.

Return type:

dictionary

async _handle_exception_async(e: Exception, attempt: int, ticker: str) bool

Handles exceptions raised during async data fetching.

Parameters:
  • e (Exception) – The exception that was raised.

  • attempt (int) – The current attempt number.

  • ticker (str) – The ticker symbol being processed.

Returns:

True if the operation should be retried, False otherwise.

Return type:

bool

async _fetch_ticker_data_async(exch: ccxt.async_support.Exchange, req_params: Dict[str, Any], ticker: str) List[Any]

Fetches data for a request dictionary and a specific ticker. Handles internal CCXT pagination logic.

Parameters:
  • req_params (Dict[str, Any]) – Request parameters dictionary.

  • ticker (str) – Ticker symbol to fetch data for.

Returns:

all_results – List of all fetched data points.

Return type:

list

async _fetch_all_tickers_async(req_params: Dict[str, Any]) Dict[str, List[Any]]

Fetches data for multiple tickers concurrently with throttling and error handling.

_convert_params_to_vendor(data_req: cryptodatapy.core.data_request.DataRequest) Dict[str, Any]

CONVERT: Uses CCXTParamConverter to get standard CCXT parameters.

async _fetch_raw_data(vendor_params: Dict[str, Any]) Dict[str, List[Any]]

EXTRACT: Orchestrates the fetching process by bridging the sync DataRequest to the async multi-ticker fetcher.

_transform_raw_response(data_req: cryptodatapy.core.data_request.DataRequest, raw_data: List[Any]) pandas.DataFrame

TRANSFORM: Uses CCXTWrangler to clean the data.

async get_data(data_req: cryptodatapy.core.data_request.DataRequest) pandas.DataFrame

Main entry point for the adapter.