htx-futures-trading

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

HTX USDT-M Futures Trading

HTX USDT本位永续合约交易

USDT-margined perpetual futures trading. HIGH RISK. Leverage amplifies losses — liquidation can wipe a position. Every write operation must be confirmed by the user before execution.
USDT保证金永续合约交易。高风险提示。杠杆会放大亏损——强制平仓可能导致持仓全部清零。所有写入操作执行前必须经用户确认

When to use this skill

何时使用该技能

  • "Open a 10x long on BTC-USDT cross at 85000"
  • "Close all my ETH perp positions"
  • "Flash-close my BTC position"
  • "Set TP 90000 / SL 82000 on my BTC long"
  • "Place a trigger order to open short if BTC drops to 80000"
  • "Change my leverage from 10x to 20x"
  • "Cancel all my open orders and strategy orders"
  • "在BTC-USDT全仓模式下开10倍多单,价格85000"
  • "平仓我所有的ETH永续合约持仓"
  • "闪电平仓我的BTC持仓"
  • "为我的BTC多单设置止盈90000 / 止损82000"
  • "设置触发单,当BTC跌至80000时开空单"
  • "将我的杠杆从10倍调整为20倍"
  • "撤销我所有的挂单和策略单"

Underlying tool

底层工具

Drives
htx-cli
. Binary on
$PATH
or
$HTX_CLI_BIN
. Always
--json
.
bash
htx-cli config set-key    <AccessKeyId>
htx-cli config set-secret <SecretKey>
Key must have trade permission. Futures base URL defaults to
https://api.hbdm.com
.
基于
htx-cli
驱动。二进制文件需在
$PATH
$HTX_CLI_BIN
路径下。始终使用
--json
参数。
bash
htx-cli config set-key    <AccessKeyId>
htx-cli config set-secret <SecretKey>
密钥必须拥有交易权限。期货基础URL默认值为
https://api.hbdm.com

Mandatory confirmation flow

强制确认流程

Before any write, present to the user:
FieldValue
Actionplace / cancel / cancel-all / flash-close / leverage-change / position-mode / trigger / TP-SL
Contracte.g.
BTC-USDT
Modeisolated / cross
Directionbuy (long) / sell (short); open / close
Quantitycontracts
Order typelimit / market / post-only / FOK / IOC
Pricelimit price, omit for market
Leveragecurrent and new (when changing)
Estimated liquidation pricecritical for user to see before confirming
Require an explicit "yes" / "confirm". For batch cancels, list IDs first. For flash-close, show current unrealized PnL.
任何写入操作执行前,需向用户展示以下信息:
字段内容
操作类型下单/撤单/全部撤单/闪电平仓/调整杠杆/切换持仓模式/触发单/止盈止损单
合约例如:
BTC-USDT
模式逐仓/全仓
方向买入(多)/卖出(空);开仓/平仓
数量合约张数
订单类型限价/市价/只做maker/立即成交剩余撤销/立即全部成交否则撤销
价格限价价格,市价单可省略
杠杆当前杠杆与新杠杆(调整杠杆时)
预估强平价格用户确认前必须查看的关键信息
需用户明确回复"yes"或"confirm"确认。批量撤单时,需先列出订单ID。闪电平仓时,需展示当前未实现盈亏。

Endpoint catalog (50)

端点目录(50个)

All paths base at
/linear-swap-api
. Mode column:
I
= isolated,
C
= cross,
*
= both / general.
所有路径均基于
/linear-swap-api
。模式列:
I
=逐仓,
C
=全仓,
*
=通用/两者皆可。

Base orders & position controls (14)

基础订单与持仓控制(14个)

