Logo Bitmart Exchange Futures

Bitmart Exchange Futures

Tổ chức
bitmartexchange
bitmart-exchange-futures

Use when the user asks about BitMart futures or contract trading or Futures WebSocket streams, including opening/closing positions, setting leverage, placing plan (conditional) orders, take-profit/stop-loss, trailing orders, checking futures positions, managing futures account, closing all positions in one click, fund ↔ futures account transfers, sub-account transfers, affiliate/rebate queries, simulated trading, or streaming real-time futures ticker/book ticker/trades/depth/funding-rate/private order/private position updates. Do NOT use for spot trading (use bitmart-exchange-spot).

Tổng quan

Nhà phát hànhbitmartexchange
Kho mãbitmart-skills
Tên kỹ năngbitmart-exchange-futures
Sao
33
Bản fork
0
Tệp đi kèm
7
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 7 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được bitmartexchange công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Bitmart Exchange Futures trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/bitmartexchange/bitmart-skills/tree/master/skills/bitmart-exchange-futures
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/bitmartexchange/bitmart-skills.git /tmp/bitmart-skills
mkdir -p .claude/skills
cp -r /tmp/bitmart-skills/skills/bitmart-exchange-futures .claude/skills/bitmart-exchange-futures
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Bitmart Exchange Futures trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Bitmart Exchange Futures ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Bitmart Exchange Futures với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

BitMart Futures Trading

Overview

60 endpoints total. Table:

#CategoryAPI EndpointTypeDescription
1Market DataGET /contract/public/detailsREADContract specifications
2Market DataGET /contract/public/depthREADOrder book
3Market DataGET /contract/public/market-tradeREADRecent trades (max 100)
4Market DataGET /contract/public/funding-rateREADCurrent funding rate (single symbol)
5Market DataGET /contract/public/funding-rate-v2READCurrent funding rate (all symbols, or filter by symbol)
6Market DataGET /contract/public/funding-rate-historyREADHistorical funding rates
7Market DataGET /contract/public/klineREADK-line (steps: 1,3,5,15,30,60,120,240,360,720,1440,4320,10080)
8Market DataGET /contract/public/markprice-klineREADMark price K-line
9Market DataGET /contract/public/open-interestREADOpen interest
10Market DataGET /contract/public/leverage-bracketREADLeverage tiers / risk limits
11AccountGET /contract/private/assets-detailREADFutures account balance
12AccountGET /contract/private/trade-fee-rateREADTrade fee rate
13AccountGET /contract/private/positionREADCurrent positions
14AccountGET /contract/private/position-v2READPositions (extended info)
15AccountGET /contract/private/position-riskREADPosition risk / liquidation
16AccountGET /contract/private/get-position-modeREADCurrent position mode
17AccountGET /contract/private/transaction-historyREADPnL / funding / fees history
18TradingPOST /contract/private/submit-orderWRITEPlace order
19TradingPOST /contract/private/cancel-orderWRITECancel order
20TradingPOST /contract/private/cancel-ordersWRITEBatch cancel
21TradingPOST /contract/private/modify-limit-orderWRITEAmend limit order
22TradingPOST /contract/private/cancel-all-afterWRITETimed cancel all
23TradingPOST /contract/private/submit-leverageWRITESet leverage
24TradingPOST /contract/private/set-position-modeWRITESet hedge/one-way mode
25TradingPOST /account/v1/transfer-contractWRITESpot-Futures transfer
26TradingPOST /contract/private/account/v1/transferWRITEFund ↔ Futures account transfer
27TradingPOST /contract/private/close-all-positionWRITEClose all positions (one-click market close)
28Plan OrderPOST /contract/private/submit-plan-orderWRITEConditional/trigger order
29Plan OrderPOST /contract/private/cancel-plan-orderWRITECancel plan order
30Plan OrderPOST /contract/private/modify-plan-orderWRITEAmend plan order
31TP/SLPOST /contract/private/submit-tp-sl-orderWRITESet take-profit/stop-loss
32TP/SLPOST /contract/private/modify-tp-sl-orderWRITEModify TP/SL
33TP/SLPOST /contract/private/modify-preset-plan-orderWRITEModify preset TP/SL on order
34TrailingPOST /contract/private/submit-trail-orderWRITETrailing stop order
35TrailingPOST /contract/private/cancel-trail-orderWRITECancel trailing
36Order QueryGET /contract/private/orderREADOrder by ID
37Order QueryGET /contract/private/order-historyREADHistorical orders
38Order QueryGET /contract/private/get-open-ordersREADAll open orders
39Order QueryGET /contract/private/current-plan-orderREADActive plan orders
40Order QueryGET /contract/private/tradesREADTrade / fill history
41Order QueryPOST /account/v1/transfer-contract-listREADTransfer records
42Sub-AccountPOST /account/contract/sub-account/main/v1/sub-to-mainWRITESub → Main transfer (main account)
43Sub-AccountPOST /account/contract/sub-account/main/v1/main-to-subWRITEMain → Sub transfer (main account)
44Sub-AccountPOST /account/contract/sub-account/sub/v1/sub-to-mainWRITESub → Main transfer (sub account)
45Sub-AccountGET /account/contract/sub-account/main/v1/walletREADSub-account futures balance
46Sub-AccountGET /account/contract/sub-account/main/v1/transfer-listREADSub-account transfer history
47Sub-AccountGET /account/contract/sub-account/v1/transfer-historyREADAccount transfer history
48AffiliateGET /contract/private/affiliate/rebate-listREADRebate overview
49AffiliateGET /contract/private/affiliate/trade-listREADAffiliate trade records
50AffiliateGET /contract/private/affiliate/rebate-userREADSingle user rebate data
51AffiliateGET /contract/private/affiliate/rebate-apiREADSingle API user rebate data
52AffiliateGET /contract/private/affiliate/invite-checkREADCheck if invited user
53AffiliateGET /contract/private/affiliate/rebate-inviteUserREADInvited customer list
54AffiliateGET /contract/private/affiliate/deposit-withdrawal-listREADInvited user deposit / withdrawal records
55AffiliateGET /contract/private/affiliate/aff-customer-infoREADInvited user contract account assets and equity
56Collateral / RepaymentGET /contract/private/cross_collateral/interest_logREADCross-collateral interest accrual logs
57Collateral / RepaymentGET /contract/private/auto_repaymentREADAuto repayment records
58SimulatedPOST /contract/private/claimWRITEDemo account top-up (demo only)
59SystemGET /system/timeREADGet server time (milliseconds)
60SystemGET /system/serviceREADGet system service status / maintenance

