npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

alltick-agent

v1.0.0

Published

Alltick Agent - Real-time financial market data API for LLMs

Readme

Alltick Agent

实时金融市场数据 API,为 LLM 提供股票、外汇、加密货币等实时行情。

特性

  • 支持多种交易品种:加密货币、股票(美股/港股/A股)、外汇、贵金属
  • REST API 封装:K线、成交价、订单簿查询
  • WebSocket 实时行情订阅
  • MCP Server:LLM 可直接调用的工具接口
  • CLI 工具:命令行快速查询

安装

npm install @alltick/agent
# 或
pnpm add @alltick/agent

快速开始

Node.js API

import { AlltickHttpClient, DEMO_TOKEN } from '@alltick/agent';

const client = new AlltickHttpClient({ token: DEMO_TOKEN });

// 获取K线数据
const response = await client.getKline({
  code: 'BTCUSDT',
  klineType: 1,  // 1分钟K线
  queryKlineNum: 10,
});

console.log(response.data?.klines);

WebSocket 实时行情

import { AlltickWsClient, WsSubscribeType } from '@alltick/agent';

const ws = new AlltickWsClient({ token: DEMO_TOKEN });

ws.on('push', (data) => {
  console.log('实时数据:', data);
});

ws.on('connected', () => console.log('已连接'));
ws.on('authenticated', async () => {
  await ws.subscribe(['BTCUSDT', 'ETHUSDT'], WsSubscribeType.TRADE);
});

await ws.connect();

MCP Server

import { AlltickMcpServer } from '@alltick/agent';

const mcp = new AlltickMcpServer({ token: DEMO_TOKEN });

// 获取工具定义
const tools = mcp.getTools();

// 调用工具
const result = await mcp.callTool({
  name: 'get_trade',
  arguments: { code: 'BTCUSDT' },
});

CLI 工具

# 查询最新成交
alltick -s BTCUSDT

# 查询K线
alltick -s BTCUSDT -k 1h -n 50

# 实时订阅
alltick -s BTCUSDT -r

API 文档

支持的交易品种

| 类型 | 代码示例 | |------|---------| | 加密货币 | BTCUSDT, ETHUSDT, BNBUSDT | | 美股 | AAPL.US, TSLA.US, NVDA.US | | 港股 | 00700.HK, 09988.HK | | A股 | 600519.SH, 300750.SZ | | 外汇 | EURUSD, GBPUSD, USDJPY | | 贵金属 | XAUUSD (黄金), XAGUSD (白银) |

K线类型

| 类型 | 代码 | |------|------| | 1分钟 | 1 | | 5分钟 | 5 | | 15分钟 | 15 | | 30分钟 | 30 | | 1小时 | 60 | | 4小时 | 240 | | 日K | 1000 | | 周K | 2000 | | 月K | 3000 |

HTTP API 方法

  • getKline(params) - 获取K线数据
  • getTrade(params) - 获取最新成交价
  • getOrderBook(params) - 获取订单簿
  • batchGetKline(codes, klineType, num) - 批量获取K线

WebSocket 事件

  • connected - 连接成功
  • authenticated - 认证成功
  • push - 收到推送数据
  • error - 错误
  • disconnected - 连接断开
  • reconnecting - 正在重连

MCP 工具

| 工具名 | 描述 | 参数 | |--------|------|------| | get_kline | 获取K线数据 | code, kline_type, num | | get_trade | 获取最新成交价 | code | | get_orderbook | 获取订单簿 | code | | get_batch_kline | 批量获取K线 | codes, kline_type, num | | list_symbols | 列出支持的品种 | category |

类型定义

import type {
  AlltickConfig,
  KlineQuery,
  KlineType,
  TradeQuote,
  OrderBook,
  WsSubscribeType,
} from '@alltick/agent';

开发

# 安装依赖
pnpm install

# 开发模式(监听变化)
pnpm dev

# 类型检查
pnpm typecheck

# 运行测试
pnpm test

# 构建
pnpm build

# 运行测试(监听模式)
pnpm test:watch

License

MIT