#MethodPathCLIModeRW
1POST
/v1/swap_order
htx-cli futures order place --contract-code <c> --direction <buy/sell> --offset <open/close> --lever-rate <n> --volume <n> [--price <p>] [--order-price-type limit/opponent/optimal_20/post_only/ioc/fok] --json
IW
2POST
/v1/swap_cross_order
htx-cli futures call POST /linear-swap-api/v1/swap_cross_order --body '{...}' --json
CW
3POST
/v1/swap_cross_batch_orders
htx-cli futures call POST /linear-swap-api/v1/swap_cross_batch_orders --body '{"orders_data":[{...}]}' --json
CW
4POST
/v1/swap_cancel
htx-cli futures order cancel --contract-code <c> --order-id <id> --json
IW
5POST
/v1/swap_cross_cancel
htx-cli futures call POST /linear-swap-api/v1/swap_cross_cancel --body '{...}' --json
CW
6POST
/v1/swap_cancelall
htx-cli futures call POST /linear-swap-api/v1/swap_cancelall --body '{"contract_code":"..."}' --json
IW
7POST
/v1/swap_cross_cancelall
htx-cli futures call POST /linear-swap-api/v1/swap_cross_cancelall --body '{...}' --json
CW
8POST
/v1/swap_lightning_close_position
htx-cli futures call POST /linear-swap-api/v1/swap_lightning_close_position --body '{...}' --json
IW
9POST
/v1/swap_cross_lightning_close_position
htx-cli futures call POST /linear-swap-api/v1/swap_cross_lightning_close_position --body '{...}' --json
CW
10POST
/v1/swap_switch_lever_rate
htx-cli futures call POST /linear-swap-api/v1/swap_switch_lever_rate --body '{"contract_code":"...","lever_rate":...}' --json
IW
11POST
/v1/swap_cross_switch_lever_rate
htx-cli futures call POST /linear-swap-api/v1/swap_cross_switch_lever_rate --body '{...}' --json
CW
12POST
/v1/swap_switch_position_mode
htx-cli futures call POST /linear-swap-api/v1/swap_switch_position_mode --body '{"position_mode":"single_side/dual_side"}' --json
IW
13POST
/v1/swap_cross_switch_position_mode
htx-cli futures call POST /linear-swap-api/v1/swap_cross_switch_position_mode --body '{...}' --json
CW
14POST
/v1/linear-cancel-after
htx-cli futures call POST /linear-swap-api/v1/linear-cancel-after --body '{"trigger_time":...}' --json
*W
#请求方法路径CLI命令模式读写
1POST
/v1/swap_order
htx-cli futures order place --contract-code <c> --direction <buy/sell> --offset <open/close> --lever-rate <n> --volume <n> [--price <p>] [--order-price-type limit/opponent/optimal_20/post_only/ioc/fok] --json
IW
2POST
/v1/swap_cross_order
htx-cli futures call POST /linear-swap-api/v1/swap_cross_order --body '{...}' --json
CW
3POST
/v1/swap_cross_batch_orders
htx-cli futures call POST /linear-swap-api/v1/swap_cross_batch_orders --body '{"orders_data":[{...}]}' --json
CW
4POST
/v1/swap_cancel
htx-cli futures order cancel --contract-code <c> --order-id <id> --json
IW
5POST
/v1/swap_cross_cancel
htx-cli futures call POST /linear-swap-api/v1/swap_cross_cancel --body '{...}' --json
CW
6POST
/v1/swap_cancelall
htx-cli futures call POST /linear-swap-api/v1/swap_cancelall --body '{"contract_code":"..."}' --json
IW
7POST
/v1/swap_cross_cancelall
htx-cli futures call POST /linear-swap-api/v1/swap_cross_cancelall --body '{...}' --json
CW
8POST
/v1/swap_lightning_close_position
htx-cli futures call POST /linear-swap-api/v1/swap_lightning_close_position --body '{...}' --json
IW
9POST
/v1/swap_cross_lightning_close_position
htx-cli futures call POST /linear-swap-api/v1/swap_cross_lightning_close_position --body '{...}' --json
CW
10POST
/v1/swap_switch_lever_rate
htx-cli futures call POST /linear-swap-api/v1/swap_switch_lever_rate --body '{"contract_code":"...","lever_rate":...}' --json
IW
11POST
/v1/swap_cross_switch_lever_rate
htx-cli futures call POST /linear-swap-api/v1/swap_cross_switch_lever_rate --body '{...}' --json
CW
12POST
/v1/swap_switch_position_mode
htx-cli futures call POST /linear-swap-api/v1/swap_switch_position_mode --body '{"position_mode":"single_side/dual_side"}' --json
IW
13POST
/v1/swap_cross_switch_position_mode
htx-cli futures call POST /linear-swap-api/v1/swap_cross_switch_position_mode --body '{...}' --json
CW
14POST
/v1/linear-cancel-after
htx-cli futures call POST /linear-swap-api/v1/linear-cancel-after --body '{"trigger_time":...}' --json
*W

Order queries — read (16)

订单查询——只读(16个)

