StandX CLI 技能
StandX CLI 是一個專為 StandX 交易所打造的加密貨幣交易命令列工具。
安裝
選項 1:ClawHub(推薦 - 自動安裝)
clawhub install standx-cli
選項 2: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
- 定期輪換 token(有效期 7 天)
取得憑證
前往 https://standx.com/user/session 產生:
- JWT Token(必要) - 有效期 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 小時 K 線
standx market kline BTC-USD -r 60 --from 1d
# 最近 7 天,日 K 線
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