algo

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Binance Algo Skill

Binance Algo 技能

Algo request on Binance using authenticated API endpoints. Requires API key and secret key for certain endpoints. Return the result in JSON format.
使用经过身份验证的API端点在Binance上发起Algo请求。部分端点需要API密钥和私钥,返回结果为JSON格式。

Quick Reference

快速参考

EndpointDescriptionRequiredOptionalAuthentication
/sapi/v1/algo/futures/order
(DELETE)
Cancel Algo Order(TRADE)algoIdrecvWindowYes
/sapi/v1/algo/futures/openOrders
(GET)
Query Current Algo Open Orders(USER_DATA)NonerecvWindowYes
/sapi/v1/algo/futures/historicalOrders
(GET)
Query Historical Algo Orders(USER_DATA)Nonesymbol, side, startTime, endTime, page, pageSize, recvWindowYes
/sapi/v1/algo/futures/subOrders
(GET)
Query Sub Orders(USER_DATA)algoIdpage, pageSize, recvWindowYes
/sapi/v1/algo/futures/newOrderTwap
(POST)
Time-Weighted Average Price(Twap) New Order(TRADE)symbol, side, quantity, durationpositionSide, clientAlgoId, reduceOnly, limitPrice, recvWindowYes
/sapi/v1/algo/futures/newOrderVp
(POST)
Volume Participation(VP) New Order (TRADE)symbol, side, quantity, urgencypositionSide, clientAlgoId, reduceOnly, limitPrice, recvWindowYes
/sapi/v1/algo/spot/order
(DELETE)
Cancel Algo Order(TRADE)algoIdrecvWindowYes
/sapi/v1/algo/spot/openOrders
(GET)
Query Current Algo Open Orders(USER_DATA)NonerecvWindowYes
/sapi/v1/algo/spot/historicalOrders
(GET)
Query Historical Algo Orders(USER_DATA)Nonesymbol, side, startTime, endTime, page, pageSize, recvWindowYes
/sapi/v1/algo/spot/subOrders
(GET)
Query Sub Orders(USER_DATA)algoIdpage, pageSize, recvWindowYes
/sapi/v1/algo/spot/newOrderTwap
(POST)
Time-Weighted Average Price(Twap) New Order(TRADE)symbol, side, quantity, durationclientAlgoId, limitPriceYes

端点描述必填参数可选参数是否需要身份验证
/sapi/v1/algo/futures/order
(DELETE)
取消Algo订单(交易类)algoIdrecvWindow
/sapi/v1/algo/futures/openOrders
(GET)
查询当前Algo未成交订单(用户数据类)recvWindow
/sapi/v1/algo/futures/historicalOrders
(GET)
查询历史Algo订单(用户数据类)symbol, side, startTime, endTime, page, pageSize, recvWindow
/sapi/v1/algo/futures/subOrders
(GET)
查询子订单(用户数据类)algoIdpage, pageSize, recvWindow
/sapi/v1/algo/futures/newOrderTwap
(POST)
时间加权平均价格(TWAP)新订单(交易类)symbol, side, quantity, durationpositionSide, clientAlgoId, reduceOnly, limitPrice, recvWindow
/sapi/v1/algo/futures/newOrderVp
(POST)
成交量参与(VP)新订单(交易类)symbol, side, quantity, urgencypositionSide, clientAlgoId, reduceOnly, limitPrice, recvWindow
/sapi/v1/algo/spot/order
(DELETE)
取消Algo订单(交易类)algoIdrecvWindow
/sapi/v1/algo/spot/openOrders
(GET)
查询当前Algo未成交订单(用户数据类)recvWindow
/sapi/v1/algo/spot/historicalOrders
(GET)
查询历史Algo订单(用户数据类)symbol, side, startTime, endTime, page, pageSize, recvWindow
/sapi/v1/algo/spot/subOrders
(GET)
查询子订单(用户数据类)algoIdpage, pageSize, recvWindow
/sapi/v1/algo/spot/newOrderTwap
(POST)
时间加权平均价格(TWAP)新订单(交易类)symbol, side, quantity, durationclientAlgoId, limitPrice

Parameters

参数

Common Parameters

