StandX CLI 技能说明
StandX CLI 是一款专为 StandX 交易所设计的加密货币交易命令行工具。
安装
方式一:ClawHub(推荐 - 自动安装)
clawhub install standx-cli
方式二:Homebrew
安全提示: 这使用了第三方 tap。你可以在安装前检查公式源代码:
# 查看公式源代码 curl -sL https://raw.githubusercontent.com/wjllance/homebrew-standx-cli/main/standx-cli.rb # 然后安装 brew tap wjllance/standx-cli brew install standx-cli
brew tap wjllance/standx-cli
brew install standx-cli
快速开始
检查安装:
standx --version
查看 BTC 价格:
standx market ticker BTC-USD
# 或者使用短别名
standx m t BTC-USD
命令简写别名
StandX CLI 支持短别名以加快输入速度:
| 完整命令 | 短别名 |
|---|---|
standx market ticker | standx m t |
standx market depth | standx m d |
standx market kline | standx m k |
standx account balances | standx a b |
standx account positions | standx a p |
standx account orders | standx a o |
standx portfolio snapshot | standx p s |
standx dashboard --watch | standx d -w |
认证
大多数命令需要认证。StandX CLI 支持多种安全认证方式。
环境变量(推荐)
最安全的认证方式。凭据不会存储在 shell 历史记录或命令日志中。
# 添加到 ~/.bashrc 或 ~/.zshrc
export STANDX_JWT="your_jwt_token"
export STANDX_PRIVATE_KEY="your_ed25519_private_key"
# 重新加载 shell 配置
source ~/.bashrc
安全最佳实践:
- 切勿在命令中硬编码凭据(会出现在 shell 历史记录中)
- 切勿将凭据提交到版本控制
- 对包含凭据的文件设置权限为 600
- 定期轮换令牌(令牌 7 天后过期)
获取凭据
访问 https://standx.com/user/session 以生成:
- JWT 令牌(必需) - 有效期 7 天,用于读取账户数据
- Ed25519 私钥(可选但推荐) - 用于交易操作
验证认证
standx auth status
其他认证方式
交互式登录
适用于首次设置或测试:
standx auth login --interactive
基于文件的登录
适用于环境变量不可用的自动化脚本:
# 将凭据存储在设置了限制权限的文件中
echo "your_jwt_token" > ~/.standx_token
echo "your_private_key" > ~/.standx_key
chmod 600 ~/.standx_token ~/.standx_key
# 使用文件登录
standx auth login --token-file ~/.standx_token --key-file ~/.standx_key
⚠️ 避免在生产环境中使用以下方式:
# 危险:凭据将在 shell 历史记录中可见
standx auth login --token "your_token" --private-key "your_key"
退出登录
standx auth logout
市场数据(无需认证)
列出交易对
standx market symbols
获取行情
standx market ticker BTC-USD
standx market ticker ETH-USD
订单簿深度
standx market depth BTC-USD --limit 10
K 线(蜡烛图)数据
# 最近 24 小时,1 小时蜡烛
standx market kline BTC-USD -r 60 --from 1d
# 最近 7 天,日线蜡烛
standx market kline BTC-USD -r 1D --from 7d
# 指定日期范围
standx market kline BTC-USD -r 60 --from 2024-01-01 --to 2024-01-07
资金费率
standx market funding BTC-USD --days 7
账户与交易(需要认证)
账户信息
standx account balances
standx account positions
standx account orders
standx account history --limit 20
创建订单
# 限价买入
standx order create BTC-USD buy limit --qty 0.01 --price 60000
# 市价卖出
standx order create BTC-USD sell market --qty 0.01
取消订单
standx order cancel BTC-USD --order-id 123456
standx order cancel-all BTC-USD
交易历史
standx trade history BTC-USD --from 7d
仪表盘与投资组合(需要认证)
实时仪表盘
带自动刷新的交互式交易仪表盘:
# 启动带自动刷新的仪表盘(监视模式)
standx dashboard --watch
# 特定交易对的仪表盘
standx dashboard --symbols BTC-USD,ETH-USD
# 自定义刷新间隔(秒)的仪表盘
standx dashboard --watch --interval 5
仪表盘功能:
- 实时账户余额显示
- 带盈亏的活跃持仓
- 未成交订单摘要
- 订单簿深度可视化
- 最近交易面板(买入/卖出)
- 自动刷新,优雅退出(Ctrl+C)
投资组合快照
查看投资组合摘要和表现:
# 投资组合快照
standx portfolio snapshot
# 短别名
standx p s
杠杆与保证金(需要认证)
# 查询杠杆
standx leverage get BTC-USD
# 设置杠杆
standx leverage set BTC-USD 10
# 查询保证金模式
standx margin mode BTC-USD
# 设置保证金模式
standx margin mode BTC-USD --set isolated
实时流式传输
公共数据流(无需认证)
# 价格流
standx stream price BTC-USD
# 订单簿流
standx stream depth BTC-USD --levels 5
# 交易流
standx stream trade BTC-USD
用户数据流(需要认证)
standx stream order # 订单更新
standx stream position # 持仓更新
standx stream balance # 余额更新
standx stream fills # 成交更新
输出格式
# JSON 输出
standx -o json market ticker BTC-USD
# CSV 导出
standx -o csv market symbols > symbols.csv
# 静默模式(仅输出值)
standx -o quiet config get base_url
特殊模式
OpenClaw 模式(AI 优化的 JSON)
standx --openclaw market ticker BTC-USD
试运行(预览而不执行)
standx --dry-run order create BTC-USD buy limit --qty 0.01 --price 60000