depth.js
1 import { cli, Strategy } from '@jackwener/opencli/registry'; 2 3 cli({ 4 site: 'binance', 5 name: 'depth', 6 description: 'Order book bid and ask prices for a trading pair', 7 domain: 'data-api.binance.vision', 8 strategy: Strategy.PUBLIC, 9 browser: false, 10 args: [ 11 { name: 'symbol', type: 'str', required: true, positional: true, help: 'Trading pair symbol (e.g. BTCUSDT, ETHUSDT)' }, 12 { name: 'limit', type: 'int', default: 10, help: 'Number of price levels (5, 10, 20, 50, 100)' }, 13 ], 14 columns: ['rank', 'bid_price', 'bid_qty', 'ask_price', 'ask_qty'], 15 pipeline: [ 16 { fetch: { url: 'https://data-api.binance.vision/api/v3/depth?symbol=${{ args.symbol }}&limit=${{ args.limit }}' } }, 17 { map: { select: 'bids', rank: '${{ index + 1 }}', bid_price: '${{ item[0] }}', bid_qty: '${{ item[1] }}', ask_price: '${{ root.asks[index]?.[0] ?? "" }}', ask_qty: '${{ root.asks[index]?.[1] ?? "" }}' } }, 18 { limit: '${{ args.limit }}' }, 19 ], 20 });