or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

error-handling.mdexchange-management.mdindex.mdmarket-data.mdprecision.mdtrading.mdutilities.mdwebsocket.md
tile.json

exchange-management.mddocs/

Exchange Management

Exchange management provides functionality to instantiate, configure, and manage connections to 100+ supported cryptocurrency exchanges through a unified interface.

Capabilities

Exchange Instantiation

Create instances of specific exchange classes with configuration options.

/**
 * Create an exchange instance with configuration
 * Available exchanges: binance, coinbase, kraken, bitfinex, and 100+ others
 */
new ccxt.exchangeName(config?: ExchangeConfig);

interface ExchangeConfig {
  /** API key for private endpoints */
  apiKey?: string;
  /** Secret key for signing requests */
  secret?: string;
  /** User ID (required by some exchanges) */
  uid?: string;
  /** Login credential (alternative to apiKey on some exchanges) */
  login?: string;
  /** Password credential */
  password?: string;
  /** Private key for advanced authentication */
  privateKey?: string;
  /** Wallet address for specific authentication schemes */
  walletAddress?: string;
  /** Access token for OAuth-based authentication */
  token?: string;
  /** Enable sandbox/testnet mode */
  sandbox?: boolean;
  /** Request timeout in milliseconds */
  timeout?: number;
  /** Rate limiting delay in milliseconds */
  rateLimit?: number;
  /** Enable automatic rate limiting */
  enableRateLimit?: boolean;
  /** Enable verbose logging */
  verbose?: boolean;
  /** HTTP proxy configuration */
  proxy?: string;
  /** Custom User-Agent header */
  userAgent?: string;
  /** Additional exchange-specific options */
  [key: string]: any;
}

Usage Examples:

import ccxt from 'ccxt';

// Basic exchange instance
const binance = new ccxt.binance();

// Exchange with API credentials
const binanceAuth = new ccxt.binance({
  apiKey: 'your-api-key',
  secret: 'your-secret-key',
  sandbox: true, // use testnet
  enableRateLimit: true,
});

// Exchange with advanced configuration
const kraken = new ccxt.kraken({
  apiKey: 'your-api-key',
  secret: 'your-secret-key',
  timeout: 30000,
  rateLimit: 1500,
  verbose: false,
  proxy: 'http://proxy.example.com:8080',
});

Available Exchanges

Access to 100+ cryptocurrency exchanges through consistent interface.

/**
 * Object containing all available exchange classes
 * Each exchange extends the base Exchange class
 */
const exchanges: {
  [exchangeName: string]: typeof Exchange;
};

// Major exchanges include:
const binance: typeof Exchange;
const coinbase: typeof Exchange;
const kraken: typeof Exchange;
const bitfinex: typeof Exchange;
const bybit: typeof Exchange;
const okx: typeof Exchange;
const kucoin: typeof Exchange;
const gate: typeof Exchange;
const htx: typeof Exchange;
const bitget: typeof Exchange;
const bitmex: typeof Exchange;
const deribit: typeof Exchange;
const bitstamp: typeof Exchange;
const gemini: typeof Exchange;
const cryptocom: typeof Exchange;
const mexc: typeof Exchange;
const bitmart: typeof Exchange;
const phemex: typeof Exchange;
const coinex: typeof Exchange;
const probit: typeof Exchange;
// ... and 80+ more

Usage Examples:

// Create exchange instances dynamically
const exchangeName = 'binance';
const ExchangeClass = ccxt[exchangeName];
const exchange = new ExchangeClass({
  apiKey: 'your-key',
  secret: 'your-secret',
});

// List all available exchanges
console.log(ccxt.exchanges); // Array of exchange names

// Check if exchange is available
if ('binance' in ccxt) {
  const binance = new ccxt.binance();
}

Exchange Information

Access exchange metadata and capabilities.

/**
 * Exchange properties and capabilities
 */
interface Exchange {
  /** Exchange identifier */
  readonly id: string;
  /** Exchange display name */
  readonly name: string;
  /** Supported countries */
  readonly countries: string[];
  /** Exchange URLs (logo, API, documentation, etc.) */
  readonly urls: {
    logo?: string;
    api?: string | { [key: string]: string };
    test?: string | { [key: string]: string };
    www?: string;
    doc?: string[];
    fees?: string;
  };
  /** Feature support matrix */
  readonly has: {
    [feature: string]: boolean | 'emulated';
  };
  /** Rate limiting configuration */
  readonly rateLimit: number;
  /** Certification status */
  readonly certified: boolean;
  /** WebSocket support availability */
  readonly pro: boolean;
}

Usage Examples:

const exchange = new ccxt.binance();

// Exchange information
console.log(exchange.id); // 'binance'
console.log(exchange.name); // 'Binance'
console.log(exchange.countries); // ['JP', 'MT']
console.log(exchange.urls.www); // 'https://www.binance.com'

// Feature support
console.log(exchange.has.fetchTicker); // true
console.log(exchange.has.fetchOHLCV); // true
console.log(exchange.has.createOrder); // true
console.log(exchange.has.fetchOrderBook); // true

// Rate limiting
console.log(exchange.rateLimit); // 1200 (milliseconds)
console.log(exchange.enableRateLimit); // true/false

Configuration Management

Modify exchange settings after instantiation.

/**
 * Update exchange configuration
 */
interface Exchange {
  /** Current configuration options */
  options: { [key: string]: any };
  /** API credentials */
  apiKey: string;
  secret: string;
  uid?: string;
  login?: string;
  password?: string;
  /** Runtime settings */
  sandbox: boolean;
  timeout: number;
  rateLimit: number;
  enableRateLimit: boolean;
  verbose: boolean;
}

Usage Examples:

const exchange = new ccxt.binance();

// Update credentials
exchange.apiKey = 'new-api-key';
exchange.secret = 'new-secret';

// Toggle sandbox mode
exchange.sandbox = true;

// Adjust timeout
exchange.timeout = 20000;

// Enable verbose logging
exchange.verbose = true;

// Custom options
exchange.options.adjustForTimeDifference = true;
exchange.options.recvWindow = 10000;

Exchange Status

Check exchange operational status and connectivity.

/**
 * Fetch exchange operational status
 */
fetchStatus(params?: object): Promise<ExchangeStatus>;

interface ExchangeStatus {
  /** Current status */
  status: 'ok' | 'shutdown' | 'error' | 'maintenance';
  /** Last update timestamp */
  updated: number;
  /** Estimated time to resolution (if applicable) */
  eta?: number;
  /** Status page URL */
  url?: string;
  /** Additional status information */
  info: any;
}

Usage Examples:

const exchange = new ccxt.binance();

// Check exchange status
const status = await exchange.fetchStatus();
console.log(status.status); // 'ok' | 'maintenance' | 'error'
console.log(status.updated); // timestamp
console.log(status.eta); // estimated resolution time

// Handle maintenance mode
if (status.status === 'maintenance') {
  console.log('Exchange is under maintenance');
  if (status.eta) {
    console.log(`Expected back online: ${new Date(status.eta)}`);
  }
}

Server Time

Synchronize with exchange server time.

/**
 * Fetch server time from exchange
 */
fetchTime(params?: object): Promise<number>;

Usage Examples:

const exchange = new ccxt.binance();

// Get server time
const serverTime = await exchange.fetchTime();
const localTime = Date.now();
const timeDiff = serverTime - localTime;

console.log(`Server time: ${new Date(serverTime)}`);
console.log(`Time difference: ${timeDiff}ms`);

// Use for timestamp synchronization
const syncedTimestamp = Date.now() + timeDiff;