WebSocket coverage: Public real-time channels and private push channels are documented in references/websocket.md, including futures book ticker, funding-rate push, depth speed suffixes, private order position_mode, and private position position_mode.


Skill Routing

User IntentCorrect Skill
Futures/contract trading, leverage, TP/SL, plan orders, trailing stops, sub-account transfers, one-click close-all-position, fund account transfers (fund ↔ futures only), affiliate/rebate/deposit-withdrawal/invited-user asset queries, simulated tradingbitmart-exchange-futures (this skill)
Futures real-time ticker, book ticker, trades, depth, funding-rate push, private order/position pushbitmart-exchange-futures (this skill, WebSocket reference)
Spot buy/sell, order management, spot balance, fee ratesbitmart-exchange-spot

Authentication

Credential Check (Before Any Private API Call)

Before calling any authenticated endpoint, verify credentials are available:

  1. Check for environment variables:
    • BITMART_API_KEY — API key
    • BITMART_API_SECRET — Secret key
    • BITMART_API_MEMO — Memo string
  2. Or check for config file: ~/.bitmart/config.toml
    toml
    [default]
    api_key = "your-api-key"
    api_secret = "your-secret-key"
    memo = "your-memo"
  3. If missing: STOP. Guide user to set up credentials. Do NOT proceed with any authenticated call.

Key display rules: When displaying credentials back to the user, show only the first 5 and last 4 characters (e.g., bmk12...9xyz). NEVER display full secret or memo values.

Auth Levels

LevelWhenHeaders Required
NONEPublic market data and system status (endpoints 1-10, 59-60)None
KEYEDRead-only private data — balances, positions, orders, affiliate, collateral / repayment logs (endpoints 11-17, 36-40, 45-57)X-BM-KEY
SIGNEDWrite operations — trading, leverage, transfers, sub-account transfers, demo claim (endpoints 18-35, 41-44, 58)X-BM-KEY + X-BM-SIGN + X-BM-TIMESTAMP