#MethodPathCLIMode
1POST
/v1/swap_cross_query_trade_state
htx-cli futures call POST /linear-swap-api/v1/swap_cross_query_trade_state --json
C
2POST
/v1/swap_order_info
htx-cli futures call POST /linear-swap-api/v1/swap_order_info --body '{"order_id":"..."}' --json
I
3POST
/v1/swap_cross_order_info
htx-cli futures call POST /linear-swap-api/v1/swap_cross_order_info --json
C
4POST
/v1/swap_order_detail
htx-cli futures call POST /linear-swap-api/v1/swap_order_detail --json
I
5POST
/v1/swap_cross_order_detail
htx-cli futures call POST /linear-swap-api/v1/swap_cross_order_detail --json
C
6POST
/v1/swap_openorders
htx-cli futures order list [--contract-code <c>] --json
I
7POST
/v1/swap_cross_openorders
htx-cli futures call POST /linear-swap-api/v1/swap_cross_openorders --json
C
8POST
/v3/swap_hisorders
htx-cli futures call POST /linear-swap-api/v3/swap_hisorders --json
I
9POST
/v3/swap_cross_hisorders
htx-cli futures call POST /linear-swap-api/v3/swap_cross_hisorders --json
C
10POST
/v3/swap_hisorders_exact
htx-cli futures call POST /linear-swap-api/v3/swap_hisorders_exact --json
I
11POST
/v3/swap_cross_hisorders_exact
htx-cli futures call POST /linear-swap-api/v3/swap_cross_hisorders_exact --json
C
12POST
/v3/swap_matchresults
htx-cli futures call POST /linear-swap-api/v3/swap_matchresults --json
I
13POST
/v3/swap_cross_matchresults
htx-cli futures call POST /linear-swap-api/v3/swap_cross_matchresults --json
C
14POST
/v3/swap_matchresults_exact
htx-cli futures call POST /linear-swap-api/v3/swap_matchresults_exact --json
I
15POST
/v3/swap_cross_matchresults_exact
htx-cli futures call POST /linear-swap-api/v3/swap_cross_matchresults_exact --json
C
16GET
/v1/swap_position_side
/
/v1/swap_cross_position_side
htx-cli futures call GET /linear-swap-api/v1/swap_position_side --json
*
#请求方法路径CLI命令模式
1POST
/v1/swap_cross_query_trade_state
htx-cli futures call POST /linear-swap-api/v1/swap_cross_query_trade_state --json
C
2POST
/v1/swap_order_info
htx-cli futures call POST /linear-swap-api/v1/swap_order_info --body '{"order_id":"..."}' --json
I
3POST
/v1/swap_cross_order_info
htx-cli futures call POST /linear-swap-api/v1/swap_cross_order_info --json
C
4POST
/v1/swap_order_detail
htx-cli futures call POST /linear-swap-api/v1/swap_order_detail --json
I
5POST
/v1/swap_cross_order_detail
htx-cli futures call POST /linear-swap-api/v1/swap_cross_order_detail --json
C
6POST
/v1/swap_openorders
htx-cli futures order list [--contract-code <c>] --json
I
7POST
/v1/swap_cross_openorders
htx-cli futures call POST /linear-swap-api/v1/swap_cross_openorders --json
C
8POST
/v3/swap_hisorders
htx-cli futures call POST /linear-swap-api/v3/swap_hisorders --json
I
9POST
/v3/swap_cross_hisorders
htx-cli futures call POST /linear-swap-api/v3/swap_cross_hisorders --json
C
10POST
/v3/swap_hisorders_exact
htx-cli futures call POST /linear-swap-api/v3/swap_hisorders_exact --json
I
11POST
/v3/swap_cross_hisorders_exact
htx-cli futures call POST /linear-swap-api/v3/swap_cross_hisorders_exact --json
C
12POST
/v3/swap_matchresults
htx-cli futures call POST /linear-swap-api/v3/swap_matchresults --json
I
13POST
/v3/swap_cross_matchresults
htx-cli futures call POST /linear-swap-api/v3/swap_cross_matchresults --json
C
14POST
/v3/swap_matchresults_exact
htx-cli futures call POST /linear-swap-api/v3/swap_matchresults_exact --json
I
15POST
/v3/swap_cross_matchresults_exact
htx-cli futures call POST /linear-swap-api/v3/swap_cross_matchresults_exact --json
C
16GET
/v1/swap_position_side
/
/v1/swap_cross_position_side
htx-cli futures call GET /linear-swap-api/v1/swap_position_side --json
*

