Crypto Currency Exchange Trading library (CCXT)

Barbotine
3 min readNov 6, 2023

--

Chapter 1: Intro.

What is CCXT?

CCXT is a is an open-source software library that aggregates CEX functions into one unified & clean SDK. It’s all you need for cross-exchange algo-trading, simulating or data ingestion.

CCXT simplifies the process of connecting to crypto exchanges, fetching market data and executing orders. Since each exchange has their own methods, CCXT aggregation makes it very simple to place, cancel and monitor orders across different Centralized Exchanges (CEXs) at once.

Advantages:

  • Price aggregation for arbitrages.
  • Scale trading bots with access to more liquidity.
  • Richer technical analysis through larger market datasets.

Supported exchanges:

  • Top-tier exchanges like Binance, Coinbase, Kraken & OKX.
  • + 93 cryptocurrency CEX markets (97 total, available here).

Structure.

CCXT has public and private, authenticated, methods; like all individual CEXs market data is public and accessible through it’s API, but user data and order execution requires API keys to access.

Remember to properly hide your API Key & Secret in an .env file !

Apart from the different methods available to interact with CCXT, and depending on what you are working on, you need to get familiar with unified structures. Mainly:

Supported languages:

# Python
import ccxt
print (ccxt.exchanges)
// JavaScript & TypeScript
const ccxt = require ('ccxt')
console.log (ccxt.exchanges)
// PHP
include 'ccxt.php';
var_dump (\ccxt\Exchange::$exchanges);
// C# => In Beta!
using ccxt;
Console.WriteLine(ccxt.Exchanges) // check this later

Connect to an exchange.

# Example in Python
bitfinex = ccxt.binance()
binance.apiKey = 'YOUR_BINANCE_API_KEY' #<-- Fetch from .env !
binance.secret = 'YOUR_BINANCE_SECRET' #<-- Fetch from .env !

In case this connection fails, make sure to check the exchange’s required credentials.

Stream Data through public API.

Basic MACD example below, but you can test out CCXT’s examples.

Place trades using “exchange.createOrder” / “exchange.createOrders” !

In the next chapter we will deep-dive into some example use-cases for CCXT in algo-trading and technical analysis. Stay tuned ! ⚡ ⚡ ⚡

--

--

Barbotine
Barbotine

Written by Barbotine

Join our small community of project owners, traders, developers and beginners! (barbotine.xyz)

No responses yet