Files
jackwener__opencli/clis/binance/top.js
jakevin 00e200b0b7 migrate: move binance adapters from src/clis/ to clis/ (#967)
Binance was the only adapter left in src/clis/ after the TS→JS
migration (PR #928). Move all 11 adapters and the test file to
clis/binance/, strip TypeScript syntax from the test, and switch
the test import to the @jackwener/opencli/pipeline package export.
2026-04-11 21:21:52 +08:00

22 lines
1.1 KiB
JavaScript

import { cli, Strategy } from '@jackwener/opencli/registry';
cli({
site: 'binance',
name: 'top',
description: 'Top trading pairs by 24h volume on Binance',
domain: 'data-api.binance.vision',
strategy: Strategy.PUBLIC,
browser: false,
args: [
{ name: 'limit', type: 'int', default: 20, help: 'Number of trading pairs' },
],
columns: ['rank', 'symbol', 'price', 'change_24h', 'high', 'low', 'volume'],
pipeline: [
{ fetch: { url: 'https://data-api.binance.vision/api/v3/ticker/24hr' } },
{ map: { symbol: '${{ item.symbol }}', price: '${{ item.lastPrice }}', change_24h: '${{ item.priceChangePercent }}', high: '${{ item.highPrice }}', low: '${{ item.lowPrice }}', volume: '${{ item.quoteVolume }}', sort_volume: '${{ Number(item.quoteVolume) }}' } },
{ sort: { by: 'sort_volume', order: 'desc' } },
{ map: { rank: '${{ index + 1 }}', symbol: '${{ item.symbol }}', price: '${{ item.lastPrice }}', change_24h: '${{ item.priceChangePercent }}', high: '${{ item.highPrice }}', low: '${{ item.lowPrice }}', volume: '${{ item.quoteVolume }}' } },
{ limit: '${{ args.limit }}' },
],
});