### Install and Run MCP Server Source: https://context7.com/sigma-quantiphi/ccxt-pandas/llms.txt Commands to install the MCP support package and start the server. ```bash # Install with MCP support pip install ccxt-pandas[mcp] # Run server ccxt-pandas-mcp ``` -------------------------------- ### Install Dependencies with UV Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/CLAUDE.md Use `uv sync` to install project dependencies. Additional flags can be used to install documentation or development dependencies. ```bash uv sync ``` ```bash uv sync --extra docs ``` ```bash uv sync --group dev ``` ```bash uv sync --all-extras --all-groups ``` -------------------------------- ### Install MCP Server Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/introduction.md Install the optional MCP server dependencies. ```bash pip install ccxt-pandas[mcp] ``` -------------------------------- ### Install CCXT-Pandas Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/README.md Command to install the library via pip. ```bash pip install ccxt-pandas ``` -------------------------------- ### MCP Server Installation and Configuration Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/README.md Commands and configuration formats for setting up the CCXT-Pandas MCP server. ```bash pip install ccxt-pandas[mcp] ``` ```json { "accounts": { "binance": { "exchange": "binance", "api_key": "your_api_key", "secret": "your_secret", "sandbox_mode": true } }, "read_only": true } ``` ```bash export CCXT_MCP_ACCOUNT_BINANCE_EXCHANGE=binance export CCXT_MCP_ACCOUNT_BINANCE_API_KEY=your_key export CCXT_MCP_ACCOUNT_BINANCE_SECRET=your_secret export CCXT_MCP_READ_ONLY=true ``` ```bash # Via CLI ccxt-pandas-mcp # Via uv uv run ccxt-pandas-mcp ``` ```json { "mcpServers": { "ccxt-pandas": { "command": "uv", "args": ["run", "ccxt-pandas-mcp"], "env": { "CCXT_MCP_CONFIG": "/path/to/ccxt-mcp-config.json" } } } } ``` -------------------------------- ### Install crypto-pandas Package Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/installation.md Use this command to install the package on Python 3.11 to 3.13. Ensure pip is up to date. ```bash pip install crypto-pandas ``` -------------------------------- ### Claude Code Skill Installation Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/README.md Commands to install the CCXT-Pandas helper skill for Claude Code. ```bash # Windows cp .claude/skills/ccxt-pandas-helper.md %USERPROFILE%\.claude\skills\ # macOS/Linux cp .claude/skills/ccxt-pandas-helper.md ~/.claude/skills/ ``` -------------------------------- ### GET /fetch_balance Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/_autosummary/crypto_pandas.utils.ccxt_pandas_exchange_typed.md Fetches the account balance and returns it as a pandas DataFrame. ```APIDOC ## GET /fetch_balance ### Description Retrieves the current account balance from the exchange. ### Method GET ### Parameters #### Query Parameters - **params** (dict) - Optional - Additional exchange-specific parameters. ### Response #### Success Response (200) - **balance** (DataFrame) - The account balance data. ``` -------------------------------- ### fetch_tickers - Fetch All Tickers Source: https://context7.com/sigma-quantiphi/ccxt-pandas/llms.txt Retrieves current ticker information for all or specified symbols. Useful for getting a quick overview of market prices. ```APIDOC ## GET /api/v1/tickers ### Description Retrieves current ticker information for all available trading symbols or a specified subset of symbols. ### Method GET ### Endpoint /api/v1/tickers ### Parameters #### Query Parameters - **symbol** (string or list) - Optional - A single symbol or a list of symbols to fetch tickers for (e.g., "BTC/USDT" or ["BTC/USDT", "ETH/USDT"]). If not provided, tickers for all symbols are fetched. ### Request Example ```python # Fetch all tickers tickers = exchange.fetch_tickers() # Fetch specific symbols tickers_subset = exchange.fetch_tickers(symbol=["BTC/USDT", "ETH/USDT"]) ``` ### Response #### Success Response (200) - **symbol** (string) - Trading symbol - **last** (float) - Last traded price - **bid** (float) - Best bid price - **ask** (float) - Best ask price - **baseVolume** (float) - Volume of the base currency traded in the last 24 hours - **percentage** (float) - Percentage change in price over the last 24 hours #### Response Example ```json { "symbol": "BTC/USDT", "last": 42150.00, "bid": 42149.50, "ask": 42150.50, "baseVolume": 12345.678901, "percentage": 2.35 } ``` ``` -------------------------------- ### Place Limit Maker and Queue Orders Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/examples.md Demonstrates placing LIMIT_MAKER and QUEUE orders in a sandbox environment. These order types are suitable for market making strategies. ```python import ccxt_pandas as cpd # Load exchange in sandbox mode exchange = cpd.load_exchange('binance', sandbox=True) # Define order parameters symbol = 'BTC/USDT' side = 'buy' amount = 0.01 price = 30000 # Place LIMIT_MAKER order order_maker = exchange.create_order(symbol, 'limit', side, amount, price, {'type': 'LIMIT_MAKER'}) print('LIMIT_MAKER Order:', order_maker) # Place QUEUE order (if supported) # order_queue = exchange.create_order(symbol, 'limit', side, amount, price, {'type': 'QUEUE'}) # print('QUEUE Order:', order_queue) ``` -------------------------------- ### Initialize and Use CCXTPandasExchange Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/README.md Demonstrates initializing a synchronous exchange object and fetching market data as DataFrames. ```python # Initialize a CCXTPandasExchange object exchange = ccxt.binance(dict(apiKey="your_api_key_here", secret="your_secret_here")) exchange = CCXTPandasExchange(exchange=exchange) # OHLCV ohlcv = exchange.fetch_ohlcv("BTC/USDT", timeframe="1m", limit=100) # -> DataFrame # Trades trades = exchange.fetch_trades("BTC/USDT", limit=1000) # -> DataFrame # Orderbook ob = exchange.fetch_order_book("BTC/USDT", limit=50) # -> DataFrame # Tickers tick = exchange.fetch_tickers() # -> DataFrame # Fetch open orders from an exchange open_orders = exchange.fetch_open_orders(symbol="BTC/USDT") # Halve the amount and edit orders open_orders["amount"] /= 2 response = exchange.edit_orders(open_orders) # Display the transformed orders dataframe print(response) ``` -------------------------------- ### Run MCP Server Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/introduction.md Execute the MCP server using CLI or uv. ```bash # Via CLI ccxt-pandas-mcp # Via uv uv run ccxt-pandas-mcp ``` -------------------------------- ### GET has_method Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/crypto_pandas.md Checks if a specific CCXT method is available for dynamic resolution. ```APIDOC ## GET has_method ### Description Determines if the processor supports a specific CCXT method name. ### Method GET ### Endpoint has_method(method_name: str) ### Parameters #### Path Parameters - **method_name** (str) - Required - The name of the CCXT method to check. ### Response #### Success Response (200) - **result** (bool) - Returns true if the method exists, false otherwise. ``` -------------------------------- ### Configure MCP Server Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/introduction.md Define account credentials and settings via JSON or environment variables. ```json { "accounts": { "binance": { "exchange": "binance", "api_key": "your_api_key", "secret": "your_secret", "sandbox_mode": true } }, "read_only": true } ``` ```bash export CCXT_MCP_ACCOUNT_BINANCE_EXCHANGE=binance export CCXT_MCP_ACCOUNT_BINANCE_API_KEY=your_key export CCXT_MCP_ACCOUNT_BINANCE_SECRET=your_secret export CCXT_MCP_READ_ONLY=true ``` -------------------------------- ### Initialize CCXTPandasExchange Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/introduction.md Wraps a standard CCXT exchange instance with CCXTPandasExchange for DataFrame-based output. ```python import ccxt from ccxt_pandas import CCXTPandasExchange # Initialize a CCXTPandasExchange object exchange = ccxt.binance(dict(apiKey="your_api_key_here", secret="your_secret_here")) exchange = CCXTPandasExchange(exchange=exchange) ``` -------------------------------- ### GET load_cached_markets Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/crypto_pandas.ccxt.async_ccxt_pandas_exchange.md Asynchronously loads and caches market data from the exchange, returning it as a pandas DataFrame. ```APIDOC ## GET load_cached_markets ### Description Loads and caches markets data asynchronously. This method allows for optional parameters to customize the data retrieval process. ### Method GET ### Endpoint load_cached_markets ### Parameters #### Query Parameters - **params** (dict) - Optional - Custom parameters for the market data request. ### Response #### Success Response (200) - **data** (pd.DataFrame) - A pandas DataFrame containing the cached market information. ``` -------------------------------- ### GET load_cached_markets Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/crypto_pandas.ccxt.ccxt_pandas_exchange.md Loads market data from the exchange and returns it as a Pandas DataFrame, utilizing a caching mechanism to improve performance. ```APIDOC ## GET load_cached_markets ### Description Loads market data from the exchange and caches it for a specified duration. Returns the market data as a Pandas DataFrame. ### Method GET ### Endpoint load_cached_markets(params={}) ### Parameters #### Query Parameters - **params** (dict) - Optional - Additional parameters for the exchange's market-loading function. ### Response #### Success Response (200) - **data** (pd.DataFrame) - A DataFrame containing the market data. ``` -------------------------------- ### Fetch Spot, Future, and Swap Prices and Volumes Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/examples.md Analyze BTC spread and volume across different contract types. This script helps in understanding market dynamics for various trading instruments. ```python import ccxt_pandas as cpd # Load all exchanges # exchanges = cpd.load_exchanges() # Load specific exchanges exchanges = cpd.load_exchanges(['binance', 'binanceusdm', 'binancecoinm']) # Fetch OHLCV data for BTC/USDT df = cpd.fetch_ohlcv(exchanges, 'BTC/USDT', timeframe='1h', limit=1000) # Calculate spread and volume df['spread'] = df['ask'] - df['bid'] df['volume'] = df['quoteVolume'] # Display results print(df.head()) # Plot BTC spread and volume df[['spread', 'volume']].plot() ``` -------------------------------- ### AsyncCCXTPandasExchange Configuration Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/crypto_pandas.ccxt.async_ccxt_pandas_exchange.md Configuration parameters for initializing the AsyncCCXTPandasExchange instance. ```APIDOC ## Configuration Parameters ### Description Initialization parameters for the AsyncCCXTPandasExchange class to manage exchange behavior, concurrency, and data validation. ### Parameters - **exchange** (ccxt.Exchange) - Required - The ccxt exchange instance. - **max_order_cost** (float) - Optional - Maximum allowable cost for a single order (default: 10000). - **max_number_of_orders** (int) - Optional - Maximum number of orders for bulk processing (default: 5). - **markets_cache_time** (int) - Optional - Cache duration in seconds (default: 3600). - **semaphore_value** (int) - Optional - Concurrency limit for requests (default: 1000). - **cost_out_of_range** (str) - Optional - Behavior for cost violations ('warn' or 'clip'). - **amount_out_of_range** (str) - Optional - Behavior for volume violations ('warn' or 'clip'). - **price_out_of_range** (str) - Optional - Behavior for price violations ('warn' or 'clip'). ``` -------------------------------- ### Fetch Option Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/_autosummary/crypto_pandas.utils.ccxt_pandas_exchange_typed.md Retrieves option details for a specific symbol and returns it as a dictionary. ```APIDOC ## POST /fetch_option ### Description Retrieves option details for a specific symbol and returns it as a dictionary. ### Method POST ### Endpoint /fetch_option ### Parameters #### Query Parameters - **symbol** (str) - Required - The symbol for which to fetch option details. - **params** (dict) - Optional - Additional parameters for the request. ### Response #### Success Response (200) - **dict** - A dictionary containing the option details. ``` -------------------------------- ### Get directional sign for order book sides Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/ccxt_pandas/calculations/README.md Returns +1 for asks/sell and -1 for bids/buy based on the 'side' column in a DataFrame. ```python import pandas as pd import ccxt_pandas as cpd orderbook = pd.DataFrame({'side': ['bids', 'asks', 'bids']}) signs = cpd.side_sign(orderbook) print(signs) # 0 -1 # 1 1 # 2 -1 ``` -------------------------------- ### Fetch Account Balances Source: https://context7.com/sigma-quantiphi/ccxt-pandas/llms.txt Retrieves account balances including free, used, and total amounts for each asset. ```python import ccxt from ccxt_pandas import CCXTPandasExchange exchange = ccxt.binance({ "apiKey": "your_api_key", "secret": "your_secret" }) pandas_exchange = CCXTPandasExchange(exchange=exchange) # Fetch balance balance = pandas_exchange.fetch_balance() print(balance[balance["total"] > 0][["code", "free", "used", "total"]]) # code free used total # 0 BTC 1.23456789 0.1234567 1.35802459 # 1 USDT 10000.00000 500.00000 10500.00000 ``` -------------------------------- ### Git Branching Workflow Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/README.md Standard commands for contributing to the repository. ```bash git checkout -b my-new-feature git commit -am 'Add some feature' git push origin my-new-feature ``` -------------------------------- ### Initialize CCXTPandasExchange Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/README.md Basic boilerplate for wrapping a CCXT exchange object with CCXTPandasExchange. ```python import ccxt from ccxt_pandas import CCXTPandasExchange ``` -------------------------------- ### Fetch Option Chain Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/_autosummary/crypto_pandas.utils.ccxt_pandas_exchange_typed.md Retrieves the option chain for a given code and returns it as a dictionary. ```APIDOC ## POST /fetch_option_chain ### Description Retrieves the option chain for a given code and returns it as a dictionary. ### Method POST ### Endpoint /fetch_option_chain ### Parameters #### Query Parameters - **code** (str) - Required - The code for which to fetch the option chain. - **params** (dict) - Optional - Additional parameters for the request. ### Response #### Success Response (200) - **dict** - A dictionary containing the option chain data. ``` -------------------------------- ### Create Single Limit Order by Amount Source: https://context7.com/sigma-quantiphi/ccxt-pandas/llms.txt Creates a single limit order for a specified amount and price. Ensure sandbox mode is set for testing. Requires ccxt and ccxt_pandas. ```python import ccxt from ccxt_pandas import CCXTPandasExchange exchange = ccxt.binance({ "apiKey": "your_api_key", "secret": "your_secret" }) exchange.set_sandbox_mode(True) pandas_exchange = CCXTPandasExchange(exchange=exchange) # Create limit order by amount order = pandas_exchange.create_order( symbol="BTC/USDT", type="limit", side="buy", amount=0.001, price=40000.0 ) print(order[["id", "symbol", "type", "side", "price", "amount", "status"]]) ``` -------------------------------- ### Initialize Synchronous CCXTPandasExchange Source: https://context7.com/sigma-quantiphi/ccxt-pandas/llms.txt Wrap a CCXT exchange instance with CCXTPandasExchange for DataFrame output. Configure options like dropna_fields, max_order_cost, max_number_of_orders, and error handling. ```python import ccxt from ccxt_pandas import CCXTPandasExchange # Initialize with any CCXT exchange exchange = ccxt.binance({ "apiKey": "your_api_key", "secret": "your_secret" }) exchange.set_sandbox_mode(True) # Use sandbox for testing # Wrap with CCXTPandasExchange pandas_exchange = CCXTPandasExchange( exchange=exchange, dropna_fields=True, # Remove empty columns max_order_cost=10_000, # Max order value limit max_number_of_orders=1_000, # Batch order limit errors="raise" # Error handling: "raise", "warn", "ignore" ) # Load available markets markets = pandas_exchange.load_markets() print(markets[["symbol", "base", "quote", "type"]].head()) # symbol base quote type # 0 BTC/USDT BTC USDT spot # 1 ETH/USDT ETH USDT spot # 2 BTC/USDT:USDT BTC USDT swap ``` -------------------------------- ### fetch_balance - Fetch Account Balances Source: https://context7.com/sigma-quantiphi/ccxt-pandas/llms.txt Retrieves account balances, including free, used, and total amounts for each currency. ```APIDOC ## GET /api/v1/balance ### Description Retrieves the current balances of your exchange account, detailing the free, used, and total amounts for each currency. ### Method GET ### Endpoint /api/v1/balance ### Parameters This endpoint does not accept any parameters. ### Request Example ```python # Fetch balance balance = pandas_exchange.fetch_balance() print(balance[balance["total"] > 0][["code", "free", "used", "total"]]) ``` ### Response #### Success Response (200) - **code** (string) - The currency code (e.g., "BTC", "USDT") - **free** (float) - The amount of currency available for trading - **used** (float) - The amount of currency currently used in open orders - **total** (float) - The total amount of currency in the account #### Response Example ```json { "code": "BTC", "free": 1.23456789, "used": 0.1234567, "total": 1.35802459 } ``` ``` -------------------------------- ### Configuration Options Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/_autosummary/crypto_pandas.md Configuration parameters for customizing CCXT-Pandas behavior. ```APIDOC ## Configuration Options This section details the configurable parameters for the CCXT-Pandas integration. ### `dropna_fields` * **Description:** Determines whether empty (NaN) columns are removed from DataFrame outputs. * **Type:** `bool` * **Default:** `True` ### `attach_trades_to_orders` * **Description:** Determines whether trades are attached to orders when processing orders. * **Type:** `bool` * **Default:** `False` ### `max_order_cost` * **Description:** Maximum cost value for any single order. * **Type:** `float` * **Default:** `10000` ### `max_number_of_orders` * **Description:** Maximum number of bulk orders allowed. * **Type:** `int` * **Default:** `5` ### `markets_cache_time` * **Description:** Cache duration (in seconds) for markets data. * **Type:** `int` * **Default:** `3600` ### `cost_out_of_range` * **Description:** Defines behavior when cost exceeds acceptable ranges. * **Options:** `"warn"` (Logs a warning while removing the order), `"clip"` (Clips or limits the volume to valid ranges). * **Type:** `str` * **Default:** `"warn"` ### `amount_out_of_range` * **Description:** Defines behavior when volume exceeds acceptable ranges. * **Options:** `"warn"` (Logs a warning while removing the order), `"clip"` (Clips or limits the volume to valid ranges). * **Type:** `str` * **Default:** `"warn"` ### `price_out_of_range` * **Description:** Defines behavior when price exceeds allowable ranges. * **Options:** `"warn"` (Logs a warning while removing the order), `"clip"` (Adjusts the price to fit within predefined limits). * **Type:** `str` * **Default:** `"warn"` ### `_ccxt_processor` * **Description:** A helper class to process CCXT responses and provide consistent output. * **Type:** `BaseProcessor` ### `__getattr__(method_name: str)` * **Description:** Overridden to enable dynamic method resolution for CCXT methods, with transformations applied to handle inputs and outputs as Pandas DataFrames. * **Type:** `str` ### `account_name` * **Description:** The name of the account. * **Type:** `str | None` * **Default:** `None` ### `exchange` * **Description:** The CCXT exchange instance. * **Type:** `Exchange` ### `exchange_name` * **Description:** The name of the exchange. * **Type:** `str | None` * **Default:** `None` ### `has_method(method_name: str) -> bool` * **Description:** Checks if the exchange supports a given method. * **Parameters:** * **method_name** (`str`) - The name of the method to check. * **Returns:** `bool` - True if the method is supported, False otherwise. ``` -------------------------------- ### Initialize Asynchronous AsyncCCXTPandasExchange Source: https://context7.com/sigma-quantiphi/ccxt-pandas/llms.txt Use AsyncCCXTPandasExchange with CCXT Pro for concurrent operations. Configure concurrency limits using semaphore_value. ```python import asyncio import ccxt.pro as ccxt_pro from ccxt_pandas import AsyncCCXTPandasExchange exchange = ccxt_pro.binance() pandas_exchange = AsyncCCXTPandasExchange( exchange=exchange, semaphore_value=1000 # Concurrency limit ) async def main(): # Load markets markets = await pandas_exchange.load_markets() symbols = markets["symbol"].head(100).tolist() # Fetch OHLCV for multiple symbols concurrently tasks = [ pandas_exchange.fetch_ohlcv(symbol=s, timeframe="1h", limit=100) for s in symbols ] results = await asyncio.gather(*tasks, return_exceptions=True) # Combine successful results import pandas as pd ohlcv_data = pd.concat([r for r in results if isinstance(r, pd.DataFrame)]) print(f"Fetched {len(ohlcv_data)} candles across {len(symbols)} symbols") await exchange.close() asyncio.run(main()) ``` -------------------------------- ### Calculate Net Delta Across Spot and Derivatives Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/examples.md Compute the net delta exposure across both spot and derivative positions in a sandbox environment. This helps in managing overall portfolio risk. ```python import ccxt_pandas as cpd # Load exchange in sandbox mode exchange = cpd.load_exchange('binance', sandbox=True) # Fetch positions positions = exchange.fetch_positions() # Calculate net delta net_delta = cpd.calculate_delta_position(positions) # Display results print('Net Delta:', net_delta) ``` -------------------------------- ### Stream Live Liquidation Events via WebSocket Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/examples.md Subscribe to live liquidation events using WebSockets. This script is essential for monitoring and reacting to high-volatility events in the derivatives market. ```python import ccxt_pandas as cpd # Load exchange exchange = cpd.load_exchange('binanceusdm') # Define a callback function for liquidation events def on_liquidation(data): print('Liquidation Event:', data) # Subscribe to liquidations channel exchange.websockets_listen_liquidations(on_liquidation) ``` -------------------------------- ### Configure MCP Server Source: https://context7.com/sigma-quantiphi/ccxt-pandas/llms.txt JSON configuration for defining exchange accounts and access restrictions. ```json { "accounts": { "binance": { "exchange": "binance", "api_key": "your_api_key", "secret": "your_secret", "sandbox_mode": true }, "bybit": { "exchange": "bybit", "api_key": "your_api_key", "secret": "your_secret", "sandbox_mode": true } }, "read_only": true, "allowed_symbols": ["BTC/USDT", "ETH/USDT"], "blocked_symbols": [] } ``` -------------------------------- ### Load Markets from All Exchanges Asynchronously Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/examples.md Asynchronously load market data from all available exchanges. This provides a comprehensive overview of available trading pairs and their properties. ```python import ccxt_pandas as cpd # Load all exchanges asynchronously all_exchanges = cpd.load_symbols_all_exchanges_async() # Access market data for a specific exchange # print(all_exchanges['binance'].head()) # Example: Get all symbols from Binance binance_symbols = all_exchanges.get('binance', cpd.pd.DataFrame())['symbol'].tolist() print('Binance Symbols:', binance_symbols[:10]) ``` -------------------------------- ### Create Single Market Order by Cost Source: https://context7.com/sigma-quantiphi/ccxt-pandas/llms.txt Creates a single market order by specifying the total cost, which will be executed at the current market price. Requires ccxt and ccxt_pandas. ```python import ccxt from ccxt_pandas import CCXTPandasExchange exchange = ccxt.binance({ "apiKey": "your_api_key", "secret": "your_secret" }) exchange.set_sandbox_mode(True) pandas_exchange = CCXTPandasExchange(exchange=exchange) # Create market order market_order = pandas_exchange.create_order( symbol="BTC/USDT", type="market", side="buy", cost=50.0 # $50 worth at market price ) ``` -------------------------------- ### create_order Source: https://context7.com/sigma-quantiphi/ccxt-pandas/llms.txt Places a single order with automatic precision handling. ```APIDOC ## create_order ### Description Creates a single order. Supports creation by amount or by cost. ### Parameters #### Request Body - **symbol** (string) - Required - The trading pair symbol - **type** (string) - Required - Order type (e.g., "limit", "market") - **side** (string) - Required - Order side ("buy" or "sell") - **amount** (float) - Optional - Order amount - **price** (float) - Optional - Order price - **cost** (float) - Optional - Total cost for the order ``` -------------------------------- ### POST /create_order Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/_autosummary/crypto_pandas.utils.ccxt_pandas_exchange_typed.md Creates a new order on the exchange. ```APIDOC ## POST /create_order ### Description Creates a new order on the exchange and returns the order details as a dictionary. ### Method POST ### Parameters #### Request Body - **symbol** (str) - Required - The trading symbol. - **type** (Literal['limit', 'market']) - Required - The order type. - **side** (Literal['buy', 'sell']) - Required - The order side. - **amount** (float) - Required - The order amount. - **price** (None | str | float | int | Decimal) - Optional - The order price. - **params** (dict) - Optional - Additional exchange-specific parameters. ### Response #### Success Response (200) - **order** (dict) - The created order details. ``` -------------------------------- ### Integrate with Claude Desktop Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/introduction.md Add the MCP server configuration to your Claude Desktop or Claude Code client. ```json { "mcpServers": { "ccxt-pandas": { "command": "uv", "args": ["run", "ccxt-pandas-mcp"], "env": { "CCXT_MCP_CONFIG": "/path/to/ccxt-mcp-config.json" } } } } ``` -------------------------------- ### Fetch Open Positions Source: https://context7.com/sigma-quantiphi/ccxt-pandas/llms.txt Retrieves open positions for derivatives trading, supporting filtering by symbol. ```python import ccxt from ccxt_pandas import CCXTPandasExchange exchange = ccxt.binance({ "apiKey": "your_api_key", "secret": "your_secret" }) pandas_exchange = CCXTPandasExchange(exchange=exchange) # Fetch all positions positions = pandas_exchange.fetch_positions() print(positions[["symbol", "side", "contracts", "entryPrice", "unrealizedPnl"]]) # symbol side contracts entryPrice unrealizedPnl # 0 BTC/USDT:USDT long 0.50 42000.0 150.00 # 1 ETH/USDT:USDT short 2.00 2200.0 -50.00 # Fetch positions for specific symbols positions = pandas_exchange.fetch_positions(symbol=["BTC/USDT:USDT", "ETH/USDT:USDT"]) ``` -------------------------------- ### Place and Edit Orders via WebSocket Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/examples.md Send orders and edit existing orders through WebSocket connections in a sandbox environment. This enables real-time order management with lower latency. ```python import ccxt_pandas as cpd # Load exchange in sandbox mode exchange = cpd.load_exchange('binance', sandbox=True) # Define order parameters symbol = 'BTC/USDT' side = 'buy' amount = 0.01 price = 30000 # Define callback for order events def on_order_update(order): print('Order Update:', order) # Send a new order via WebSocket order_id = exchange.send_order_ws(symbol, 'limit', side, amount, price, callback=on_order_update) # Edit an existing order via WebSocket (example) # new_price = 30001 # updated_order = exchange.edit_order_ws(order_id, symbol, 'limit', side, amount, new_price, callback=on_order_update) ``` -------------------------------- ### Fetch Deposit and Withdrawal History Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/examples.md Retrieve the history of deposits and withdrawals from a sandbox account. This is useful for auditing and tracking fund movements. ```python import ccxt_pandas as cpd # Load exchange in sandbox mode exchange = cpd.load_exchange('binance', sandbox=True) # Fetch deposit history deposits = exchange.fetch_deposits() print('Deposits:', deposits) # Fetch withdrawal history withdrawals = exchange.fetch_withdrawals() print('Withdrawals:', withdrawals) ``` -------------------------------- ### Account and Balance API Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/_autosummary/crypto_pandas.utils.async_ccxt_pandas_exchange_typed.md Methods for fetching account information and balances. ```APIDOC ## GET /api/v1/accounts ### Description Fetches account information. ### Method GET ### Endpoint /api/v1/accounts ### Parameters #### Query Parameters - **params** (dict) - Optional - Additional parameters for the exchange. ### Response #### Success Response (200) - **DataFrame** (pd.DataFrame) - A DataFrame containing account information. #### Response Example ```json { "example": "[DataFrame representing account information]" } ``` ## GET /api/v1/balance ### Description Fetches the current account balance. ### Method GET ### Endpoint /api/v1/balance ### Parameters #### Query Parameters - **params** (dict) - Optional - Additional parameters for the exchange. ### Response #### Success Response (200) - **DataFrame** (pd.DataFrame) - A DataFrame containing balance information. #### Response Example ```json { "example": "[DataFrame representing balance information]" } ``` ``` -------------------------------- ### fetch_funding_rates - Fetch Perpetual Funding Rates Source: https://context7.com/sigma-quantiphi/ccxt-pandas/llms.txt Retrieves current funding rates for perpetual contracts. Also provides a method to fetch historical funding rates. ```APIDOC ## GET /api/v1/funding_rates ### Description Retrieves the current funding rates for perpetual futures contracts. A separate method is available to fetch historical funding rates. ### Method GET ### Endpoint /api/v1/funding_rates ### Parameters This endpoint does not accept any parameters for fetching current rates. ### Request Example ```python # Fetch current funding rates funding_rates = exchange.fetch_funding_rates() ``` ### Response #### Success Response (200) - **symbol** (string) - Trading symbol for the perpetual contract - **fundingRate** (float) - The current funding rate - **fundingTimestamp** (string) - The timestamp when the funding rate is effective #### Response Example ```json { "symbol": "BTC/USDT:USDT", "fundingRate": 0.000100, "fundingTimestamp": "2024-01-15 16:00:00+00:00" } ``` ## GET /api/v1/funding_rate_history ### Description Retrieves historical funding rates for a specified perpetual contract symbol. ### Method GET ### Endpoint /api/v1/funding_rate_history ### Parameters #### Query Parameters - **symbol** (string) - Required - The trading symbol for the perpetual contract (e.g., "BTC/USDT:USDT") - **limit** (integer) - Optional - The maximum number of historical funding rates to retrieve. ### Request Example ```python # Fetch historical funding rate funding_history = exchange.fetch_funding_rate_history( symbol="BTC/USDT:USDT", limit=1000 ) ``` ### Response #### Success Response (200) - **symbol** (string) - Trading symbol for the perpetual contract - **fundingRate** (float) - The funding rate at the specified time - **fundingTimestamp** (string) - The timestamp of the funding rate #### Response Example ```json { "symbol": "BTC/USDT:USDT", "fundingRate": 0.000100, "fundingTimestamp": "2024-01-15 16:00:00+00:00" } ``` ``` -------------------------------- ### Create Single Limit Order by Cost Source: https://context7.com/sigma-quantiphi/ccxt-pandas/llms.txt Creates a single limit order by specifying the total cost, automatically calculating the order amount. Requires ccxt and ccxt_pandas. ```python import ccxt from ccxt_pandas import CCXTPandasExchange exchange = ccxt.binance({ "apiKey": "your_api_key", "secret": "your_secret" }) exchange.set_sandbox_mode(True) pandas_exchange = CCXTPandasExchange(exchange=exchange) # Create order by cost (automatically calculates amount) order = pandas_exchange.create_order( symbol="BTC/USDT", type="limit", side="buy", cost=100.0, # $100 worth price=40000.0 ) ``` -------------------------------- ### Fetch Perpetual Funding Rates Source: https://context7.com/sigma-quantiphi/ccxt-pandas/llms.txt Retrieves current funding rates for perpetual contracts and historical funding rate data. ```python import ccxt from ccxt_pandas import CCXTPandasExchange exchange = CCXTPandasExchange(exchange=ccxt.binance()) # Fetch current funding rates funding_rates = exchange.fetch_funding_rates() print(funding_rates[["symbol", "fundingRate", "fundingTimestamp"]].head()) # symbol fundingRate fundingTimestamp # 0 BTC/USDT:USDT 0.000100 2024-01-15 16:00:00+00:00 # 1 ETH/USDT:USDT 0.000075 2024-01-15 16:00:00+00:00 # Fetch historical funding rate funding_history = exchange.fetch_funding_rate_history( symbol="BTC/USDT:USDT", limit=1000 ) ``` -------------------------------- ### Fetch Best Bid/Ask Prices Source: https://context7.com/sigma-quantiphi/ccxt-pandas/llms.txt Retrieves the best bid and ask prices for all symbols. ```python import ccxt from ccxt_pandas import CCXTPandasExchange exchange = CCXTPandasExchange(exchange=ccxt.binance()) # Fetch best bid/ask bids_asks = exchange.fetch_bids_asks() print(bids_asks[["symbol", "bid", "ask", "bidVolume", "askVolume"]].head()) # symbol bid ask bidVolume askVolume # 0 BTC/USDT 42149.50 42150.50 1.234567 0.987654 # 1 ETH/USDT 2249.80 2250.20 5.432100 3.210987 ``` -------------------------------- ### Run Pytest Tests Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/CLAUDE.md Execute tests using `uv run pytest`. This includes running all tests, a single test file, or a specific test case. Ensure API keys are configured in a `.env` file. ```bash uv run pytest tests/ ``` ```bash uv run pytest tests/test_sync.py::test_fetch_ohlcv -s ``` ```bash uv run python tests/test_async.py ``` -------------------------------- ### Fetch My Liquidations Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/_autosummary/crypto_pandas.utils.ccxt_pandas_exchange_typed.md Retrieves liquidation information for the current user and returns it as a Pandas DataFrame. ```APIDOC ## POST /fetch_my_liquidations ### Description Retrieves liquidation information for the current user and returns it as a Pandas DataFrame. ### Method POST ### Endpoint /fetch_my_liquidations ### Parameters #### Query Parameters - **symbol** (str | None) - Optional - The symbol to filter liquidations by. - **since** (int | Timestamp | dict | str | None) - Optional - The starting timestamp for the liquidation entries. - **limit** (int | None) - Optional - The maximum number of liquidation entries to retrieve. - **params** (dict) - Optional - Additional parameters for the request. ### Response #### Success Response (200) - **DataFrame** (pd.DataFrame) - A DataFrame containing the user's liquidation information. ``` -------------------------------- ### Place Multiple Orders from DataFrame Source: https://context7.com/sigma-quantiphi/ccxt-pandas/llms.txt Creates multiple orders simultaneously from a pandas DataFrame. Requires ccxt, pandas, and ccxt_pandas. Ensure sandbox mode is enabled for testing. ```python import ccxt import pandas as pd from ccxt_pandas import CCXTPandasExchange exchange = ccxt.binance({ "apiKey": "your_api_key", "secret": "your_secret" }) exchange.set_sandbox_mode(True) pandas_exchange = CCXTPandasExchange(exchange=exchange) # Get current price for reference ohlcv = pandas_exchange.fetch_ohlcv(symbol="BTC/USDT", timeframe="1m", limit=1) current_price = ohlcv["close"].iloc[-1] # Create order DataFrame orders = pd.DataFrame({ "symbol": ["BTC/USDT"] * 4, "type": ["limit"] * 4, "side": ["buy", "buy", "sell", "sell"], "price": [ current_price * 0.95, # 5% below current_price * 0.90, # 10% below current_price * 1.05, # 5% above current_price * 1.10 # 10% above ], "cost": [100, 100, 100, 100] # $100 each }) # Submit all orders results = pandas_exchange.create_orders(orders=orders) print(results[["id", "symbol", "side", "price", "amount", "status"]]) ``` -------------------------------- ### Fetch Order Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/_autosummary/crypto_pandas.utils.ccxt_pandas_exchange_typed.md Retrieves details for a specific order ID and returns it as a dictionary. ```APIDOC ## POST /fetch_order ### Description Retrieves details for a specific order ID and returns it as a dictionary. ### Method POST ### Endpoint /fetch_order ### Parameters #### Query Parameters - **id** (str) - Required - The ID of the order to retrieve. - **symbol** (str | None) - Optional - The symbol associated with the order. - **params** (dict) - Optional - Additional parameters for the request. ### Response #### Success Response (200) - **dict** - A dictionary containing the order details. ``` -------------------------------- ### Fetch Private Account Data (Trades, Positions, Greeks) Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/examples.md Retrieve private account data including trades, positions, and greeks from a sandbox environment. Ensure you have set up API keys and enabled sandbox mode. ```python import ccxt_pandas as cpd # Load exchange in sandbox mode exchange = cpd.load_exchange('binance', sandbox=True) # Fetch trades trades = exchange.fetch_my_trades() print('My Trades:', trades) # Fetch positions positions = exchange.fetch_positions() print('My Positions:', positions) # Fetch greeks (if supported) greeks = exchange.fetch_greeks() print('My Greeks:', greeks) ``` -------------------------------- ### Stream Real-Time Trades Source: https://context7.com/sigma-quantiphi/ccxt-pandas/llms.txt Uses the AsyncCCXTPandasExchange to watch live trade data via WebSockets. ```python import asyncio import ccxt.pro as ccxt_pro from ccxt_pandas import AsyncCCXTPandasExchange exchange = ccxt_pro.binance() pandas_exchange = AsyncCCXTPandasExchange(exchange=exchange) async def stream_trades(): try: while True: trades = await pandas_exchange.watch_trades(symbol="BTC/USDT") print(trades[["timestamp", "price", "amount", "side"]].tail(5)) finally: await exchange.close() asyncio.run(stream_trades()) ``` -------------------------------- ### Currency and Conversion API Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/_autosummary/crypto_pandas.utils.async_ccxt_pandas_exchange_typed.md Methods for fetching currency information and conversion details. ```APIDOC ## GET /api/v1/currencies ### Description Fetches information about available currencies. ### Method GET ### Endpoint /api/v1/currencies ### Parameters #### Query Parameters - **params** (dict) - Optional - Additional parameters for the exchange. ### Response #### Success Response (200) - **DataFrame** (pd.DataFrame) - A DataFrame containing currency information. #### Response Example ```json { "example": "[DataFrame representing currency information]" } ``` ## GET /api/v1/convert/currencies ### Description Fetches information about currencies supported for conversion. ### Method GET ### Endpoint /api/v1/convert/currencies ### Parameters #### Query Parameters - **params** (dict) - Optional - Additional parameters for the exchange. ### Response #### Success Response (200) - **DataFrame** (pd.DataFrame) - A DataFrame containing information about convertible currencies. #### Response Example ```json { "example": "[DataFrame representing convertible currencies]" } ``` ## GET /api/v1/convert/trade_history ### Description Fetches the history of conversion trades. ### Method GET ### Endpoint /api/v1/convert/trade_history ### Parameters #### Query Parameters - **code** (str | None) - Optional - Filter by currency code. - **since** (int | Timestamp | dict | str | None) - Optional - The earliest timestamp to fetch conversion history from. - **limit** (int | None) - Optional - The maximum number of conversion trades to return. - **params** (dict) - Optional - Additional parameters for the exchange. ### Response #### Success Response (200) - **DataFrame** (pd.DataFrame) - A DataFrame containing conversion trade history. #### Response Example ```json { "example": "[DataFrame representing conversion trade history]" } ``` ``` -------------------------------- ### fetch_bids_asks - Fetch Best Bid/Ask Prices Source: https://context7.com/sigma-quantiphi/ccxt-pandas/llms.txt Retrieves the best bid and ask prices, along with their volumes, for all trading symbols. ```APIDOC ## GET /api/v1/bids_asks ### Description Retrieves the best bid and ask prices, and their corresponding volumes, for all available trading symbols. ### Method GET ### Endpoint /api/v1/bids_asks ### Parameters This endpoint does not accept any parameters. ### Request Example ```python # Fetch best bid/ask for all symbols bids_asks = exchange.fetch_bids_asks() ``` ### Response #### Success Response (200) - **symbol** (string) - Trading symbol - **bid** (float) - Best bid price - **ask** (float) - Best ask price - **bidVolume** (float) - Volume available at the best bid price - **askVolume** (float) - Volume available at the best ask price #### Response Example ```json { "symbol": "BTC/USDT", "bid": 42149.50, "ask": 42150.50, "bidVolume": 1.234567, "askVolume": 0.987654 } ``` ``` -------------------------------- ### calculate_realized_pnl() Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/ccxt_pandas/calculations/README.md Calculate realized PnL metrics by matching buy and sell trades. ```APIDOC ## calculate_realized_pnl() ### Description Calculate realized PnL metrics by matching buy and sell trades. ### Parameters - **trades** (DataFrame) - Required - Trades DataFrame from fetch_my_trades() - **group_by** (tuple/list) - Optional - Columns to group by (default: ("symbol",)) - **freq** (string) - Optional - pandas frequency string for time aggregation - **include_totals** (bool) - Optional - Whether to include "All" totals row (default: False) ### Response - **Returns** (DataFrame) - Buy/sell amounts, prices, spread, matched amounts, and realized PnL ``` -------------------------------- ### Fetch and Plot OHLCV Data Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/README.md Initializes a CCXTPandasExchange instance to fetch OHLCV data and plot the closing price. ```python import ccxt from ccxt_pandas import CCXTPandasExchange exchange = CCXTPandasExchange(exchange=ccxt.binance()) ohlcv = exchange.fetch_ohlcv("BTC/USDT", timeframe="1m", limit=1000) plt = ohlcv.close.plot(title="BTC/USDT — 1m") plt.show() ``` -------------------------------- ### Fetch Leverages Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/docs/source/_autosummary/crypto_pandas.utils.ccxt_pandas_exchange_typed.md Retrieves leverage information for specified symbols and returns it as a Pandas DataFrame. ```APIDOC ## POST /fetch_leverages ### Description Retrieves leverage information for specified symbols and returns it as a Pandas DataFrame. ### Method POST ### Endpoint /fetch_leverages ### Parameters #### Query Parameters - **symbols** (List[str] | None) - Optional - A list of symbols to fetch leverage information for. - **params** (dict) - Optional - Additional parameters for the request. ### Response #### Success Response (200) - **DataFrame** (pd.DataFrame) - A DataFrame containing the leverage information. ``` -------------------------------- ### calculate_vwap_by_depth() Source: https://github.com/sigma-quantiphi/ccxt-pandas/blob/main/ccxt_pandas/calculations/README.md Calculate Volume-Weighted Average Price (VWAP) at various depth levels. ```APIDOC ## calculate_vwap_by_depth() ### Description Calculate Volume-Weighted Average Price (VWAP) at various depth levels. Useful for estimating market impact and slippage. ### Parameters - **df** (DataFrame) - Required - Order book DataFrame with price, qty, symbol, and side columns - **depths** (list) - Required - List of notional depths to calculate VWAP for - **group_by** (list) - Optional - Columns to group by (default: ['symbol', 'side'] + 'exchange') - **price_col** (string) - Optional - Name of price column (default: 'price') - **qty_col** (string) - Optional - Name of quantity column (default: 'qty') ### Response - **Returns** (DataFrame) - Columns: [*group_by, depth, qty, notional, price] where 'price' is the VWAP ```