CLI 命令行
CLI 是独立的终端工具,无需 AI 客户端即可使用。安装后通过 toobit 命令调用。
安装
bash
npm install -g toobit-trade-cli命令格式
bash
toobit <module> <command> [options]支持的模块:market、spot、futures、account。
交易对格式
| 接口类型 | 格式 | 示例 |
|---|---|---|
| 现货(行情、深度、K 线、订单等) | 无分隔符,大写 | BTCUSDT、ETHUSDT |
| 合约(资金费率、标记价格、持仓量、多空比、合约行情、保险基金、风险限额、下单、持仓、杠杆等) | 合约格式,带连字符 | BTC-SWAP-USDT、ETH-SWAP-USDT |
命令示例
行情数据
bash
# 查询 BTC 最新价格(现货)
toobit market ticker --symbol BTCUSDT
# 24 小时行情统计(现货)
toobit market ticker-24hr --symbol ETHUSDT
# K 线数据(现货)
toobit market candles --symbol BTCUSDT --interval 1h --limit 10
# 盘口深度(现货)
toobit market depth --symbol BTCUSDT --limit 5
# 合约资金费率(需使用合约格式)
toobit market funding-rate --symbol BTC-SWAP-USDT
# 标记价格、持仓量、多空比(合约)
toobit market mark-price --symbol BTC-SWAP-USDT
toobit market open-interest --symbol BTC-SWAP-USDT
toobit market long-short-ratio --symbol BTC-SWAP-USDT
# 合约行情(合约)
toobit market contract-ticker --symbol BTC-SWAP-USDT
# 保险基金、风险限额(合约)
toobit market insurance-fund --symbol BTC-SWAP-USDT
toobit market risk-limits --symbol BTC-SWAP-USDT现货交易
bash
# 市价买入 BTC
toobit spot place --symbol BTCUSDT --side BUY --type MARKET --quantity 0.001
# 限价买入 DOGE
toobit spot place --symbol DOGEUSDT --side BUY --type LIMIT --quantity 100 --price 0.08
# 查看当前挂单
toobit spot open-orders
# 撤销订单
toobit spot cancel --orderId 123456789合约交易
bash
# 市价开多(需使用合约格式)
toobit futures place --symbol BTC-SWAP-USDT --side BUY_OPEN --orderType MARKET --quantity 1
# 查看持仓
toobit futures positions
# 查看杠杆设置(需使用合约格式)
toobit futures leverage --symbol BTC-SWAP-USDT账户管理
bash
# 查看账户信息
toobit account info
# 查看资金流水
toobit account balance-flow管道与脚本
CLI 支持 --json 参数输出 JSON 格式,方便与其他工具配合使用:
bash
# 提取价格数据
toobit market ticker --symbol BTCUSDT --json | jq '.data'
# 接入 Python 分析脚本
toobit market candles --symbol BTCUSDT --interval 1h --limit 200 --json | python3 analyze.py也可以配合 cron 定时任务实现自动化:
bash
# 每 5 分钟记录 BTC 价格
*/5 * * * * toobit market ticker --symbol BTCUSDT --json >> /var/log/btc-price.jsonl