Signature Generation

timestamp = current UTC time in milliseconds
message   = "{timestamp}#{memo}#{request_body_json}"
signature = HMAC-SHA256(secret_key, message) → hex string
  • For POST requests: request_body_json is the JSON body string.
  • For GET requests: request_body_json is an empty string "".

Required Headers (SIGNED)

HeaderValue
Content-Typeapplication/json
X-BM-KEYAPI key
X-BM-SIGNHex-encoded HMAC-SHA256 signature
X-BM-TIMESTAMPCurrent UTC timestamp in milliseconds
User-Agentbitmart-skills/futures/v2026.7.14 — SDK source identifier for analytics

API Base

  • Base URL: https://api-cloud-v2.bitmart.com
  • Symbol Format: BTCUSDT (no separator — unlike spot which uses BTC_USDT)

Key Differences from Spot

AspectSpotFutures
Base URLapi-cloud.bitmart.comapi-cloud-v2.bitmart.com
Symbol FormatBTC_USDT (underscore)BTCUSDT (no separator)
Order Side"buy" / "sell" (string)1 / 2 / 3 / 4 (integer)
LeverageN/AConfigurable per symbol
Position ModeN/Ahedge_mode / one_way_mode
Margin ModeN/Across / isolated

IMPORTANT: Always use the futures base URL (api-cloud-v2) for contract endpoints. Using the spot base URL will fail.

Standard Response Format

Success:

json
{
  "code": 1000,
  "message": "OK",
  "trace": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "data": { ... }
}

Error:

json
{
  "code": 40035,
  "message": "Order not exist",
  "trace": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "data": null
}

Important: For standard Futures endpoints, String(code) == "1000" means success and any other code is an error. Two collateral / repayment endpoints (GET /contract/private/cross_collateral/interest_log and GET /contract/private/auto_repayment) use the alternate response shape {"errno":"OK","message":"Success","success":true,...} and may omit code; treat success == true as success for those endpoints. GET /contract/private/affiliate/aff-customer-info may return "code":"1000" as a string, so do not require a numeric-only comparison.

GET requests: Parameters go in the query string. POST requests: Parameters go in the JSON body.


Order Side Reference

ValueHedge ModeOne-Way Mode
1Open Long (buy_open_long)Buy
2Close Short (buy_close_short)Buy (Reduce Only)
3Close Long (sell_close_long)Sell (Reduce Only)
4Open Short (sell_open_short)Sell

Hedge mode mapping:

  • To open long: side = 1
  • To close long: side = 3
  • To open short: side = 4
  • To close short: side = 2

One-way mode: Use side 1 (buy) or 4 (sell). The system infers whether to open or close.

Order Mode Reference

ValueNameDescription
1GTCGood Till Cancel — order stays open until filled or canceled
2FOKFill or Kill — must fill entirely or cancel immediately
3IOCImmediate or Cancel — fill what's available, cancel the rest
4Maker OnlyPost Only — rejected if it would immediately match

Rate Limits

EndpointRateTarget
Public Market Data (most)12/2secIP
Open Interest2/2secIP
Assets Detail12/2secKEY
Trade Fee Rate2/2secKEY
Position / Position V26/2secKEY
Position Risk24/2secKEY
Get Position Mode2/2secKEY
Transaction History6/2secKEY
Order Detail50/2secKEY
Order History / Trades6/2secKEY
Open Orders / Plan Orders50/2secKEY
Submit Order24/2secKEY
Cancel Order40/2secKEY
Cancel Orders (batch)2/2secKEY
Modify Order24/2secUID
Plan / TP-SL / Trail Orders24/2secUID
Cancel Plan Order40/2secUID
Cancel All After4/2secUID
Set Leverage24/2secKEY
Set Position Mode2/2secKEY
Transfer1/2secKEY
Transfer List1/2secKEY
Fund Account Transfer (/contract/private/account/v1/transfer)12/2secKEY
Close All Position1/1secUID
Sub-Account Transfers (42-44)8/2secKEY
Sub-Account Wallet (45)12/2secKEY
Sub-Account History (46-47)8/2secKEY
Affiliate Endpoints (48-53)24/2secKEY
Affiliate Deposit / Withdrawal and Account Info (54-55)24/2secKEY
Cross-Collateral Interest / Auto Repayment (56-57)2/2secUID
GET /system/time10/secIP
GET /system/service10/secIP

