CCXT Pro Manual: WebSocket Streaming for Crypto Trading

·

The CCXT Pro library is a powerful, open-source extension of the popular CCXT framework, designed to bring real-time data and trading capabilities to developers through WebSocket streaming. Built on top of the widely used CCXT library, CCXT Pro enables seamless integration with over 60 cryptocurrency exchanges using a unified, asynchronous API.

Whether you're building high-frequency trading bots, real-time dashboards, or automated portfolio managers, CCXT Pro delivers low-latency access to live market data, account balances, orders, and more—without relying on traditional REST polling.

This comprehensive guide explores how to use CCXT Pro effectively, covering its architecture, key features, supported exchanges, and best practices for implementation.


What Is CCXT Pro?

CCXT Pro extends the functionality of the standard CCXT library by adding WebSocket-based streaming methods that allow developers to receive real-time updates from exchanges. While CCXT uses REST APIs for request-response interactions, CCXT Pro introduces watch* methods that establish persistent connections for continuous data flow.

It supports multiple programming languages—including JavaScript/TypeScript, Python, and PHP—and leverages language-specific async patterns like promises, futures, and event loops.

👉 Discover how real-time trading tools can enhance your strategy development.


Core Architecture and Design

CCXT Pro builds upon the foundation of CCXT using language-specific inheritance models:

This ensures full compatibility with existing CCXT workflows while introducing new streaming capabilities. The library uses a transpiler system for consistent behavior across languages.

At its core, CCXT Pro maintains a layered structure:

User
│
├── Unified CCXT Pro API (watchBalance, watchOrderBook, etc.)
│
├── Underlying Exchange-Specific APIs
│
└── CCXT Pro Base Exchange Class (built on CCXT)

All unified methods mirror their REST counterparts but replace fetch* with watch*, enabling real-time equivalents.

Unified Streaming Methods

Public Data Streams

Private User Streams

WebSocket Trading Actions

Each watch* method has a corresponding unWatch* method to unsubscribe and free resources.


Supported Exchanges

CCXT Pro currently supports 65+ cryptocurrency exchanges with native WebSocket APIs. These include major platforms such as:

This list continues to grow as more exchanges adopt WebSocket-based endpoints. For the most up-to-date support matrix, refer to the official repository.

While many exchanges offer public market data streams (e.g., order books and trades), not all support private feeds or WebSocket-based trading actions. Developers should verify exchange capabilities using the .has property.


Prerequisites for Using CCXT Pro

Before diving into CCXT Pro, users should be familiar with:

Developers must also understand streaming fundamentals such as connection management, incremental updates ("deltas"), and caching mechanisms.

👉 Learn how to build responsive trading systems with low-latency data feeds.


How Streaming Works in CCXT Pro

When you call a watch* method for the first time, CCXT Pro automatically:

  1. Establishes a WebSocket connection.
  2. Subscribes to the requested data feed.
  3. Handles authentication for private streams.
  4. Manages reconnections and rate limits transparently.

If the connection drops, the library retries with exponential backoff. You don't need to manually manage connectivity—CCXT Pro handles it under the hood.

Two Types of Streaming Interfaces

TypeDescription
Sub (Subscribe)One-way data feed from exchange to client (e.g., live trades). Most common.
Pub (Publish)Bidirectional communication allowing order placement and cancellation over WebSocket. Less common.

Many exchanges only support Sub for public data and require REST for Pub actions like placing orders. However, some advanced platforms (like OKX and Bybit) offer full WebSocket trading.


Incremental Data Structures and Caching

Due to the nature of real-time feeds, exchanges often send only delta updates—changes since the last state—rather than full snapshots. To reconstruct complete objects (like an order book), CCXT Pro maintains local caches called incremental structures.

For example:

Cached data includes:

By default, each cache holds up to 1000 entries. This can be configured:

import ccxt.pro as ccxtpro

exchange = ccxtpro.binance({
    'options': {
        'tradesLimit': 500,
        'OHLCVLimit': 2000,
        'ordersLimit': 1000
    }
})
⚠️ Cache limits must be set before calling any watch* methods.

New Updates Mode

To receive only the latest changes (not full cached arrays), enable newUpdates: True:

exchange = ccxtpro.binance({'newUpdates': True})
while True:
    trades = await exchange.watchTrades('BTC/USDT')
    print("New trades:", trades)  # Only new entries since last call

This mode will become the default in future versions.


Real-Time vs Throttled Execution Modes

CCXT Pro supports two primary execution patterns:

1. Real-Time Mode

while (true) {
    const orderbook = await exchange.watchOrderBook('BTC/USDT');
    console.log('Updated:', orderbook.bids[0], orderbook.asks[0]);
}

2. Throttling Mode

await exchange.watchOrderBook('BTC/USDT');
while (true) {
    console.log(exchange.orderbooks['BTC/USDT'].limit(10));
    await exchange.sleep(100); // Check every 100ms
}

Choose based on your algorithm’s responsiveness needs and resource constraints.


Frequently Asked Questions

Q: Can I use CCXT Pro without knowing CCXT?

A: It's strongly recommended to master standard CCXT first. CCXT Pro builds directly on its concepts—markets, symbols, error handling—and assumes familiarity with REST-based workflows.

Q: Do all exchanges support WebSocket trading?

A: No. While most support streaming market data (watchOrderBook, watchTrades), only select exchanges allow placing or canceling orders over WebSocket (createOrderWs, etc.). Always check exchange.has['createOrderWs'].

Q: How does authentication work?

A: Same as CCXT—use your API keys. For private streams like watchBalance, pass credentials during instantiation:

exchange = ccxtpro.binance({
    'apiKey': 'YOUR_KEY',
    'secret': 'YOUR_SECRET'
})

Q: What happens when the connection fails?

A: CCXT Pro automatically reconnects with exponential backoff. Your watch* calls will resume once the connection is restored.

Q: Can I process raw WebSocket messages?

A: Yes! Override the handleMessage() method to intercept raw messages:

class MyExchange(ccxtpro.binance):
    def handle_message(self, client, message):
        print("Raw:", message)
        super().handle_message(client, message)

Q: Is OHLCV streaming reliable for trading signals?

A: Not always. Many exchanges calculate candles server-side with delays (up to seconds). For precise timing, rebuild OHLCV locally from watchTrades using build_ohlcvc().


Getting Started: Instantiation Examples

JavaScript

const ccxtpro = require('ccxt').pro;
const exchange = new ccxtpro.binance({ newUpdates: false });

Python

import ccxt.pro as ccxtpro
import asyncio

async def main():
    exchange = ccxtpro.kraken()
    orderbook = await exchange.watch_order_book('BTC/USD')
    print(orderbook['bids'][0], orderbook['asks'][0])
    await exchange.close()

asyncio.run(main())

PHP

require_once 'vendor/autoload.php';
$exchange = new \ccxt\pro\kucoin();

Final Thoughts

CCXT Pro bridges the gap between traditional polling-based crypto trading and modern, real-time applications. With its unified interface, robust error handling, and cross-language support, it empowers developers to build responsive, scalable trading systems with minimal overhead.

Whether you're monitoring microsecond-level price movements or managing complex multi-exchange portfolios, CCXT Pro provides the tools you need—backed by a mature ecosystem and active community.

👉 Start building smarter trading algorithms with real-time data access today.