Trigger orders (10)

触发单(10个)

#MethodPathCLIModeRW
1POST
/v1/swap_trigger_order
htx-cli futures call POST /linear-swap-api/v1/swap_trigger_order --body '{...}' --json
IW
2POST
/v1/swap_cross_trigger_order
htx-cli futures call POST /linear-swap-api/v1/swap_cross_trigger_order --json
CW
3POST
/v1/swap_trigger_cancel
htx-cli futures call POST /linear-swap-api/v1/swap_trigger_cancel --json
IW
4POST
/v1/swap_cross_trigger_cancel
htx-cli futures call POST /linear-swap-api/v1/swap_cross_trigger_cancel --json
CW
5POST
/v1/swap_trigger_cancelall
htx-cli futures call POST /linear-swap-api/v1/swap_trigger_cancelall --json
IW
6POST
/v1/swap_cross_trigger_cancelall
htx-cli futures call POST /linear-swap-api/v1/swap_cross_trigger_cancelall --json
CW
7POST
/v1/swap_trigger_openorders
htx-cli futures call POST /linear-swap-api/v1/swap_trigger_openorders --json
IR
8POST
/v1/swap_cross_trigger_openorders
htx-cli futures call POST /linear-swap-api/v1/swap_cross_trigger_openorders --json
CR
9POST
/v1/swap_trigger_hisorders
htx-cli futures call POST /linear-swap-api/v1/swap_trigger_hisorders --json
IR
10POST
/v1/swap_cross_trigger_hisorders
htx-cli futures call POST /linear-swap-api/v1/swap_cross_trigger_hisorders --json
CR
#请求方法路径CLI命令模式读写
1POST
/v1/swap_trigger_order
htx-cli futures call POST /linear-swap-api/v1/swap_trigger_order --body '{...}' --json
IW
2POST
/v1/swap_cross_trigger_order
htx-cli futures call POST /linear-swap-api/v1/swap_cross_trigger_order --json
CW
3POST
/v1/swap_trigger_cancel
htx-cli futures call POST /linear-swap-api/v1/swap_trigger_cancel --json
IW
4POST
/v1/swap_cross_trigger_cancel
htx-cli futures call POST /linear-swap-api/v1/swap_cross_trigger_cancel --json
CW
5POST
/v1/swap_trigger_cancelall
htx-cli futures call POST /linear-swap-api/v1/swap_trigger_cancelall --json
IW
6POST
/v1/swap_cross_trigger_cancelall
htx-cli futures call POST /linear-swap-api/v1/swap_cross_trigger_cancelall --json
CW
7POST
/v1/swap_trigger_openorders
htx-cli futures call POST /linear-swap-api/v1/swap_trigger_openorders --json
IR
8POST
/v1/swap_cross_trigger_openorders
htx-cli futures call POST /linear-swap-api/v1/swap_cross_trigger_openorders --json
CR
9POST
/v1/swap_trigger_hisorders
htx-cli futures call POST /linear-swap-api/v1/swap_trigger_hisorders --json
IR
10POST
/v1/swap_cross_trigger_hisorders
htx-cli futures call POST /linear-swap-api/v1/swap_cross_trigger_hisorders --json
CR

TP / SL orders (10)

止盈止损单(10个)