Rate limit response headers:

  • X-BM-RateLimit-Remaining — Number of requests already used in the current window
  • X-BM-RateLimit-Limit — Maximum allowed requests in the current window
  • X-BM-RateLimit-Reset — Current time window length (seconds)

Warning: If X-BM-RateLimit-Remaining >= X-BM-RateLimit-Limit, stop calling immediately and wait for reset to avoid sending one extra over-limit request.

If rate limited (HTTP 429), wait for the reset period before retrying.


Quickstart

Example 1: Get BTC contract details (no auth)

bash
curl -s -H "User-Agent: bitmart-skills/futures/v2026.7.14" 'https://api-cloud-v2.bitmart.com/contract/public/details?symbol=BTCUSDT'

Example 2: Get futures positions (KEYED)

bash
curl -s -H "X-BM-KEY: $BITMART_API_KEY" \
  -H "User-Agent: bitmart-skills/futures/v2026.7.14" \
  'https://api-cloud-v2.bitmart.com/contract/private/position?symbol=BTCUSDT'

Example 3: Open long BTC position (SIGNED)

bash
TIMESTAMP=$(date +%s000)
BODY='{"symbol":"BTCUSDT","side":1,"type":"market","size":1,"leverage":"10","open_type":"cross"}'
SIGN=$(echo -n "${TIMESTAMP}#${BITMART_API_MEMO}#${BODY}" | openssl dgst -sha256 -hmac "$BITMART_API_SECRET" | awk '{print $NF}')
curl -s -X POST 'https://api-cloud-v2.bitmart.com/contract/private/submit-order' \
  -H "User-Agent: bitmart-skills/futures/v2026.7.14" \
  -H "Content-Type: application/json" \
  -H "X-BM-KEY: $BITMART_API_KEY" \
  -H "X-BM-SIGN: $SIGN" \
  -H "X-BM-TIMESTAMP: $TIMESTAMP" \
  -d "$BODY"

Operation Flow

Step 0: Credential Check

Verify BITMART_API_KEY, BITMART_API_SECRET, and BITMART_API_MEMO are available via environment variables or ~/.bitmart/config.toml. If missing, STOP and guide the user to set up credentials.

Step 1: Identify User Intent

Parse user request and map to a READ or WRITE operation:

  • READ operations: market data, positions, balance, order queries, funding rates
  • WRITE operations: open/close position, set leverage, place plan order, set TP/SL, trailing stop, transfer, close all positions, fund account transfer
  • STREAM operations: real-time futures ticker/book ticker/trades/depth/funding rate, private order push, private position push

Step 1.5: Pre-Trade Position Check (MANDATORY for open/leverage operations)

Before executing ANY of: open position (POST /contract/private/submit-order with side 1 or 4), set leverage (POST /contract/private/submit-leverage), or change margin mode:

  1. Call GET /contract/private/position-v2?symbol=<SYMBOL> to check for existing positions and current margin mode (open_type)
  2. Evaluate the entire data[] array returned by position-v2 — do not assume there is only one row
  3. Parse each row's current_amount as a number before comparing it. The API returns string values such as "0".
  4. If any row's parsed current_amount is non-zero (existing position found):
    • You MUST inherit the relevant non-zero position row's leverage value — do NOT send a different leverage in the order
    • You MUST inherit the relevant non-zero position row's open_type (margin mode: cross or isolated) — do NOT send a different margin mode
    • If the user explicitly requested different leverage or margin mode: STOP and warn:

      "You have an existing [X]x [cross/isolated] [LONG/SHORT] position of [size] contracts. Changing leverage or margin mode while a position is open is commonly rejected by the API (for example, code 40012/40040). Please close the existing position first if you want to change these settings."

    • Do not attempt to change position_mode while any non-zero position row exists
    • Wait for user decision before proceeding
  5. If every row's parsed current_amount is 0: proceed with user-specified leverage and margin mode
  6. If the request becomes mode-sensitive (for example, deciding whether to switch between hedge_mode and one_way_mode, or explaining current mode-dependent behavior), call GET /contract/private/get-position-mode before making that decision. Do not treat get-position-mode as a hard prerequisite for every plain open-position flow.

