htx-spot-trading

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

HTX Spot Trading

HTX 现货交易

Spot order placement / cancellation and margin borrow-lend. HIGH RISK. Every write operation changes real fund balances and must be confirmed by the user before execution (Human-in-the-Loop).
现货订单挂单/撤单及保证金借贷。高风险。所有写入操作都会改变真实资金余额,执行前必须经过用户确认(人机协作)。

When to use this skill

何时使用该技能

  • "Market-buy 0.1 BTC"
  • "Place a limit buy on ETH at 3500"
  • "Cancel all my BTC/USDT open orders"
  • "Borrow USDT and long ETH on margin"
  • "Repay my margin loan"
  • "Show my order history / fills"
  • "市价买入0.1 BTC"
  • "以3500的价格挂限价单买入ETH"
  • "取消我所有BTC/USDT的未成交订单"
  • "借入USDT并进行ETH保证金做多"
  • "偿还我的保证金贷款"
  • "查看我的订单历史/成交记录"

Underlying tool

底层工具

Drives
htx-cli
. Binary on
$PATH
or
$HTX_CLI_BIN
. Always
--json
.
Configure credentials once:
bash
htx-cli config set-key    <AccessKeyId>
htx-cli config set-secret <SecretKey>
Key must have trade permission enabled (and margin if using margin endpoints).
基于
htx-cli
驱动。二进制文件需在
$PATH
$HTX_CLI_BIN
路径下。始终使用
--json
参数。
只需配置一次凭证:
bash
htx-cli config set-key    <AccessKeyId>
htx-cli config set-secret <SecretKey>
密钥必须启用交易权限(若使用保证金端点,还需启用保证金权限)。

Mandatory confirmation flow

强制确认流程

Before any write operation, present to the user:
FieldShown value
Actionplace / cancel / batch-cancel / margin-borrow / margin-repay
Symbole.g.
btcusdt
Sidebuy / sell
Type
buy-limit
,
sell-limit
,
buy-market
,
sell-market
,
buy-ioc
,
sell-ioc
,
buy-limit-maker
, etc.
Amountquantity (and whether base or quote)
Pricelimit price (omit for market)
Accountspot / margin / super-margin account id
Estimated costprice × amount
Proceed only after an explicit affirmative ("yes", "confirm", "go"). For batch cancels, list the IDs first.
在执行任何写入操作前,需向用户展示以下信息:
字段展示值
操作挂单 / 撤单 / 批量撤单 / 保证金借入 / 保证金偿还
交易对例如
btcusdt
方向买入 / 卖出
类型
buy-limit
,
sell-limit
,
buy-market
,
sell-market
,
buy-ioc
,
sell-ioc
,
buy-limit-maker
数量交易量(注明是基础货币还是计价货币)
价格限价(市价单可省略)
账户现货 / 保证金 / 超级保证金账户ID
预估成本价格 × 数量
仅在用户明确确认(如“是”“确认”“执行”)后才可继续操作。批量撤单时,需先列出待撤单的ID。

Endpoint catalog (11)

端点目录(11个)

Order operations (7)

订单操作(7个)

#MethodEndpointCLI invocationRW
1POST
/v1/order/orders/place
htx-cli spot order place --account-id <id> --symbol <symbol> --type <type> --amount <n> [--price <p>] [--client-order-id <coid>] --json
W
2POST
/v1/order/orders/{id}/cancel
htx-cli spot order cancel <order-id> --json
W
3POST
/v1/order/orders/batchcancel
htx-cli spot call POST /v1/order/orders/batchcancel --body '{"order-ids":["..."]}' --json
W
4GET
/v1/order/orders/{id}
htx-cli spot order query <order-id> --json
R
5GET
/v1/order/orders
htx-cli spot order list --symbol <symbol> --states <states> --json
R
6GET
/v1/order/orders/getClientOrder
htx-cli spot call GET /v1/order/orders/getClientOrder --query clientOrderId=<coid> --json
R
7GET
/v1/order/matchresults
htx-cli spot call GET /v1/order/matchresults --query symbol=<symbol> --json
R
序号请求方法端点CLI调用命令读写类型
1POST
/v1/order/orders/place
htx-cli spot order place --account-id <id> --symbol <symbol> --type <type> --amount <n> [--price <p>] [--client-order-id <coid>] --json
2POST
/v1/order/orders/{id}/cancel
htx-cli spot order cancel <order-id> --json
3POST
/v1/order/orders/batchcancel
htx-cli spot call POST /v1/order/orders/batchcancel --body '{"order-ids":["..."]}' --json
4GET
/v1/order/orders/{id}
htx-cli spot order query <order-id> --json
5GET
/v1/order/orders
htx-cli spot order list --symbol <symbol> --states <states> --json
6GET
/v1/order/orders/getClientOrder
htx-cli spot call GET /v1/order/orders/getClientOrder --query clientOrderId=<coid> --json
7GET
/v1/order/matchresults
htx-cli spot call GET /v1/order/matchresults --query symbol=<symbol> --json

