-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
tickers
github-actions[bot] edited this page Jun 11, 2026
·
2 revisions
import ccxt from '../../js/ccxt.js';
import asTable from 'as-table';
import ansicolor from 'ansicolor';
import ololog from 'ololog';
const log = ololog.configure ({ locate: false }), verbose = process.argv.includes ('--verbose');
ansicolor.nice
//-----------------------------------------------------------------------------
let printSupportedExchanges = function () {
log ('Supported exchanges:', ccxt.exchanges.join (', ').green)
}
let printUsage = function () {
log ('Usage: node', process.argv[1], 'id'.green, '[symbol]'.yellow)
printSupportedExchanges ()
}
let printSymbols = function (exchange) {
log (id.green, 'has', exchange.symbols.length, 'symbols:', exchange.symbols.join (', ').yellow)
}
let sleep = (ms) => new Promise (resolve => setTimeout (resolve, ms))
let printTicker = async (exchange, symbol) => {
let ticker = await exchange.fetchTicker (symbol)
log (exchange.id.green, symbol.yellow, 'ticker',
ticker['datetime'],
'high: ' + ticker['high'],
'low: ' + ticker['low'],
'bid: ' + ticker['bid'],
'ask: ' + ticker['ask'],
'volume: ' + ticker['baseVolume'])
return ticker
}
//-----------------------------------------------------------------------------
let printTickers = async (id) => {
log ('Instantiating', id.green, 'exchange exchange')
// instantiate the exchange by id
let exchange = new ccxt[id] ({ verbose })
// load all markets from the exchange
let markets = await exchange.loadMarkets ()
if (process.argv.length > 3) { // if a symbol was supplied, get that symbol only
let symbol = process.argv[3]
await printTicker (exchange, symbol)
} else { // otherwise run through all symbols one by one
for (let symbol of exchange.symbols)
if ((symbol.indexOf ('.d') < 0)) { // skip darkpool symbols
const market = exchange.markets[symbol];
if (!market['active']) {
log.red (exchange.id + ' ' + symbol + ' inactive');
continue;
}
await sleep (exchange.rateLimit)
await printTicker (exchange, symbol)
}
}
}
//-----------------------------------------------------------------------------
;(async function main () {
if (process.argv.length > 2) {
let id = process.argv[2]
// check if the exchange is supported by ccxt
let exchangeFound = ccxt.exchanges.indexOf (id) > -1
if (exchangeFound) {
await printTickers (id)
} else {
log ('Exchange ' + id.red + ' not found')
printUsage ()
}
} else {
printUsage ()
}
process.exit ()
}) ()(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
- fetchCurrencies
- alpaca
- apex
- ascendex
- aster
- backpack
- bigone
- binance
- bingx
- bit2c
- bitbank
- bitbns
- bitfinex
- bitflyer
- bitget
- bithumb
- bitmart
- bitmex
- bitopro
- bitrue
- bitso
- bitstamp
- bitteam
- bittrade
- bitvavo
- blockchaincom
- blofin
- btcbox
- btcmarkets
- btcturk
- bullish
- bybit
- bydfi
- cex
- coinbase
- coinbaseexchange
- coinbaseinternational
- coincheck
- coinex
- coinmate
- coinmetro
- coinone
- coinsph
- coinspot
- cryptocom
- cryptomus
- deepcoin
- delta
- deribit
- derive
- digifinex
- dydx
- exmo
- extended
- foxbit
- gate
- gemini
- grvt
- hashkey
- hibachi
- hitbtc
- hollaex
- htx
- hyperliquid
- independentreserve
- indodax
- kraken
- krakenfutures
- kucoin
- fetchBidsAsks
- latoken
- lbank
- lighter
- luno
- mercado
- mexc
- modetrade
- ndax
- novadax
- okx
- onetrading
- p2b
- pacifica
- paradex
- paymium
- phemex
- poloniex
- tokocrypto
- toobit
- upbit
- weex
- whitebit
- woo
- woofipro
- xt
- zaif
- fetchStatus