MarketDataClient
The MarketDataClient provides access to real-time market data including prices, order books, and trading pairs.
Prices
Get All Prices
const prices = await client.marketData.getPrices();
for (const price of prices) {
console.log(`${price.asset}: ${price.mid}`);
}
Get Specific Assets
const prices = await client.marketData.getPrices(['BTC', 'ETH', 'SOL']);
Get Single Asset Price
const btc = await client.marketData.getPrice('BTC');
console.log(btc);
// {
// asset: 'BTC',
// bid: '49950.00',
// ask: '50050.00',
// mid: '50000.00',
// last: '50010.00',
// volume24h: '1234.56',
// change24h: '2.5',
// high24h: '51000.00',
// low24h: '49000.00',
// timestamp: '2024-01-15T10:30:00Z'
// }
Order Books
Get Order Book
const orderBook = await client.marketData.getOrderBook('BTC', 10);
console.log('Bids:');
for (const level of orderBook.bids) {
console.log(` ${level.price}: ${level.quantity} (${level.orderCount} orders)`);
}
console.log('Asks:');
for (const level of orderBook.asks) {
console.log(` ${level.price}: ${level.quantity} (${level.orderCount} orders)`);
}
Get Multiple Order Books
const orderBooks = await client.marketData.getOrderBooks(['BTC', 'ETH'], 5);
console.log('BTC spread:', orderBooks.BTC.asks[0].price - orderBooks.BTC.bids[0].price);
console.log('ETH spread:', orderBooks.ETH.asks[0].price - orderBooks.ETH.bids[0].price);
Trading Pairs
const pairs = await client.marketData.getTradingPairs();
for (const pair of pairs) {
console.log(`${pair.asset}/${pair.quoteCurrency}`);
console.log(` Min: ${pair.minOrderSize}, Max: ${pair.maxOrderSize}`);
console.log(` Decimals: price=${pair.priceDecimals}, qty=${pair.quantityDecimals}`);
console.log(` Status: ${pair.status}`);
}
24h Statistics
// Get stats for all assets
const allStats = await client.marketData.get24hStats();
// Get stats for specific asset
const btcStats = await client.marketData.get24hStats('BTC');
console.log(btcStats[0]);
// {
// asset: 'BTC',
// volume24h: '15234567.89',
// trades24h: 12345,
// high24h: '51000.00',
// low24h: '49000.00',
// open24h: '49500.00',
// close24h: '50000.00',
// change24h: '1.01',
// timestamp: '2024-01-15T10:30:00Z'
// }
Types
import type {
Price,
OrderBook,
OrderBookLevel,
TradingPair,
Stats24h,
} from 'zenotc';
Price
| Field | Type | Description |
|---|---|---|
asset | string | Asset symbol |
bid | string | Best bid price |
ask | string | Best ask price |
mid | string | Mid price |
last | string | Last trade price |
volume24h | string | 24h volume |
change24h | string | 24h change % |
high24h | string | 24h high |
low24h | string | 24h low |
timestamp | string | ISO timestamp |
OrderBook
| Field | Type | Description |
|---|---|---|
asset | string | Asset symbol |
bids | OrderBookLevel[] | Bid levels (descending) |
asks | OrderBookLevel[] | Ask levels (ascending) |
timestamp | string | ISO timestamp |
sequence | number | Sequence number |
OrderBookLevel
| Field | Type | Description |
|---|---|---|
price | string | Price level |
quantity | string | Total quantity |
orderCount | number | Number of orders |