Step 1.55: Pre-Mode-Switch Clean-State Check (MANDATORY when changing position mode)

position_mode is an account-wide setting. Before calling POST /contract/private/set-position-mode:

  1. Ensure Step 1.5 found no existing position (every row's parsed current_amount is 0)
  2. Call GET /contract/private/get-open-orders and verify there are no open orders on the account
  3. If any open orders or other occupied state remain: STOP and ask the user to clear them before retrying the mode switch
  4. If set-position-mode returns 40059, treat that as "account is not in a clean state for mode switching" and stop

Step 1.6: TP/SL Order Parameter Rules (MANDATORY when setting TP/SL on a position)

When the user asks to set take-profit or stop-loss on an existing futures position, use POST /contract/private/submit-tp-sl-order.

CRITICAL — Do NOT confuse these two mechanisms:

  • preset_take_profit_price / preset_stop_loss_price: optional fields on submit-order to attach TP/SL at position-open time
  • submit-tp-sl-order: standalone endpoint to set TP/SL on an already-open position — uses trigger_price + executive_price, NOT take_profit_price/stop_loss_price

Required parameters:

ParameterTypeValueNotes
symbolStringe.g. BTCUSDT
typeString"take_profit" or "stop_loss"NEVER "market" or "limit"
sideInt3 (close long) or 2 (close short)Must match position direction
trigger_priceStringActivation priceLong TP: > entry; Long SL: < entry
executive_priceString"0" for market fill; or a limit price
price_typeInt1 last price / 2 mark priceDefault: 1
plan_categoryInt1 TP/SL order / 2 Position TP/SL order (default)For existing-position TP/SL, use 2. Omitting the field currently defaults to 2, but sending 2 explicitly is clearer.

Before submitting or modifying TP/SL, call GET /contract/public/details?symbol=<SYMBOL> and truncate both trigger_price and executive_price to the symbol's price_precision tick size. The API rejects over-precise TP/SL prices with errors such as 40053.

Always submit TP and SL as two separate API calls. One call for take-profit, one for stop-loss.

Long BTC TP example: {"symbol":"BTCUSDT","type":"take_profit","side":3,"trigger_price":"72000","executive_price":"0","price_type":1,"plan_category":2} Long BTC SL example: {"symbol":"BTCUSDT","type":"stop_loss","side":3,"trigger_price":"64000","executive_price":"0","price_type":1,"plan_category":2}

Timestamp Display Rules

API responses contain Unix timestamps in different units. When displaying any timestamp to the user, always convert to human-readable local time.

FieldUnitConversion
create_time, update_time (order responses)Milliseconds÷ 1000 → Unix seconds → local time
server_time (system time)Milliseconds÷ 1000 → Unix seconds → local time
timestamp (K-line candle open time)SecondsDirect → Unix seconds → local time
open_timestamp, funding_time (contract details)Milliseconds÷ 1000 → Unix seconds → local time

Query parameter timestamps for futures endpoints (start_time, end_time) are endpoint-specific:

  • Seconds: /contract/public/kline, /contract/public/markprice-kline, /contract/private/order-history, /contract/private/trades, cross-collateral / auto-repayment query filters, and affiliate rebate endpoints (/contract/private/affiliate/...)
  • Milliseconds: /contract/private/transaction-history

Do NOT assume all futures start_time / end_time are seconds — always follow the target endpoint definition.

Display format: YYYY-MM-DD HH:MM:SS in the user's local timezone. Example: timestamp 1709971200000 (ms) → 2024-03-09 16:00:00 (UTC+8).

Common mistakes to avoid:

  • Do NOT treat millisecond timestamps as seconds (produces dates in year 55000+)
  • Do NOT display raw numeric timestamps — always convert to readable format
  • Do NOT assume UTC — convert to the user's local timezone

Step 2: Execute

  • READ: Call the API endpoint, parse response, format data for user display.

  • STREAM: Use references/websocket.md. Subscribe to the matching WebSocket channel; for private channels, access/login first with the WebSocket signature payload timestamp#memo#bitmart.WebSocket.

  • WRITE: Follow sub-steps below, then ask for "CONFIRM":

    2a. submit-order conditional param selection:

    ScenarioSendDo NOT send
    Open position, type=limit (side=1 or 4)symbol, side, type:"limit", price, size, leverage, open_type—
    Open position, type=market (side=1 or 4)symbol, side, type:"market", size, leverage, open_typeprice (ignored, causes confusion)
    Close position, type=limit (side=2 or 3)symbol, side, type:"limit", price, sizeleverage, open_type (not needed for close)
    Close position, type=market (side=2 or 3)symbol, side, type:"market", sizeprice, leverage, open_type

    Additional constraints:

    • leverage / open_type for open orders: if an existing position is found (Step 1.5), use the relevant non-zero position row's values — do NOT send different ones.
    • mode=4 (Maker Only): only valid with type=limit. Never combine with type=market.
    • preset_take_profit_price / preset_stop_loss_price: only valid for opening orders (side=1 or 4). For TP/SL on an already-open position, use submit-tp-sl-order (see Step 1.6).
    • size is always an integer (number of contracts). Check the minimum contract size via GET /contract/public/details.
    • Futures price precision: truncate every order price field to the contract's price_precision tick size from GET /contract/public/details, including limit price, plan trigger_price, TP/SL trigger_price / executive_price, and trailing-stop activation_price.

    2b. Confirm and execute: Present a summary (symbol, side, type, price if limit, size, leverage, open_type) and ask for explicit "CONFIRM" before executing.

    Close All Positions (POST /contract/private/close-all-position) — HIGH-RISK, mandatory flow:

    This endpoint market-closes positions immediately. NEVER call it directly on user request. Follow all 5 steps in order:

    1. Call GET /contract/private/position-v2 and list every position that will be closed: symbol, side, size, unrealized PnL. Use position-v2 for this check. Its position_side field is "long", "short", or "both" (the latter can appear in one-way position mode — inferred, not stated verbatim in the official docs) — but this endpoint's position_side parameter only accepts "long", "short", or omitted. NEVER pass "both". If the user uses copy trading, also check account="copy_trading" — see references/close-all-position.md for the scope caveat.
    2. Determine scope from user intent and set params accordingly:
      • symbol (optional): if set, only that symbol is closed; if empty, ALL symbols are closed
      • position_side (optional, hedge mode): long / short; if empty, both directions are closed
      • contractType (required): 1 = USDT-FUTURES, 2 = COIN-FUTURES (bare JSON number, not a quoted string — a string is rejected with 40011 Invalid parameter)
    3. Show the user the exact list of positions about to be market-closed and warn: "This will market-close the positions listed above immediately at current market price. Slippage may occur."
    4. Require explicit CONFIRM before executing. Rate limit is 1 req/1sec per UID — never retry automatically.
    5. After execution, call GET /contract/private/position-v2 again and confirm the targeted positions are gone; report the result. If any listed position remains after the re-check, do NOT re-call close-all-position automatically (rate limit 1 req/1sec) — report which positions failed to close and ask the user how to proceed (e.g. retry once after explicit confirmation, or close the remaining positions individually via submit-order).

    Fund account transfer (POST /contract/private/account/v1/transfer):

    • Required params: currency, amount (string decimal), type.
    • type enum: "fund_to_contract" (fund → futures) or "contract_to_fund" (futures → fund). (Note: do NOT use the spot endpoint's transfer-direction values here — only fund_to_contract / contract_to_fund are valid for this endpoint; the official docs' request sample for this endpoint is wrong.)
    • Uses the futures Base URL (https://api-cloud-v2.bitmart.com) despite managing the fund account.
    • Distinct from POST /account/v1/transfer-contract (#25): #25 moves spot ↔ futures; this endpoint moves fund ↔ futures.
    • Present summary (currency, amount, direction) and require explicit CONFIRM.
    • Verify after execution via GET /contract/private/assets-detail.

Step 3: Verify (WRITE only)

  • After opening a position: Call GET /contract/private/position-v2 to confirm position was opened. Report entry price, size, leverage, liquidation price, margin used.
  • After closing a position: Call GET /contract/private/position-v2 to confirm position was closed or reduced. Report realized PnL.
  • After placing an order: Call GET /contract/private/order to confirm order status.
  • After canceling an order: Call GET /contract/private/get-open-orders to verify the order is no longer open.
  • Report the verified result to the user.

See references/open-position.md, references/close-position.md, references/close-all-position.md, references/plan-order.md, and references/tp-sl.md for detailed step-by-step workflows.


References

  • API Reference — All 60 endpoints with full parameters, examples, and response fields
  • WebSocket Reference — Real-time Futures WebSocket channels, login signing, subscription formats, and changelog-only fields
  • Open Position — Step-by-step open position workflow
  • Close Position — Step-by-step close position workflow
  • Close All Positions — Step-by-step HIGH-RISK bulk market-close workflow
  • Plan Orders — Conditional/trigger order workflow
  • TP/SL — Take-profit/stop-loss workflow

Cross-Skill Workflows

Workflow 1: Transfer Funds → Open Position → Monitor

  1. bitmart-exchange-futures → POST /account/v1/transfer-contract — Transfer USDT from spot to futures
  2. bitmart-exchange-futures → POST /contract/private/submit-leverage — Set leverage
  3. bitmart-exchange-futures → POST /contract/private/submit-order — Open position (after user CONFIRM)
  4. bitmart-exchange-futures → GET /contract/private/position-v2 — Monitor position

Workflow 2: Check Spot Balance → Transfer → Open Futures

  1. bitmart-exchange-spot → GET /account/v1/wallet — Check spot balance
  2. bitmart-exchange-futures → POST /account/v1/transfer-contract — Transfer to futures
  3. bitmart-exchange-futures → POST /contract/private/submit-order — Open position

Error Handling

CodeDescriptionAction
1000SuccessProcess response normally
30002X-BM-KEY not foundCheck that API key is set correctly
30005X-BM-SIGN is wrongVerify signature generation (timestamp, memo, body format)
30006X-BM-TIMESTAMP is wrongEnsure X-BM-TIMESTAMP is present and is a Unix timestamp in milliseconds
30007Timestamp/recvWindow validation failedSync system clock (NTP), send X-BM-TIMESTAMP as Unix milliseconds, and ensure (serverTime - timestamp) <= recvWindow; recvWindow must be Long in (0,60000], default 5000 (max 60000). For signed contract flows that expose recvWindow, rely on recvWindow as the effective request-validity window.
30010IP forbiddenCheck API key IP whitelist settings
30013Rate limit exceededWait for rate limit window to reset, then retry
40035Order not existVerify the order ID is correct and belongs to this account
40044Invalid order sizeCheck min/max limits via GET /contract/public/details
40027Insufficient balanceCheck futures balance; may need to transfer from spot
42000Insufficient balance (margin)Reduce order size or add margin
40021Position does not existVerify position is still open before trying to close
40040Invalid leverage / mode constraintCheck leverage bracket and current position state; if position exists, keep current leverage + open_type
40012Parameter/state conflictCommonly appears when leverage/mode conflicts with current position/order state; query GET /contract/private/position-v2 and inherit existing leverage + open_type
429HTTP rate limitBack off exponentially, check X-BM-RateLimit-Reset header
418IP bannedStop all requests immediately; wait before retrying
403Cloudflare WAF blockCheck IP reputation (VPN/cloud IPs are commonly challenged); wait 30-60 seconds and retry; do not auto-retry more than 3 times
503Cloudflare challenge / origin unavailableSame as 403; if response body contains "Cloudflare" or "cf-", it is a Cloudflare interception, not a BitMart error; check network environment

Cloudflare Handling

BitMart API is behind Cloudflare CDN. If you receive HTTP 403/503 and the response body contains "Cloudflare", "cf-", or an HTML challenge page (instead of JSON):

  1. This is a Cloudflare interception, not a BitMart API error — do not parse as JSON
  2. Check if too many requests were sent in a short window (Cloudflare WAF has its own rules independent of API rate limits)
  3. Wait 30-60 seconds before retrying
  4. If running from a cloud server or VPN, the IP may have low reputation — try from a different network
  5. Do not auto-retry more than 3 times — inform the user if the issue persists

Cloudflare 1010: Non-curl HTTP clients with default bot-like User-Agent strings (e.g., Python-urllib, Go-http-client) may receive HTTP 403 / error 1010. Always send the User-Agent: bitmart-skills/futures/v2026.7.14 header from your HTTP library — do not rely on the library default.


Security Notes

  • Never display full API keys or secrets. Show first 5 + last 4 characters only (e.g., bmk12...9xyz).
  • All WRITE operations require explicit user confirmation before execution. Present a clear summary of the action and wait for "CONFIRM".
  • Recommend IP whitelist on API keys for additional security.
  • Recommend minimum permissions: Read-Only + Futures-Trade only (no Withdraw permission).
  • Leverage warning: Higher leverage amplifies both gains and losses. Always inform the user of the liquidation price before opening leveraged positions.
  • All trading outputs include disclaimer: "Not financial advice. You are solely responsible for your investment decisions. Futures trading carries significant risk of loss."

Reference: Order Types

TypeDescription
limitExecute at specified price or better
marketExecute immediately at best available price

Reference: Order Sides

ValueHedge ModeOne-Way Mode
1Open LongBuy
2Close ShortBuy (Reduce Only)
3Close LongSell (Reduce Only)
4Open ShortSell

Reference: Order Modes

ValueNameDescription
1GTCGood Till Cancel
2FOKFill or Kill
3IOCImmediate or Cancel
4Maker OnlyPost Only — rejected if it would immediately match

Reference: Order States

StateCodeDescription
Approving1Order being validated
Pending2Order accepted, awaiting fill
Closed4Order completed (filled or canceled)

Reference: Open Types (Margin Mode)

ValueDescription
crossCross margin — all available balance used as margin
isolatedIsolated margin — only allocated margin is at risk

Reference: Position Modes

ValueDescription
hedge_modeCan hold simultaneous long and short positions
one_way_modeCan hold only one direction at a time

Reference: Plan Categories

ValueDescription
1TP/SL order — applies to a specific order quantity
2Position TP/SL — applies to the entire position (default)

Reference: Price Types

ValueDescription
1Last price (default) — triggers based on last trade price
2Fair price (mark price) — triggers based on mark price

Reference: Price Way (Plan Orders)

ValueDescription
1Bullish — trigger when price rises above trigger_price
2Bearish — trigger when price drops below trigger_price

Reference: Transfer Types

ValueDescription
spot_to_contractSpot wallet to futures wallet
contract_to_spotFutures wallet to spot wallet

Reference: Flow Types (Transaction History)

ValueDescription
0All types
1Transfer
2Realized PNL
3Funding Fee
4Commission
6Liquidation

Reference: STP Modes (Self-Trade Prevention)

ValueDescription
1Cancel Maker (default)
2Cancel Taker
3Cancel Both

Reference: K-Line Steps

Step (minutes)Description
11-minute candles
33-minute candles
55-minute candles
1515-minute candles
3030-minute candles
601-hour candles
1202-hour candles
2404-hour candles
3606-hour candles
72012-hour candles
14401-day candles
43203-day candles
100801-week candles

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Bitmart Exchange Futures làm được gì?

Use when the user asks about BitMart futures or contract trading or Futures WebSocket streams, including opening/closing positions, setting leverage, placing plan (conditional) orders, take-profit/stop-loss, trailing orders, checking futures positions, managing futures account, closing all positions in one click, fund ↔ futures account transfers, sub-account transfers, affiliate/rebate queries, simulated trading, or streaming real-time futures ticker/book ticker/trades/depth/funding-rate/private order/private position updates. Do NOT use for spot trading (use bitmart-exchange-spot).

Vì sao nên dùng Bitmart Exchange Futures trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Bitmart Exchange Futures là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Bitmart Exchange Futures trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/bitmartexchange/bitmart-skills/tree/master/skills/bitmart-exchange-futures. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Bitmart Exchange Futures?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Bitmart Exchange Futures với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Bitmart Exchange Futures với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Bitmart Exchange Futures có miễn phí không?

Kỹ năng này được bitmartexchange phát hành trên GitHub. Hãy xem điều khoản giấy phép trong kho mã. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