You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Bitget API触发订单报错43011:clientOid参数不符合规范求助

解决Bitget API触发订单报错43011(clientOid不符合规范)

问题原因

错误码43011明确指向clientOid参数不符合规范,你的代码中clientOid使用了test@483939290000,其中包含了Bitget API不允许的特殊字符@。

Bitget API对clientOid的要求

  • 仅允许包含字母、数字、下划线(_)
  • 长度限制在1-32字符范围内
  • 同一API密钥下需保证全局唯一(避免重复提交时的冲突)

修正后的代码

将clientOid替换为符合规范的字符串,比如把@改成_,或者直接使用纯数字字母组合:

import hashlib
import hmac
import base64
import requests
import json
import time

api_key = "key here"
secret_key = "secret"
passphrase = "pass"
base_url = "https://api.bitget.com"
endpoint = "/api/mix/v1/plan/placePlan"

# 修正clientOid格式,去掉@改用下划线
payload = {
    "symbol": "BTCUSDT_UMCBL",
    "marginCoin": "USDT",
    "size": "0.001",
    "executePrice": "33145.5",
    "triggerPrice":"33145.5",
    "side":"open_long",
    "orderType":"limit",
    "triggerType":"market_price",
    "clientOid":"test_483939290000"  # 替换@为下划线,符合格式要求
}

# Convert the payload to JSON format
payload_str = json.dumps(payload)

# Generate the signature
timestamp = str(int(time.time() * 1000))
message = timestamp + "POST" + endpoint + payload_str
signature = base64.b64encode(hmac.new(secret_key.encode('utf-8'), message.encode('utf-8'), 
hashlib.sha256).digest())

# Set the request headers
headers = {
    "ACCESS-KEY": api_key,
    "ACCESS-SIGN": signature,
    "ACCESS-TIMESTAMP": timestamp,
    "ACCESS-PASSPHRASE": passphrase,
    "Content-Type": "application/json"
}

# Send the request
response = requests.post(base_url + endpoint, headers=headers, data=payload_str)

# Print the response
print(response.json())

额外验证建议

  • 确认clientOid在你的API密钥下没有重复使用过
  • 检查其他参数格式是否符合要求(比如size的精度是否匹配合约规格,executePrice和triggerPrice的小数位数是否符合要求)

内容的提问来源于stack exchange,提问作者Andy S

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 05:43:20