#MethodPathCLIModeRW
1POST
/v1/swap_tpsl_order
htx-cli futures call POST /linear-swap-api/v1/swap_tpsl_order --body '{...}' --json
IW
2POST
/v1/swap_cross_tpsl_order
htx-cli futures call POST /linear-swap-api/v1/swap_cross_tpsl_order --json
CW
3POST
/v1/swap_tpsl_cancel
htx-cli futures call POST /linear-swap-api/v1/swap_tpsl_cancel --json
IW
4POST
/v1/swap_cross_tpsl_cancel
htx-cli futures call POST /linear-swap-api/v1/swap_cross_tpsl_cancel --json
CW
5POST
/v1/swap_tpsl_cancelall
htx-cli futures call POST /linear-swap-api/v1/swap_tpsl_cancelall --json
IW
6POST
/v1/swap_cross_tpsl_cancelall
htx-cli futures call POST /linear-swap-api/v1/swap_cross_tpsl_cancelall --json
CW
7POST
/v1/swap_tpsl_openorders
htx-cli futures call POST /linear-swap-api/v1/swap_tpsl_openorders --json
IR
8POST
/v1/swap_cross_tpsl_openorders
htx-cli futures call POST /linear-swap-api/v1/swap_cross_tpsl_openorders --json
CR
9POST
/v1/swap_tpsl_hisorders
htx-cli futures call POST /linear-swap-api/v1/swap_tpsl_hisorders --json
IR
10POST
/v1/swap_cross_tpsl_hisorders
htx-cli futures call POST /linear-swap-api/v1/swap_cross_tpsl_hisorders --json
CR
#请求方法路径CLI命令模式读写
1POST
/v1/swap_tpsl_order
htx-cli futures call POST /linear-swap-api/v1/swap_tpsl_order --body '{...}' --json
IW
2POST
/v1/swap_cross_tpsl_order
htx-cli futures call POST /linear-swap-api/v1/swap_cross_tpsl_order --json
CW
3POST
/v1/swap_tpsl_cancel
htx-cli futures call POST /linear-swap-api/v1/swap_tpsl_cancel --json
IW
4POST
/v1/swap_cross_tpsl_cancel
htx-cli futures call POST /linear-swap-api/v1/swap_cross_tpsl_cancel --json
CW
5POST
/v1/swap_tpsl_cancelall
htx-cli futures call POST /linear-swap-api/v1/swap_tpsl_cancelall --json
IW
6POST
/v1/swap_cross_tpsl_cancelall
htx-cli futures call POST /linear-swap-api/v1/swap_cross_tpsl_cancelall --json
CW
7POST
/v1/swap_tpsl_openorders
htx-cli futures call POST /linear-swap-api/v1/swap_tpsl_openorders --json
IR
8POST
/v1/swap_cross_tpsl_openorders
htx-cli futures call POST /linear-swap-api/v1/swap_cross_tpsl_openorders --json
CR
9POST
/v1/swap_tpsl_hisorders
htx-cli futures call POST /linear-swap-api/v1/swap_tpsl_hisorders --json
IR
10POST
/v1/swap_cross_tpsl_hisorders
htx-cli futures call POST /linear-swap-api/v1/swap_cross_tpsl_hisorders --json
CR

Safety checklist

安全检查清单

Before every write:
  • Fetch current mark price from
    futures-market
    skill.
  • Show: contract, direction, offset (open/close), volume, price, leverage.
  • Compute and show the estimated liquidation price for the resulting position.
  • For leverage changes: show old → new and the new liquidation price.
  • For flash-close: show current position size and unrealized PnL.
  • For batch / cancel-all: list the order IDs first.
  • For TP/SL: show the trigger price and its distance from current mark.
  • Wait for explicit user confirmation ("yes" / "confirm").
  • Execute and report the JSON response.
每次写入操作前:
  • futures-market
    技能获取当前标记价格。
  • 展示:合约、方向、开平、数量、价格、杠杆。
  • 计算并展示持仓后的预估强平价格
  • 调整杠杆时:展示旧杠杆→新杠杆以及新的强平价格。
  • 闪电平仓时:展示当前持仓量和未实现盈亏。
  • 批量/全部撤单时:先列出订单ID。
  • 止盈止损单:展示触发价格及其与当前标记价格的差值。
  • 等待用户明确确认("yes" / "confirm")。
  • 执行操作并返回JSON响应。

Typical session — open long

典型会话——开多单

bash
undefined
bash
undefined

1. Price check

1. 价格查询

htx-cli futures market funding-rate BTC-USDT --json
htx-cli futures market funding-rate BTC-USDT --json

2. Current position / available

2. 当前持仓/可用资金

htx-cli futures account info --contract-code BTC-USDT --json
htx-cli futures account info --contract-code BTC-USDT --json

3. User confirms preview, then:

3. 用户确认预览后,执行:

htx-cli futures order place
--contract-code BTC-USDT --direction buy --offset open
--lever-rate 10 --volume 1 --price 85000
--order-price-type limit --json
htx-cli futures order place
--contract-code BTC-USDT --direction buy --offset open
--lever-rate 10 --volume 1 --price 85000
--order-price-type limit --json

4. Monitor

4. 监控订单

htx-cli futures order list --contract-code BTC-USDT --json
undefined
htx-cli futures order list --contract-code BTC-USDT --json
undefined

References

参考资料

  • references/authentication.md
  • references/order-types.md
    — order types, trigger/TPSL field layout
  • references/authentication.md
  • references/order-types.md
    — 订单类型、触发单/止盈止损单字段布局