通用参数

  • algoId: eg. 14511 (e.g., 1)
  • recvWindow: (e.g., 5000)
  • symbol: Trading symbol eg. BTCUSDT (e.g., BTCUSDT)
  • side: BUY or SELL (e.g., BUY)
  • startTime: in milliseconds eg.1641522717552 (e.g., 1623319461670)
  • endTime: in milliseconds eg.1641522526562 (e.g., 1641782889000)
  • page: Default is 1 (e.g., 1)
  • pageSize: MIN 1, MAX 100; Default 100 (e.g., 100)
  • symbol: Trading symbol eg. BTCUSDT (e.g., BTCUSDT)
  • side: Trading side ( BUY or SELL ) (e.g., BUY)
  • positionSide: Default
    BOTH
    for One-way Mode ;
    LONG
    or
    SHORT
    for Hedge Mode. It must be sent in Hedge Mode. (e.g., BOTH)
  • quantity: Quantity of base asset; Maximum notional per order is 200k, 2mm or 10mm, depending on symbol. Please reduce your size if you order is above the maximum notional per order. (e.g., 1.0)
  • duration: Duration for TWAP orders in seconds. [300, 86400] (e.g., 5000)
  • clientAlgoId: A unique id among Algo orders (length should be 32 characters), If it is not sent, we will give default value (e.g., 1)
  • reduceOnly: "true" or "false". Default "false"; Cannot be sent in Hedge Mode; Cannot be sent when you open a position
  • limitPrice: Limit price of the order; If it is not sent, will place order by market price by default (e.g., 1.0)
  • urgency: Represent the relative speed of the current execution; ENUM: LOW, MEDIUM, HIGH (e.g., LOW)
  • algoId:示例值14511(例如:1)
  • recvWindow:(例如:5000)
  • symbol:交易对,示例值BTCUSDT(例如:BTCUSDT)
  • side:BUY或SELL(例如:BUY)
  • startTime:毫秒级时间戳,示例值1641522717552(例如:1623319461670)
  • endTime:毫秒级时间戳,示例值1641522526562(例如:1641782889000)
  • page:默认值为1(例如:1)
  • pageSize:最小值1,最大值100;默认值100(例如:100)
  • symbol:交易对,示例值BTCUSDT(例如:BTCUSDT)
  • side:交易方向(BUY或SELL)(例如:BUY)
  • positionSide:单向模式下默认值为
    BOTH
    ;对冲模式下为
    LONG
    SHORT
    ,对冲模式下必须传入该参数(例如:BOTH)
  • quantity:基础资产数量;单笔订单的最大名义价值为20万、200万或1000万,具体取决于交易对。如果订单超过单笔最大名义价值,请减少订单规模(例如:1.0)
  • duration:TWAP订单的持续时间(秒),取值范围[300, 86400](例如:5000)
  • clientAlgoId:Algo订单的唯一标识(长度应为32个字符),若未传入,系统将自动生成默认值(例如:1)
  • reduceOnly:取值为"true"或"false",默认值为"false";对冲模式下不可传入;开仓时不可传入
  • limitPrice:订单限价,若未传入,默认以市价下单(例如:1.0)
  • urgency:表示当前执行的相对速度,可选值:LOW、MEDIUM、HIGH(例如:LOW)

Authentication

身份验证

For endpoints that require authentication, you will need to provide Binance API credentials. Required credentials:
  • apiKey: Your Binance API key (for header)
  • secretKey: Your Binance API secret (for signing)
Base URLs:
对于需要身份验证的端点,您需要提供Binance API凭证。 所需凭证:
  • apiKey:您的Binance API密钥(用于请求头)
  • secretKey:您的Binance API私钥(用于签名)
基础URL:

Security

安全规范

Share Credentials

凭证共享

Users can provide Binance API credentials by sending a file where the content is in the following format:
bash
abc123...xyz
secret123...key
用户可通过发送文件的方式提供Binance API凭证,文件内容格式如下:
bash
abc123...xyz
secret123...key

Never Disclose API Key and Secret

切勿泄露API密钥和私钥

Never disclose the location of the API key and secret file.
Never send the API key and secret to any website other than Mainnet and Testnet.
切勿泄露API密钥和私钥文件的存储位置。
切勿将API密钥和私钥发送至主网和测试网以外的任何网站。

Never Display Full Secrets

切勿显示完整私钥

