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

@chongqingliangyunzhijing/contest-cli

v0.1.23

Published

PandaAI 期货仿真大赛命令行工具:账户、交易、授权边界,所有命令支持 --json 供 Agent 解析

Readme

@chongqingliangyunzhijing/contest-cli

PandaAI 期货仿真交易大赛 CLI。默认连接: https://www.pandaaiquant.com/openapi/v1。

安装

源码版本 0.1.23 新增品种目录和识别命令,需配套新版 OpenAPI:

panda varieties --json
panda varieties --query P --prefix --exchange DCE --json
panda resolve 聚丙烯月均价 --json
panda resolve 硅 --json

varieties 返回品种名、代码、交易所与目录启用状态;不代表实际合约当前可以交易。 resolve 不查询主力或行情,状态为 exact、ambiguous、suggested、not_found 或 unavailable。 有候选时必须先明确选择,再用完整名称或代码继续查询和预演;匹配分数不是概率。 移仓和目标仓位的真实执行使用冻结计划,复核发现合约或数量变化时返回 plan_stale,需重新预演确认。

npm 包发布后:

npm install -g @chongqingliangyunzhijing/contest-cli
panda --version

当前版本以 panda --version 输出为准;安装命令始终跟随 npm latest。

CLI 0.1.22 起,查询资金、持仓等命令会分别检查 CLI 和已安装的交易 Skill,缓存 5 分钟。JSON 结果通过 meta.update 返回检查状态及更新命令,有更新时 available 和 mustNotifyUser 为 true,AI 应在本轮回复中提醒用户。文本模式将提醒写到 stderr,不影响业务数据。检查失败不阻断查询,也不能据此判断已是最新版;报单、撤单、计划执行及回执查询只读缓存。

AI 或脚本也可显式检查并更新(--check 绕过缓存、不需要登录):

panda update --check --json
panda update --yes --client codex --global --json
# 持续监控(默认每 30 分钟;按 Ctrl+C 停止)
panda update --watch --client codex --global

不传 --yes 时只检查不更新。panda update --yes --client codex --global 在 CLI 包已最新时也会同步 Skill;项目安装省略 --global。仅更新 Skill 可使用 panda skill update --client codex --global。自动识别 Skill 时,同一客户端优先检查项目文件,再检查用户目录。

--watch 会在独立进程中持续检查,发现新版本后自动升级并重新读取 Skill/agent-spec;更新完成后重新启动当前 AI/终端进程。活动委托、未知回执或计划执行期间不要更新。旧版 CLI 需先升级一次到 0.1.22 或以上,才能获得普通查询的更新提醒。

当前包尚未发布时,可以从仓库源码运行:

cd cli
npm install
node bin/panda.js --help
npm link
panda --version

登录

本机有浏览器:

panda login

授权过程使用浏览器 OAuth + PKCE,并且复用 PandaAI 官网的统一登录页:

  • 浏览器如果已经登录官网,会直接完成赛事账户授权并回到 CLI,不需要再次输入密码;
  • 浏览器如果尚未登录,会跳转官网登录,登录完成后自动回到授权流程;
  • 授权成功后本地回调会自动跳转到赛事首页 https://www.pandaaiquant.com/contest,CLI 在后台接收一次性授权码;
  • CLI 不接触、不保存官网密码,只保存赛事 OpenAPI 签发的 token:
Windows:%USERPROFILE%\.panda\credentials.json
Linux/macOS:~/.panda/credentials.json

查看用户、参赛账户和权限:

panda whoami
panda whoami --json
panda doctor
panda logout

Claude Code / MCP

CLI 本身不需要 MCP 配置。只有使用 Claude Code 等本地 AI 进行自然语言交易时,才需要配置:

claude mcp add --transport http panda-trade https://www.pandaaiquant.com/openapi/v1/mcp

skill 安装是可选的,不能替代 MCP:

panda skill install --client claude
panda skill install --client claude --global
panda skill install --client cursor
panda skill install --client codex

账户和委托