Margin loan (4)

保证金借贷(4个)

#MethodEndpointCLI invocationRW
1POST
/v1/margin/orders
htx-cli spot call POST /v1/margin/orders --body '{"symbol":"btcusdt","currency":"usdt","amount":"..."}' --json
W
2POST
/v1/margin/orders/{id}/repay
htx-cli spot call POST /v1/margin/orders/<id>/repay --body '{"amount":"..."}' --json
W
3GET
/v1/margin/loan-orders
htx-cli spot call GET /v1/margin/loan-orders --query symbol=<symbol> --json
R
4GET
/v1/margin/accounts/balance
htx-cli spot call GET /v1/margin/accounts/balance --query symbol=<symbol> --json
R
序号请求方法端点CLI调用命令读写类型
1POST
/v1/margin/orders
htx-cli spot call POST /v1/margin/orders --body '{"symbol":"btcusdt","currency":"usdt","amount":"..."}' --json
2POST
/v1/margin/orders/{id}/repay
htx-cli spot call POST /v1/margin/orders/<id>/repay --body '{"amount":"..."}' --json
3GET
/v1/margin/loan-orders
htx-cli spot call GET /v1/margin/loan-orders --query symbol=<symbol> --json
4GET
/v1/margin/accounts/balance
htx-cli spot call GET /v1/margin/accounts/balance --query symbol=<symbol> --json

Order types

订单类型

See
references/order-types.md
. Common values for
--type
:
  • buy-limit
    ,
    sell-limit
    — limit order
  • buy-market
    ,
    sell-market
    — market order (for
    buy-market
    ,
    amount
    is quote currency)
  • buy-ioc
    ,
    sell-ioc
    — immediate-or-cancel
  • buy-limit-maker
    ,
    sell-limit-maker
    — post-only
  • buy-stop-limit
    ,
    sell-stop-limit
    — stop-limit
  • buy-limit-fok
    ,
    sell-limit-fok
    — fill-or-kill
详见
references/order-types.md
--type
参数的常见取值:
  • buy-limit
    ,
    sell-limit
    — 限价单
  • buy-market
    ,
    sell-market
    — 市价单(
    buy-market
    amount
    为计价货币)
  • buy-ioc
    ,
    sell-ioc
    — 立即成交或取消
  • buy-limit-maker
    ,
    sell-limit-maker
    — 只做市
  • buy-stop-limit
    ,
    sell-stop-limit
    — 止损限价单
  • buy-limit-fok
    ,
    sell-limit-fok
    — 全部成交或取消

Safety checklist

安全检查清单

Before any write:
  • Fetch current price via
    htx-cli spot market ticker <symbol> --json
    and show the distance from the user's price
  • Show quantity, price, and estimated total cost
  • For margin borrow: show borrow rate and the liquidation price implied by the position
  • For batch cancel: list the order IDs that will be cancelled
  • Wait for explicit confirmation ("yes" / "confirm")
  • Emit the CLI command, capture its JSON response, report success/failure
执行任何写入操作前:
  • 通过
    htx-cli spot market ticker <symbol> --json
    获取当前价格,并展示与用户指定价格的差值
  • 展示交易量、价格及预估总成本
  • 保证金借入:展示借款利率及仓位对应的清算价格
  • 批量撤单:列出待取消的订单ID
  • 等待用户明确确认(“是” / “确认”)
  • 执行CLI命令,捕获JSON响应,报告操作成功/失败

Typical session

典型会话

bash
undefined
bash
undefined

1. Check price

1. 查询价格

htx-cli spot market ticker btcusdt --json
htx-cli spot market ticker btcusdt --json

2. Find account id

2. 查询账户ID

htx-cli spot account list --json # type=spot
htx-cli spot account list --json # type=spot

3. Confirm with user, then place order

3. 用户确认后,挂单

htx-cli spot order place --account-id 123 --symbol btcusdt
--type buy-limit --amount 0.01 --price 82000 --json
htx-cli spot order place --account-id 123 --symbol btcusdt
--type buy-limit --amount 0.01 --price 82000 --json

4. Monitor

4. 监控订单

htx-cli spot order query <order-id> --json
undefined
htx-cli spot order query <order-id> --json
undefined

References

参考资料

  • references/authentication.md
  • references/order-types.md
  • references/authentication.md
  • references/order-types.md