When showing credentials to users:
  • API Key: Show first 5 + last 4 characters:
    su1Qc...8akf
  • Secret Key: Always mask, show only last 5:
    ***...aws1
Example response when asked for credentials: Account: main API Key: su1Qc...8akf Secret: ***...aws1
向用户展示凭证时:
  • API密钥:仅显示前5位+后4位字符:
    su1Qc...8akf
  • 私钥:始终掩码处理,仅显示最后5位:
    ***...aws1
询问凭证时的示例回复: 账户:main API密钥:su1Qc...8akf 私钥:***...aws1

Listing Accounts

列出账户

When listing accounts, show names and environment only — never keys: Binance Accounts:
  • main (Mainnet)
  • futures-keys (Mainnet)
列出账户时,仅显示账户名称和环境,绝不显示密钥: Binance账户:
  • main(主网)
  • futures-keys(主网)

Transactions in Mainnet

主网交易

When performing transactions in mainnet, always confirm with the user before proceeding by asking them to write "CONFIRM" to proceed.

在主网执行交易时,必须先征得用户确认,要求用户输入"CONFIRM"后再继续操作。

Binance Accounts

Binance账户

main

main

  • API Key: your_mainnet_api_key
  • Secret: your_mainnet_secret
  • API密钥:your_mainnet_api_key
  • 私钥:your_mainnet_secret

TOOLS.md Structure

TOOLS.md 结构

bash
undefined
bash
undefined

Binance Accounts

Binance Accounts

main

main

  • API Key: abc123...xyz
  • Secret: secret123...key
  • Description: Primary trading account
  • API Key: abc123...xyz
  • Secret: secret123...key
  • Description: Primary trading account

futures-keys

futures-keys

  • API Key: futures789...def
  • Secret: futuressecret...uvw
  • Description: Futures trading account
undefined
  • API Key: futures789...def
  • Secret: futuressecret...uvw
  • Description: Futures trading account
undefined

Agent Behavior

Agent 行为

  1. Credentials requested: Mask secrets (show last 5 chars only)
  2. Listing accounts: Show names and environment, never keys
  3. Account selection: Ask if ambiguous, default to main
  4. When doing a transaction in mainnet, confirm with user before by asking to write "CONFIRM" to proceed
  5. New credentials: Prompt for name, environment, signing mode
  1. 请求凭证时:对私钥进行掩码处理(仅显示最后5位)
  2. 列出账户时:仅显示账户名称和环境,绝不显示密钥
  3. 账户选择:若存在歧义则询问用户,默认选择main账户
  4. 在主网执行交易时,需先让用户输入"CONFIRM"确认后再继续
  5. 添加新凭证时:提示用户输入账户名称、环境和签名模式

Adding New Accounts

添加新账户

When user provides new credentials:
  • Ask for account name
  • Store in
    TOOLS.md
    with masked display confirmation
当用户提供新凭证时:
  • 询问账户名称
  • 将其存储在
    TOOLS.md
    中,并向用户展示掩码后的信息以确认

Signing Requests

请求签名

For trading endpoints that require a signature:
  1. Build query string with all parameters, including the timestamp (Unix ms).
  2. Percent-encode the parameters using UTF-8 according to RFC 3986.
  3. Sign query string with secretKey using HMAC SHA256, RSA, or Ed25519 (depending on the account configuration).
  4. Append signature to query string.
  5. Include
    X-MBX-APIKEY
    header.
Otherwise, do not perform steps 3–5.
对于需要签名的交易端点:
  1. 构建包含所有参数的查询字符串,包括时间戳(毫秒级Unix时间)
  2. 根据RFC 3986标准使用UTF-8对参数进行百分编码
  3. 使用私钥(secretKey)通过HMAC SHA256、RSA或Ed25519(取决于账户配置)对查询字符串进行签名
  4. 将签名附加到查询字符串中
  5. 包含
    X-MBX-APIKEY
    请求头
否则,无需执行步骤3-5。

User Agent Header

User Agent 请求头

Include
User-Agent
header with the following string:
binance-algo/1.0.0 (Skill)
See
references/authentication.md
for implementation details.
需在请求头中包含
User-Agent
,值为:
binance-algo/1.0.0 (Skill)
有关实现细节,请参阅
references/authentication.md