panda account
panda position
panda positions
panda snapshot
panda quote 黄金                    # 中文品种自动解析当前主力
panda contract-spec SA2701.CZC --json # 合约乘数、四项参考保证金、最后交易日
panda orders --status active
panda orders --date today --json       # 今天下过的订单
panda trades
panda trades --date today --json       # 今天成交
panda ranking
panda ranking-me
panda ranking-config
panda settlements                 # 最近 5 个交易日结算
panda settlements --limit 30      # 最多最近 30 个交易日

panda quote <symbol> 只返回单品种最新快照,包括实际合约、最新价、涨跌幅、 日内高低、买一卖一和完整上海时间;不提供 K 线、历史行情或批量行情。下单响应也会 附带 marketQuote 供展示,但市价单仍不传委托价格。

所有命令支持 --json,适合 Agent 和脚本:

contract-spec 返回 symbol、contractMultiplier、margin、lastTradeDate。 margin 包含 longMarginRatioByMoney、shortMarginRatioByMoney(0.1 表示 10%)及 longMarginByVolume、shortMarginByVolume(元/手)。缺失值为 null,文本显示“暂无数据”; 最后交易日格式为 YYYYMMDD。支持中文品种名、品种码和实际合约,查询持仓时使用实际合约。

下单预演和冻结计划的确认摘要还会展示上述四项保证金、乘数、最后交易日及交割日。 预演规格位于 detail.contract,交割日字段为 deliveryDate;缺失显示“暂无数据”,不以最后交易日替代。

panda account --json
panda ranking --json
panda settlements --json

排行榜固定只返回前十。panda ranking --board-type live 查询实时榜; panda ranking --board-type settled 查询正式结算总榜; panda ranking --board-type settled --period month --month-id M1 查询指定月榜。 月榜编号必须从 panda ranking-config 返回的 periods 选择,不能硬编码月份含义; 结果包含交易指标和五项指标得分。ranking-me 支持相同的周期参数。

交易授权

完成 OAuth 登录后,服务端会自动启用全部合约、双向交易授权,不需要执行 panda mandate create。如需立即停止 Agent 交易,可以撤销授权:

panda mandate revoke

下单和撤单

先预演,不会真实报单:

panda order `
  --symbol au2610 `
  --direction buy `
  --offset open `
  --price 580 `
  --volume 1 `
  --dry-run

确认后正式下单:

panda order --symbol 原油 --direction buy --offset open --volume 1 --dry-run  # 开仓品种名自动解析当前主力
panda order --symbol au2610 --direction buy --offset open --volume 1  # 无价格,自动市价 IOC
panda orders --status active
panda trades
panda cancel <orderId>
panda cancel-all --dry-run --json
panda cancel-all --yes --json
panda rollover --dry-run
panda rollover --symbol 黄金 --from-contract au2508 --direction long --volume 2 --dry-run
panda rollover --symbol 黄金 --from-contract au2508 --direction long --volume 2 --client-request-id roll-001
panda close-all --dry-run
panda close-all
panda target-position --targets '[{"symbol":"黄金","direction":"long","volume":5}]' --dry-run --json

历史订单和成交默认返回最近 20 条;当前挂单使用 panda orders --status active,不能用最近历史记录代替。撤单必须使用返回的 orderId。

下单超时或状态未知时不要重复提交,先用委托查询确认。

可选环境变量

生产环境不需要设置任何变量。测试环境可覆盖服务域名:

PANDA_API_BASE=https://example.com panda doctor

Windows PowerShell:

$env:PANDA_API_BASE = 'https://example.com'
panda doctor

其他可选变量:

PANDA_CLIENT_ID
PANDA_TRADE_HOME

安全规则

  • 不要向 AI 或他人提供 credentials.json。
  • 不要把官网密码、token、数据库密码提交到 Git。
  • AI 发起的真实交易必须经过 dry-run、冻结计划和用户明确确认;交易授权由服务端自动维护。
  • 只有状态为 filled 才表示成交。
  • 下单超时后不要重复下单。