-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
load markets to files
github-actions[bot] edited this page Jun 24, 2026
·
3 revisions
// @NO_AUTO_TRANSPILE
import ccxt from '../../js/ccxt.js';
import path from 'path';
import fs from 'fs';
const enableRateLimit = true,
// exchange defaults
// ------------------------------------------------------------------------
// path to your folder, for example '/myproject/markets' or 'C:/myproject/markets'
options = { enableRateLimit },
// writes to current working directory if left empty
// ------------------------------------------------------------------------
// use a reasonable value for maxConcurrency to avoid network congestion
// a burst of requests in a short period of time will cause
// excessive competition for networking resources within the application
folder = '', maxConcurrency = 7;
async function main() {
const allExchanges = ccxt.exchanges.map(id => {
try {
return new ccxt[id](options);
}
catch (e) {
console.log('Failed to initialize', id, e.constructor.name);
}
}).filter(x => x), allExchangesByIds = ccxt.indexBy(allExchanges, 'id'), exchangeIds = Object.keys(allExchangesByIds);
const load = async () => {
while (exchangeIds.length > 0) {
const id = exchangeIds.pop();
const exchange = allExchangesByIds[id];
const file = path.join(folder, `saved-markets-${exchange.id}.json`);
try {
await exchange.loadMarkets();
const { id, markets } = exchange;
await fs.promises.writeFile(file, JSON.stringify({ id, markets }));
console.log('Loaded markets from', id, 'to', file);
}
catch (e) {
console.log('Failed to load markets from', id, 'to', file, e.constructor.name);
}
}
};
const started = ccxt.milliseconds();
const loaders = Array(maxConcurrency).fill().map(x => load());
await Promise.all(loaders);
const stopped = ccxt.milliseconds();
console.log('Done loading', allExchanges.length, 'exchanges in', ((stopped - started) / 1000).toFixed(2), 'seconds');
// other code...
}
main();(If the page is not being rendered for you, you can refer to the mirror at https://docs.ccxt.com/)
- Install
- Examples
- Manual
- CCXT Pro
- Contributing
- Supported Exchanges
- Exchanges By Country
- API Spec By Method
- FAQ
- Changelog
- Awesome
- API Spec by Exchange
- alpaca
- apex
- aster
- backpack
- bigone
- binance
- bingx
- bit2c
- bitbank
- bitbns
- bitfinex
- bitflyer
- bitget
- bithumb
- bitmex
- bitopro
- bitrue
- bitso
- bitstamp
- bitteam
- bittrade
- bitvavo
- blockchaincom
- blofin
- btcbox
- btcmarkets
- btcturk
- btse
- bullish
- bybit
- bydfi
- cex
- coinbase
- coinbaseexchange
- coinbaseinternational
- coincheck
- coinex
- coinmate
- coinone
- coinsph
- coinspot
- cryptocom
- cryptomus
- deepcoin
- delta
- deribit
- derive
- digifinex
- dydx
- extended
- foxbit
- gate
- gemini
- grvt
- hashkey
- hibachi
- hitbtc
- hollaex
- htx
- hyperliquid
- independentreserve
- indodax
- kraken
- krakenfutures
- kucoin
- kucoinfutures
- latoken
- lbank
- lighter
- luno
- mercado
- mexc
- modetrade
- mudrex
- nado
- ndax
- okx
- onetrading
- p2b
- pacifica
- paradex
- paymium
- phemex
- poloniex
- revolutx
- tokocrypto
- toobit
- upbit
- weex
- whitebit
- woo
- woofipro
- xt
- zaif
- zebpay
- API Spec by Prediction Exchange