├── .gitignore ├── CHANGELOG.md ├── CHANGELOG_CN.md ├── PROD-TERMS-OF-USE.md ├── PROD-TERMS-OF-USE_CN.md ├── README.md ├── README_CN.md ├── enums.md ├── enums_CN.md ├── errors.md ├── errors_CN.md ├── faqs ├── api_key_types.md ├── api_key_types_CN.md ├── commission_faq.md ├── commission_faq_CN.md ├── market_data_only.md ├── market_data_only_CN.md ├── market_orders_faq.md ├── market_orders_faq_CN.md ├── order_amend_keep_priority.md ├── order_amend_keep_priority_CN.md ├── order_count_decrement.md ├── order_count_decrement_CN.md ├── sbe_faq.md ├── sbe_faq_CN.md ├── sor_faq.md ├── sor_faq_CN.md ├── spot_glossary.md ├── spot_glossary_CN.md ├── stp_faq.md ├── stp_faq_CN.md ├── trailing-stop-faq.md └── trailing-stop-faq_CN.md ├── filters.md ├── filters_CN.md ├── fix-api.md ├── fix-api_CN.md ├── fix └── schemas │ ├── spot-fix-md.xml │ └── spot-fix-oe.xml ├── rest-api.md ├── rest-api_CN.md ├── sbe-market-data-streams.md ├── sbe-market-data-streams_CN.md ├── sbe └── schemas │ ├── sbe_schema_lifecycle_prod.json │ ├── sbe_schema_lifecycle_testnet.json │ ├── spot_1_0.xml │ ├── spot_2_0.xml │ ├── spot_2_1.xml │ ├── spot_3_0.xml │ ├── spot_prod_latest.xml │ ├── spot_testnet_latest.xml │ └── stream_1_0.xml ├── testnet ├── CHANGELOG.md ├── TESTNET-TERMS-OF-USE.md ├── enums.md ├── errors.md ├── fix-api.md ├── rest-api.md ├── sbe-market-data-streams.md ├── user-data-stream.md ├── web-socket-api.md └── web-socket-streams.md ├── user-data-stream.md ├── user-data-stream_CN.md ├── web-socket-api.md ├── web-socket-api_CN.md ├── web-socket-streams.md └── web-socket-streams_CN.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | -------------------------------------------------------------------------------- /PROD-TERMS-OF-USE.md: -------------------------------------------------------------------------------- 1 | # SPOT Exchange Terms of Use 2 | 3 | Binance products and services are subject to the [Product Terms of Use](https://www.binance.com/en/terms).
4 | Please read it carefully before proceeding. 5 | -------------------------------------------------------------------------------- /PROD-TERMS-OF-USE_CN.md: -------------------------------------------------------------------------------- 1 | # SPOT 交易所使用条款 2 | 3 | 使用币安产品和服务须遵守 [产品使用条款](https://www.binance.com/zh-CN/terms)。
4 | 在继续之前,请仔细阅读。 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Official Documentation for the Binance APIs and Streams. 2 | * Official Announcements regarding changes, downtime, etc. to the API and Streams will be reported here: **https://t.me/binance_api_announcements** 3 | * Streams, endpoints, parameters, payloads, etc. described in the documents in this repository are considered **official** and **supported**. 4 | * The use of any other streams, endpoints, parameters, or payloads, etc. is **not supported**; **use them at your own risk and with no guarantees.** 5 | 6 | 7 | Name | Description 8 | ------------ | ------------ 9 | [enums.md](./enums.md) | Details on the enums used by REST and WebSocket API 10 | [errors.md](./errors.md) | Error codes and messages of Spot API 11 | [filters.md](./filters.md) | Details on the filters used by Spot API 12 | [rest-api.md](./rest-api.md) | Spot REST API (`/api`) 13 | [web-socket-api.md](./web-socket-api.md) | Spot WebSocket API 14 | [fix-api.md](fix-api.md) | FIX API 15 | [web-socket-streams.md](./web-socket-streams.md) | Spot Market Data WebSocket streams 16 | [sbe-market-data-streams.md](./sbe-market-data-streams.md) | SBE Market Data Streams 17 | [user-data-stream.md](./user-data-stream.md) | Spot User Data WebSocket streams 18 | [sbe_schemas](./sbe/schemas/) | Spot Simple Binary Encoding (SBE) schemas 19 | [testnet](./testnet/) | API docs for features available only on SPOT Testnet 20 | | 21 | [Margin Trading](https://developers.binance.com/docs/margin_trading) | Details on Margin Trading 22 | [Derivative UM Futures](https://developers.binance.com/docs/derivatives/usds-margined-futures/general-info) | Details on Derivative UM Futures (`/fapi`) 23 | [Derivative CM Futures](https://developers.binance.com/docs/derivatives/coin-margined-futures/general-info) | Details on Derivative CM Futures (`/dapi`) 24 | [Derivative Options](https://developers.binance.com/docs/derivatives/option/general-info) | Details on Derivative European Options (`/eapi`) 25 | [Derivative Portfolio Margin](https://developers.binance.com/docs/derivatives/portfolio-margin/general-info)| Details on Derivative Portfolio Margin (`/papi`) 26 | [Wallet](https://developers.binance.com/docs/wallet) | Details on Wallet endpoints (`/sapi`) 27 | [Sub Account](https://developers.binance.com/docs/sub_account/general-info) | Details on Sub-Account requests (`/sapi`) 28 | [Simple Earn](https://developers.binance.com/docs/simple_earn/general-info) | Details on Simple Earn 29 | [Dual Investment](https://developers.binance.com/docs/dual_investment) | Details on Dual Investment 30 | [Auto Invest](https://developers.binance.com/docs/auto_invest) | Details on Auto Invest 31 | [Staking](https://developers.binance.com/docs/staking) | Details on Staking 32 | [Mining](https://developers.binance.com/docs/mining) |Details on Mining 33 | [Algo Trading](https://developers.binance.com/docs/algo) |Details on Algo Trading 34 | [Copy Trading](https://developers.binance.com/docs/copy_trading) |Details on Copy Trading 35 | [Porfolio Margin Pro](https://developers.binance.com/docs/derivatives/portfolio-margin-pro/general-info) |Details on Portfolio Margin Pro 36 | [Fiat](https://developers.binance.com/docs/fiat) |Details on Fiat| 37 | [C2C](https://developers.binance.com/docs/c2c) |Details on C2C| 38 | [VIP Loan](https://developers.binance.com/docs/vip_loan) |Details on VIP Loan 39 | [Crypto Loan](https://developers.binance.com/docs/crypto_loan) |Details on Crypto Loan 40 | [Pay](https://developers.binance.com/docs/binance-pay) |Details on Binance Pay 41 | [Convert](https://developers.binance.com/docs/convert) |Details on Convert API 42 | [Rebate](https://developers.binance.com/docs/rebate) |Details on Spot Rebate 43 | [NFT](https://developers.binance.com/docs/nft) |Details on NFT requests 44 | [Gift Card](https://developers.binance.com/docs/gift_card) | Details on Gift Card API 45 | 46 | ### FAQ 47 | 48 | Name | Description 49 | ------------ | ------------ 50 | [spot_glossary](./faqs/spot_glossary.md) | Definition of terms used in the API 51 | [commissions_faq](./faqs/commissions_faq.md) | Explaining commission calculations on the API 52 | [trailing-stop-faq](./faqs/trailing-stop-faq.md) | Detailed Information on the behavior of Trailing Stops on the API 53 | [stp_faq](./faqs/stp_faq.md) | Detailed Information on the behavior of Self Trade Prevention (aka STP) on the API 54 | [market_orders_faq](./faqs/market_orders_faq.md)| Detailed information on the behavior of Market Orders 55 | [market-data-only](./faqs/market_data_only.md) | Information on our market data only API and WebSocket streams. 56 | [sor_faq](./faqs/sor_faq.md) | Smart Order Routing (SOR) 57 | [order_count_decrement](./faqs/order_count_decrement.md) | Updates to the Spot Order Count Limit Rules. 58 | [order_amend_keep_priority](./faqs/order_amend_keep_priority.md) | Detailed Information on the behavior of Order Amend Keep Priority 59 | [sbe_faq](./faqs/sbe_faq.md) | Information on the implementation of Simple Binary Encoding (SBE) on the API 60 | 61 | ### Change log 62 | 63 | Please refer to [CHANGELOG](./CHANGELOG.md) for latest changes on our APIs and Streamers. 64 | 65 | ### Useful Resources 66 | 67 | * [Postman Collections](https://github.com/binance/binance-api-postman) 68 | * Postman collections are available, and they are recommended for new users seeking a quick and easy start with the API. 69 | * Connectors 70 | * The following are lightweight libraries that work as connectors to the Binance public API, written in different languages: 71 | * [Python](https://github.com/binance/binance-connector-python) 72 | * [Node.js](https://github.com/binance/binance-connector-node) 73 | * [Ruby](https://github.com/binance/binance-connector-ruby) 74 | * [DotNET C#](https://github.com/binance/binance-connector-dotnet) 75 | * [Java](https://github.com/binance/binance-connector-java) 76 | * [Rust](https://github.com/binance/binance-spot-connector-rust) 77 | * [PHP](https://github.com/binance/binance-connector-php) 78 | * [Go](https://github.com/binance/binance-connector-go) 79 | * [TypeScript](https://github.com/binance/binance-connector-typescript) 80 | * FIX Connector - This provides access to the exchange using the FIX protocol. 81 | * [Python](https://github.com/binance/binance-fix-connector-python) 82 | * [Swagger](https://github.com/binance/binance-api-swagger) 83 | * A YAML file with OpenAPI specification for the RESTful API is available, along with a Swagger UI page for reference. 84 | * [Spot Testnet](https://testnet.binance.vision/) 85 | * Users can use the SPOT Testnet to practice SPOT trading. 86 | * Currently, this is only available via the API. 87 | * Only endpoints starting with `/api/*` are supported, `/sapi/*` is not supported. 88 | 89 | ### Contact Us 90 | 91 | * [Binance API Telegram Group](https://t.me/binance_api_english) 92 | * For any questions regarding sudden drop in performance with the API and/or Websockets. 93 | * For any general questions about the API not covered in the documentation. 94 | * [Binance Developers](https://dev.binance.vision/) 95 | * For any questions/help regarding code implementation with API and/or Websockets. 96 | * [Binance Customer Support](https://www.binance.com/en/support-center) 97 | * For cases such as missing funds, help with 2FA, etc. 98 | -------------------------------------------------------------------------------- /README_CN.md: -------------------------------------------------------------------------------- 1 | # 关于本中文翻译版 2 | * 中文文档由英文文档翻译而来,当中文文档内容与英文文档冲突时,以英文文档为准。 3 | 4 | ### 币安API文档 5 | * 有关 API 和数据流的更改、停机等官方公告将在此处发布:**https://t.me/binance_api_announcements** 6 | * 所有于本文档内给出定义的包括但不限于接口,数据流,参数,响应等,可认为是币安官方提供的内容。 7 | * 而所有未于本文档内给出的内容,币安均不承诺提供任何支持。 8 | 9 | 文档名 | 描述 10 | ------------ | ------------ 11 | [enums_CN.md](./enums_CN.md) | 适用于 Rest API 和 WebSocket API 的枚举定义 12 | [errors_CN.md](./errors_CN.md) | 现货 API 的错误代码及含义 13 | [filters_CN.md](./filters_CN.md) | 现货 API 使用的过滤器的详细信息 14 | [rest-api_CN.md](./rest-api_CN.md) | 现货 Rest API 接口定义 (`/api`) 15 | [fix-api_CN.md](fix-api_CN.md) | 现货 FIX API 16 | [web-socket-api_CN.md](./web-socket-api_CN.md) | 现货 WebSocket API 17 | [web-socket-streams_CN.md](./web-socket-streams_CN.md) | 现货行情数据流接口的描述 18 | [sbe-market-data-streams_CN.md](./sbe-market-data-streams_CN.md)|SBE 市场数据流 19 | [user-data-stream_CN.md](./user-data-stream_CN.md) | 现货用户数据流接口的描述 20 | [sbe_schemas](./sbe/schemas/) | 现货API的简单二进制编码 (SBE)模式 (Schema) 21 | | 22 | [Margin Trading](https://developers.binance.com/docs/zh-CN/margin_trading/Introduction) | 关于杠杆交易的描述 23 | [Derivative UM Futures](https://developers.binance.com/docs/zh-CN/derivatives/usds-margined-futures/general-info) | 关于U本位合约相关接口的描述 (`/fapi`) 24 | [Derivative CM Futures](https://developers.binance.com/docs/zh-CN/derivatives/coin-margined-futures/general-info) | 关于币本位合约相关接口的描述 (`/dapi`) 25 | [Derivative Options](https://developers.binance.com/docs/zh-CN/derivatives/option/general-info) | 关于欧式期权的描述 (`/eapi`) 26 | [Derivative Portfolio Margin](https://developers.binance.com/docs/zh-CN/derivatives/portfolio-margin/general-info)| 关于统一账户的描述 (`/papi`) 27 | [Wallet](https://developers.binance.com/docs/zh-CN/wallet/Introduction) | 关于钱包的描述 (`/sapi`) 28 | [Sub Account](https://developers.binance.com/docs/zh-CN/sub_account/Introduction) | 关于子母账户接口的描述 (`/sapi`) 29 | [Simple Earn](https://developers.binance.com/docs/zh-CN/simple_earn/Introduction) | 关于赚币的描述 30 | [Dual Investment](https://developers.binance.com/docs/binance-spot-api-docs/CHANGELOG) | 关于双币投资接口的描述 31 | [Auto Invest](https://developers.binance.com/docs/zh-CN/auto_invest/Introduction) | 关于定投接口的描述 32 | [Staking](https://developers.binance.com/docs/zh-CN/staking/Introduction) | 关于ETH质押接口的描述 33 | [Mining](https://developers.binance.com/docs/zh-CN/mining/Introduction) | 关于矿池接口的描述 34 | [Algo Trading](https://developers.binance.com/docs/zh-CN/algo/Introduction) | 关于策略交易的描述 35 | [Copy Trading](https://developers.binance.com/docs/zh-CN/copy_trading/Introduction) | 关于跟单交易的描述 36 | [Porfolio Margin Pro](https://developers.binance.com/docs/zh-CN/derivatives/portfolio-margin-pro/general-info) | 关于统一账户专业版的描述 37 | [Fiat](https://developers.binance.com/docs/zh-CN/fiat/Introduction) | 关于法币的描述| 38 | [C2C](https://developers.binance.com/docs/zh-CN/c2c/Introduction) | 关于 C2C 接口的描述| 39 | [VIP Loan](https://developers.binance.com/docs/zh-CN/vip_loan/Introduction) | 关于 VIP 借币的描述 40 | [Crypto Loan](https://developers.binance.com/docs/zh-CN/crypto_loan/Introduction) | 关于质押借币的描述 41 | [Pay](https://developers.binance.com/docs/zh-CN/binance-pay/introduction) |关于币安 Pay 的描述 42 | [Convert](https://developers.binance.com/docs/zh-CN/convert/Introduction) | 关于闪兑接口的描述 43 | [Rebate](https://developers.binance.com/docs/zh-CN/rebate/Introduction) | 关于返佣的描述 44 | [NFT](https://developers.binance.com/docs/zh-CN/nft/Introduction) | 关于 NFT 的描述 45 | [Gift Card](https://developers.binance.com/docs/zh-CN/gift_card/Introduction) | 关于礼品卡的描述 46 | 47 | ### 常见问题 48 | 49 | 50 | 名称 | 描述 51 | ------------ | ------------ 52 | [spot_glossary_CN](./faqs/spot_glossary_CN.md) | 现货交易 API 术语表 53 | [commission_faq_CN](./faqs/commission_faq_CN.md) | 解释 API 上所使用的佣金计算方式 54 | [trailing_stop_faq_CN](./faqs/trailing-stop-faq_CN.md) | 追踪止盈止损订单(Trailing Stop)详细信息和常见问题 55 | [stp_faq_CN](./faqs/stp_faq_CN.md) | 关于 Self Trade Prevention (STP) 的详细信息 56 | [market_orders_faq_CN](./faqs/market_orders_faq_CN.md)| 关于市价单行为的详细信息 57 | [market_data_only_CN](./faqs/market_data_only_CN.md) | 仅提供市场数据的 API 和 WebSocket Streams 58 | [sor_faq_CN](./faqs/sor_faq_CN.md) | 智能指令路由 (SOR) 59 | [order_amend_keep_priority_CN](./faqs/order_amend_keep_priority_CN.md)| 关于修改订单并保留其优先级的详细信息 60 | [order_count_decrement_CN](./faqs/order_count_decrement_CN.md) | 现货下单频率限制的更新 61 | [sbe_faq_CN](./faqs/sbe_faq_CN.md) | 关于在 API 上实施简单二进制编码 (SBE) 的信息 62 | 63 | ### 更新日志 64 | 65 | 关于 API 和数据流方面的最新变动,请参考 [更新日志](./CHANGELOG_CN.md)。 66 | 67 | 68 | ### 相关信息 69 | 70 | * [Postman Collections](https://github.com/binance/binance-api-postman) 71 | * 现在你可以通过使用 Postman Collections 来快速体验和使用 API 接口。 72 | * Connectors 73 | * 以下是以不同编程语言编写的轻量代码库,可作为连接到币安公共 API 的连接器: 74 | * [Python](https://github.com/binance/binance-connector-python) 75 | * [Node.js](https://github.com/binance/binance-connector-node) 76 | * [Ruby](https://github.com/binance/binance-connector-ruby) 77 | * [DotNET C#](https://github.com/binance/binance-connector-dotnet) 78 | * [Java](https://github.com/binance/binance-connector-java) 79 | * [Rust](https://github.com/binance/binance-spot-connector-rust) 80 | * [PHP](https://github.com/binance/binance-connector-php) 81 | * [Go](https://github.com/binance/binance-connector-go) 82 | * [TypeScript](https://github.com/binance/binance-connector-typescript) 83 | * FIX Connector - 这提供了使用 FIX 协议对交易所的访问. 84 | * [Python](https://github.com/binance/binance-fix-connector-python) 85 | * [Swagger](https://github.com/binance/binance-api-swagger) 86 | * 一个基于 OpenAPI 规范的 RESTful API 接口定义的 YAML 文件,还有便于交互的 Swagger UI 页面。 87 | * [Spot Testnet](https://testnet.binance.vision/) 88 | * 用户可以使用现货的测试网来体验 SPOT 交易。 89 | * 现在只能通过 API 来测试交易,没有 UI。 90 | * 只支持以 `/api/*`开头的接口,`/sapi/*`接口不支持。 91 | 92 | ### 联系我们 93 | 94 | * [Binance API 中文电报群](https://t.me/binance_api_chinese) 或 [Binance API 英文电报群](https://t.me/binance_api_english) 95 | * 适合咨询关于 API 或者 Websocket 性能方面的疑问和困扰。 96 | * 可以咨询在文档上面没有的 API 问题。 97 | * [Binance 开发者论坛](https://dev.binance.vision/) 98 | * 可以提问或者咨询关于 API 或者 Websocket 代码方面问题。 99 | * [Binance 客服](https://www.binance.com/zh-CN/support-center) 100 | * 咨询关于账户,资金,2FA 等问题。 101 | -------------------------------------------------------------------------------- /enums.md: -------------------------------------------------------------------------------- 1 | # ENUM Definitions 2 | 3 | This will apply for both REST API and WebSocket API. 4 | 5 | ## Symbol status (status) 6 | 7 | * `TRADING` 8 | * `END_OF_DAY` 9 | * `HALT` 10 | * `BREAK` 11 | 12 | 13 | 14 | ## Account and Symbol Permissions (permissions) 15 | 16 | * `SPOT` 17 | * `MARGIN` 18 | * `LEVERAGED` 19 | * `TRD_GRP_002` 20 | * `TRD_GRP_003` 21 | * `TRD_GRP_004` 22 | * `TRD_GRP_005` 23 | * `TRD_GRP_006` 24 | * `TRD_GRP_007` 25 | * `TRD_GRP_008` 26 | * `TRD_GRP_009` 27 | * `TRD_GRP_010` 28 | * `TRD_GRP_011` 29 | * `TRD_GRP_012` 30 | * `TRD_GRP_013` 31 | * `TRD_GRP_014` 32 | * `TRD_GRP_015` 33 | * `TRD_GRP_016` 34 | * `TRD_GRP_017` 35 | * `TRD_GRP_018` 36 | * `TRD_GRP_019` 37 | * `TRD_GRP_020` 38 | * `TRD_GRP_021` 39 | * `TRD_GRP_022` 40 | * `TRD_GRP_023` 41 | * `TRD_GRP_024` 42 | * `TRD_GRP_025` 43 | 44 | ## Order status (status) 45 | 46 | Status | Description 47 | -----------| -------------- 48 | `NEW` | The order has been accepted by the engine. 49 | `PENDING_NEW`|The order is in a pending phase until the working order of an order list has been fully filled. 50 | `PARTIALLY_FILLED`| A part of the order has been filled. 51 | `FILLED` | The order has been completed. 52 | `CANCELED` | The order has been canceled by the user. 53 | `PENDING_CANCEL` | Currently unused 54 | `REJECTED` | The order was not accepted by the engine and not processed. 55 | `EXPIRED` | The order was canceled according to the order type's rules (e.g. LIMIT FOK orders with no fill, LIMIT IOC or MARKET orders that partially fill)
or by the exchange, (e.g. orders canceled during liquidation, orders canceled during maintenance) 56 | `EXPIRED_IN_MATCH` | The order was expired by the exchange due to STP. (e.g. an order with `EXPIRE_TAKER` will match with existing orders on the book with the same account or same `tradeGroupId`) 57 | 58 | ## Order List Status (listStatusType) 59 | 60 | Status | Description 61 | -----------| -------------- 62 | `RESPONSE` | This is used when the ListStatus is responding to a failed action. (E.g. order list placement or cancellation) 63 | `EXEC_STARTED`| The order list has been placed or there is an update to the order list status. 64 | `UPDATED` | The clientOrderId of an order in the order list has been changed. 65 | `ALL_DONE` | The order list has finished executing and thus is no longer active. 66 | 67 | 68 | ## Order List Order Status (listOrderStatus) 69 | 70 | Status | Description 71 | -----------| -------------- 72 | `EXECUTING` | Either an order list has been placed or there is an update to the status of the list. 73 | `ALL_DONE`| An order list has completed execution and thus no longer active. 74 | `REJECT` | The List Status is responding to a failed action either during order placement or order canceled. 75 | 76 | ## ContingencyType 77 | 78 | * `OCO` 79 | * `OTO` 80 | 81 | 82 | 83 | ## AllocationType 84 | 85 | * `SOR` 86 | 87 | 88 | 89 | ## Order types (orderTypes, type) 90 | 91 | * `LIMIT` 92 | * `MARKET` 93 | * `STOP_LOSS` 94 | * `STOP_LOSS_LIMIT` 95 | * `TAKE_PROFIT` 96 | * `TAKE_PROFIT_LIMIT` 97 | * `LIMIT_MAKER` 98 | 99 | 100 | 101 | ## Order Response Type (newOrderRespType) 102 | 103 | * `ACK` 104 | * `RESULT` 105 | * `FULL` 106 | 107 | ## Working Floor 108 | 109 | * `EXCHANGE` 110 | * `SOR` 111 | 112 | 113 | 114 | ## Order side (side) 115 | 116 | * `BUY` 117 | * `SELL` 118 | 119 | 120 | 121 | ## Time in force (timeInForce) 122 | 123 | This sets how long an order will be active before expiration. 124 | 125 | Status | Description 126 | -----------| -------------- 127 | `GTC` | Good Til Canceled
An order will be on the book unless the order is canceled. 128 | `IOC` | Immediate Or Cancel
An order will try to fill the order as much as it can before the order expires. 129 | `FOK`| Fill or Kill
An order will expire if the full order cannot be filled upon execution. 130 | 131 | 132 | ## Rate limiters (rateLimitType) 133 | 134 | * REQUEST_WEIGHT 135 | 136 | ```json 137 | { 138 | "rateLimitType": "REQUEST_WEIGHT", 139 | "interval": "MINUTE", 140 | "intervalNum": 1, 141 | "limit": 6000 142 | } 143 | ``` 144 | 145 | * ORDERS 146 | 147 | ```json 148 | { 149 | "rateLimitType": "ORDERS", 150 | "interval": "SECOND", 151 | "intervalNum": 1, 152 | "limit": 10 153 | } 154 | ``` 155 | 156 | * RAW_REQUESTS 157 | 158 | ```json 159 | { 160 | "rateLimitType": "RAW_REQUESTS", 161 | "interval": "MINUTE", 162 | "intervalNum": 5, 163 | "limit": 61000 164 | } 165 | ``` 166 | 167 | ## Rate limit intervals (interval) 168 | 169 | * SECOND 170 | * MINUTE 171 | * DAY 172 | 173 | 174 | 175 | ## STP Modes 176 | 177 | Read [Self Trade Prevention (STP) FAQ](faqs/stp_faq.md) to learn more. 178 | 179 | * `NONE` 180 | * `EXPIRE_MAKER` 181 | * `EXPIRE_TAKER` 182 | * `EXPIRE_BOTH` 183 | * `DECREMENT` 184 | -------------------------------------------------------------------------------- /enums_CN.md: -------------------------------------------------------------------------------- 1 | # 枚举定义 2 | 3 | 这将适用于 REST API 和 WebSocket API。 4 | 5 | ## 交易对的状态(status) 6 | 7 | * `TRADING` - 正常交易中 8 | * `END_OF_DAY` - 收盘 9 | * `HALT` - 交易终止(该交易对已下线) 10 | * `BREAK` - 交易暂停 11 | 12 | 13 | 14 | ## 账户与交易对权限(permissions) 15 | 16 | * `SPOT` - 现货 17 | * `MARGIN` - 杠杆 18 | * `LEVERAGED` - 杠杆代币 19 | * `TRD_GRP_002` - 交易组 002 20 | * `TRD_GRP_003` - 交易组 003 21 | * `TRD_GRP_004` - 交易组 004 22 | * `TRD_GRP_005` - 交易组 005 23 | * `TRD_GRP_006` - 交易组 006 24 | * `TRD_GRP_007` - 交易组 007 25 | * `TRD_GRP_008` - 交易组 008 26 | * `TRD_GRP_009` - 交易组 009 27 | * `TRD_GRP_010` - 交易组 010 28 | * `TRD_GRP_011` - 交易组 011 29 | * `TRD_GRP_012` - 交易组 012 30 | * `TRD_GRP_013` - 交易组 013 31 | * `TRD_GRP_014` - 交易组 014 32 | * `TRD_GRP_015` - 交易组 015 33 | * `TRD_GRP_016` - 交易组 016 34 | * `TRD_GRP_017` - 交易组 017 35 | * `TRD_GRP_018` - 交易组 018 36 | * `TRD_GRP_019` - 交易组 019 37 | * `TRD_GRP_020` - 交易组 020 38 | * `TRD_GRP_021` - 交易组 021 39 | * `TRD_GRP_022` - 交易组 022 40 | * `TRD_GRP_023` - 交易组 023 41 | * `TRD_GRP_024` - 交易组 024 42 | * `TRD_GRP_025` - 交易组 025 43 | 44 | ## 订单状态(status) 45 | 46 | 状态 |描述 47 | -----------|-------------- 48 | `NEW` | 该订单被交易引擎接受。 49 | `PENDING_NEW` | 该订单处于待处理 (`PENDING`) 阶段,直到其所属订单组(order list) 中的 `working order` 完全成交。 50 | `PARTIALLY_FILLED` | 部分订单已被成交。 51 | `FILLED`| 订单已完全成交。 52 | `CANCELED` | 用户撤销了订单。 53 | `PENDING_CANCEL` | 撤销中(目前并未使用) 54 | `REJECTED` | 订单没有被交易引擎接受,也没被处理。 55 | `EXPIRED` | 该订单根据订单类型的规则被取消(例如,没有成交的 LIMIT FOK 订单, LIMIT IOC 或部分成交的 MARKET 订单)
或者被交易引擎取消(例如,在强平期间被取消的订单,在交易所维护期间被取消的订单) 56 | `EXPIRED_IN_MATCH` | 表示订单由于 STP 而过期。(例如,带有 `EXPIRE_TAKER` 的订单与账簿上同属相同帐户或相同 `tradeGroupId` 的现有订单匹配) 57 | 58 | ## 订单组(order list)状态 (状态类型集 listStatusType) 59 | 60 | 状态 |描述 61 | -----------|-------------- 62 | `RESPONSE` | 在 ListStatus 用于响应失败的操作时会被使用。(例如,下订单组或取消订单组) 63 | `EXEC_STARTED` | 订单组已被下达或订单组状态有更新。 64 | `UPDATED` | 订单组里的某个订单的 clientOrderId 被改变。 65 | `ALL_DONE` | 订单组执行结束,因此不再处于活动状态。 66 | 67 | ## 订单组(order list)中的订单状态 (订单状态集 listOrderStatus) 68 | 69 | 状态 |描述 70 | -----------|-------------- 71 | `EXECUTING` | 订单组已被下达或订单组状态有更新。 72 | `ALL_DONE`| 订单组执行结束,因此不再处于活动状态。 73 | `REJECT` | 在 ListStatus 用于响应在下单阶段或取消订单组期间的失败操作时会被使用, 74 | 75 | ## 订单组的类型 76 | 77 | * `OCO` 78 | * `OTO` 79 | 80 | 81 | 82 | ## 分配类型 83 | 84 | * `SOR` 85 | 86 | 87 | 88 | ## 订单类型(orderTypes, type) 89 | 90 | * `LIMIT` - 限价单 91 | * `MARKET` - 市价单 92 | * `STOP_LOSS` - 止损单 93 | * `STOP_LOSS_LIMIT` - 限价止损单 94 | * `TAKE_PROFIT` - 止盈单 95 | * `TAKE_PROFIT_LIMIT` - 限价止盈单 96 | * `LIMIT_MAKER` - 限价做市单 97 | 98 | 99 | 100 | ## 订单返回类型 (newOrderRespType) 101 | 102 | * `ACK` 103 | * `RESULT` 104 | * `FULL` 105 | 106 | ## 工作平台 107 | 108 | * `EXCHANGE` - 常规交易 109 | * `SOR` - 智能订单路由 110 | 111 | 112 | 113 | ## 订单方向 (side) 114 | 115 | * `BUY` - 买入 116 | * `SELL` - 卖出 117 | 118 | 119 | 120 | ## 生效时间 (timeInForce) 121 | 122 | 这里定义了订单在失效前的有效时间。 123 | 124 | 状态 |描述 125 | -----------|-------------- 126 | `GTC` | 成交为止
订单会一直有效,直到被成交或者取消。 127 | `IOC` | 无法立即成交的部分就撤销
订单在失效前会尽量多的成交。 128 | `FOK` | 无法全部立即成交就撤销
如果无法全部成交,订单会失效。 129 | 130 | 131 | ## 速率限制种类(rateLimitType) 132 | 133 | * REQUESTS_WEIGHT - 单位时间请求权重之和上限 134 | 135 | ```json 136 | { 137 | "rateLimitType": "REQUEST_WEIGHT", 138 | "interval": "MINUTE", 139 | "intervalNum": 1, 140 | "limit": 6000 141 | } 142 | ``` 143 | 144 | * ORDERS - 单位时间下单(撤单)次数上限 145 | 146 | ```json 147 | { 148 | "rateLimitType": "ORDERS", 149 | "interval": "SECOND", 150 | "intervalNum": 1, 151 | "limit": 10 152 | } 153 | ``` 154 | 155 | * RAW_REQUESTS - 单位时间请求次数上限 156 | 157 | ```json 158 | { 159 | "rateLimitType": "RAW_REQUESTS", 160 | "interval": "MINUTE", 161 | "intervalNum": 5, 162 | "limit": 61000 163 | } 164 | ``` 165 | 166 | ## 速率限制间隔 (interval) 167 | 168 | * SECOND 169 | * MINUTE 170 | * DAY 171 | 172 | 173 | 174 | ## STP 模式 175 | 176 | 请参阅 [自我交易预防 (Self Trade Prevention - STP) 常见问题](faqs/stp_faq_CN.md)。 177 | 178 | * `NONE` 179 | * `EXPIRE_MAKER` 180 | * `EXPIRE_TAKER` 181 | * `EXPIRE_BOTH` 182 | * `DECREMENT` 183 | -------------------------------------------------------------------------------- /faqs/api_key_types.md: -------------------------------------------------------------------------------- 1 | # API Key Types 2 | 3 | Binance APIs require an API key to access authenticated endpoints for trading, account history, etc. 4 | 5 | We support several types of API keys: 6 | 7 | - Ed25519 (recommended) 8 | - HMAC 9 | - RSA 10 | 11 | This document provides an overview of supported API keys. 12 | 13 | **We recommend to use Ed25519 API keys** as it should provide the best performance and security out of all supported key types. 14 | 15 | Read [REST API](../rest-api.md#signed-trade-and-user_data-endpoint-security) or [WebSocket API](../web-socket-api.md#request-security) documentation to learn how to use different API keys. 16 | 17 | ## Ed25519 18 | 19 | Ed25519 keys use asymmetric cryptography. 20 | You share your public key with Binance and use the private key to sign API requests. 21 | Binance API uses the public key to verify your signature. 22 | 23 | Ed25519 keys provide security comparable to 3072-bit RSA keys, but with considerably smaller key, smaller signature size, and faster signature computation. 24 | 25 | **We recommend to use Ed25519 API keys.** 26 | 27 | Sample Ed25519 key: 28 | ``` 29 | -----BEGIN PUBLIC KEY----- 30 | MCowBQYDK2VwAyEAgmDRTtj2FA+wzJUIlAL9ly1eovjLBu7uXUFR+jFULmg= 31 | -----END PUBLIC KEY----- 32 | ``` 33 | 34 | Sample Ed25519 signature: 35 | 36 | ``` 37 | E7luAubOlcRxL10iQszvNCff+xJjwJrfajEHj1hOncmsgaSB4NE+A/BbQhCWwit/usNJ32/LeTwDYPoA7Qz4BA== 38 | ``` 39 | 40 | ## HMAC 41 | 42 | HMAC keys use symmetric cryptography. 43 | Binance generates and shares with you a secret key which you use to sign API requests. 44 | Binance API uses the same shared secret key to verify your signature. 45 | 46 | HMAC signatures are quick to compute and compact.
47 | However, the shared secret must be shared between multiple parties which is less secure than asymmetric cryptography used by Ed25519 or RSA keys. 48 | 49 | **HMAC keys are deprecated.** We recommend to migrate to asymmetric API keys, such as Ed25519 or RSA. 50 | 51 | Sample HMAC key: 52 | 53 | ``` 54 | Fhs4lGae2qAi6VNjbJjebUAwXrIChb7mlf372UOICMwdKaNdNBGKtfdeUff2TTTT 55 | ``` 56 | 57 | Sample HMAC signature: 58 | 59 | ``` 60 | 7f3fc79c57d7a70d2b644ad4589672f4a5d55a62af2a336a0af7d4896f8d48b8 61 | ``` 62 | 63 | ## RSA 64 | 65 | RSA keys use asymmetric cryptography.
66 | You share your public key with Binance and use the private key to sign API requests.
67 | Binance API uses the public key to verify your signature. 68 | 69 | We support 2048 and 4096 bit RSA keys. 70 | 71 | While RSA keys are more secure than HMAC keys, 72 | RSA signatures are much larger than HMAC and Ed25519 which can lead to a degradation to performance. 73 | 74 | Sample RSA key (2048 bits): 75 | 76 | ``` 77 | -----BEGIN PUBLIC KEY----- 78 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyfKiFXpcOhF5rX1XxePN 79 | akwN7Etwtn3v05cZNY+ftDHbVZHs/kY6Ruj5lhxVFAq5dv7Ba9/4jPijXuMuIc6Y 80 | 8nUlqtrrxC8DEOAczw9SKATDYZN9nbLfYlbBFfHzRQUXdAtYCPI6XtxmJBS7aOBb 81 | 4nZe1SVm+bhLrp0YQnx2P0s+37qkGeVn09m6w9MnWxjgCkkYFPWQkXIu5qOnwx6p 82 | NfqDmFD7d7dUc/6PZQ1bKFALu/UETsobmBk82ShbrBhlc0JXuhf9qBR7QASjHjFQ 83 | 2N+VF2PfH8dm5prZIpz/MFKPkBW4Yuss0OXiD+jQt1J2JUKspLqsIqoXjHQQGjL7 84 | 3wIDAQAB 85 | -----END PUBLIC KEY----- 86 | ``` 87 | 88 | Sample RSA signature (2048 bits): 89 | 90 | ``` 91 | wS6q6h77AvH1TqwInoTDdWIIubRCiUP4RLG++GI24twL3BMtX0EEV+YT1eH8Hb8bLe0Rb9OhOHbt1CC3aurzoCTgZvhNek47mg+Bpu8fwQ7eRkXEiWBx5C8BNN73JwnnkZw4UzYvqiwAs162jToV8AL0eN043KJ3MEKCy3C6nyeYOFSg+1Cp637KtAZk3z7aHknSu7/PXSPuwMIpBgFctf8YKGZFAVRbgwlcgUDhXyaGts6OFePGy0jkZKJHawb/w5hoatatsfVmVC4hZ8fsfystQ9k5DNjTm7ROApWaXy9BsfAYcj13O424mqlpkKG4EGnIjOIWB/pRDDQEm2O/xg== 92 | ``` 93 | -------------------------------------------------------------------------------- /faqs/api_key_types_CN.md: -------------------------------------------------------------------------------- 1 | # API Key 类型 2 | 3 | 币安 API 需要 API Key 才能访问经过身份验证的接口以进行交易,账户历史记录等。 4 | 5 | 我们支持多种类型的 API key: 6 | 7 | - Ed25519(推荐) 8 | - HMAC 9 | - RSA 10 | 11 | 本文档概述了受支持的 API Keys。 12 | 13 | **我们建议使用 Ed25519 API keys**,因为它在所有受支持的 API key 类型中提供最佳性能和安全性。 14 | 15 | 请读 [REST API](../rest-api_CN.md#需要签名的接口-trade-与-user_data) 或者 [WebSocket API](../web-socket-api_CN.md#请求鉴权类型) 文档以了解如何使用不同的 API Key 类型。 16 | 17 | ## Ed25519 18 | 19 | Ed25519 keys 使用非对称加密技术。 20 | 您只与币安共享您的 public key 并在本地使用 private key 签署 API 请求。 21 | 币安 API 会使用 public key 来验证您的请求签名。 22 | 23 | Ed25519 Keys 提供与 3072 bits 的 RSA keys 相当的安全性,但是 key 更小,签名更小,签名的计算更快。 24 | 25 | **我们建议使用 Ed25519 API keys** 26 | 27 | Ed25519 key 例子: 28 | 29 | ``` 30 | -----BEGIN PUBLIC KEY----- 31 | MCowBQYDK2VwAyEAgmDRTtj2FA+wzJUIlAL9ly1eovjLBu7uXUFR+jFULmg= 32 | -----END PUBLIC KEY----- 33 | ``` 34 | 35 | Ed25519 签名例子: 36 | 37 | ``` 38 | E7luAubOlcRxL10iQszvNCff+xJjwJrfajEHj1hOncmsgaSB4NE+A/BbQhCWwit/usNJ32/LeTwDYPoA7Qz4BA== 39 | ``` 40 | 41 | ## HMAC 42 | 43 | HMAC keys 使用对称加密技术。 44 | 币安生成并与您共享一个 secret key,您可以使用该 secret key 对 API 请求进行签名。 45 | 币安 API 使用相同的共享 secret key 来验证您的请求签名。 46 | 47 | HMAC 签名可以快速计算和压缩。
48 | 但是,由于共享 secret key 必须在多方之间共享,这就不如 Ed25519 或 RSA keys 使用的非对称加密技术那么安全。 49 | 50 | **不建议使用 HMAC keys。** 我们建议换成并使用非对称 API Keys,例如 Ed25519 或 RSA。 51 | 52 | HMAC key 例子: 53 | 54 | ``` 55 | Fhs4lGae2qAi6VNjbJjebUAwXrIChb7mlf372UOICMwdKaNdNBGKtfdeUff2TTTT 56 | ``` 57 | 58 | HMAC 签名例子: 59 | 60 | ``` 61 | 7f3fc79c57d7a70d2b644ad4589672f4a5d55a62af2a336a0af7d4896f8d48b8 62 | ``` 63 | 64 | ## RSA 65 | 66 | RSA keys 使用非对称加密技术。
67 | 您只与币安共享您的 public key 并在本地使用 private key 签署 API 请求。 68 | 币安 API 会使用 public key 来验证您的请求签名。 69 | 70 | 我们支持 2048 和 4096 bits 的 RSA keys。 71 | 72 | 虽然 RSA keys 比 HMAC keys 更安全,RSA 签名比 HMAC 和 Ed25519 大很多,这会降低性能。 73 | 74 | RSA (2048 bits) 例子: 75 | 76 | ``` 77 | -----BEGIN PUBLIC KEY----- 78 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyfKiFXpcOhF5rX1XxePN 79 | akwN7Etwtn3v05cZNY+ftDHbVZHs/kY6Ruj5lhxVFAq5dv7Ba9/4jPijXuMuIc6Y 80 | 8nUlqtrrxC8DEOAczw9SKATDYZN9nbLfYlbBFfHzRQUXdAtYCPI6XtxmJBS7aOBb 81 | 4nZe1SVm+bhLrp0YQnx2P0s+37qkGeVn09m6w9MnWxjgCkkYFPWQkXIu5qOnwx6p 82 | NfqDmFD7d7dUc/6PZQ1bKFALu/UETsobmBk82ShbrBhlc0JXuhf9qBR7QASjHjFQ 83 | 2N+VF2PfH8dm5prZIpz/MFKPkBW4Yuss0OXiD+jQt1J2JUKspLqsIqoXjHQQGjL7 84 | 3wIDAQAB 85 | -----END PUBLIC KEY----- 86 | ``` 87 | 88 | RSA (2048 bits) 签名例子:: 89 | 90 | ``` 91 | wS6q6h77AvH1TqwInoTDdWIIubRCiUP4RLG++GI24twL3BMtX0EEV+YT1eH8Hb8bLe0Rb9OhOHbt1CC3aurzoCTgZvhNek47mg+Bpu8fwQ7eRkXEiWBx5C8BNN73JwnnkZw4UzYvqiwAs162jToV8AL0eN043KJ3MEKCy3C6nyeYOFSg+1Cp637KtAZk3z7aHknSu7/PXSPuwMIpBgFctf8YKGZFAVRbgwlcgUDhXyaGts6OFePGy0jkZKJHawb/w5hoatatsfVmVC4hZ8fsfystQ9k5DNjTm7ROApWaXy9BsfAYcj13O424mqlpkKG4EGnIjOIWB/pRDDQEm2O/xg== 92 | ``` 93 | -------------------------------------------------------------------------------- /faqs/commission_faq.md: -------------------------------------------------------------------------------- 1 | # Commission Rates 2 | 3 | **Disclaimer:** 4 | 5 | * The commissions and prices used here are fictional, and do not imply anything about the actual setup on the live exchange. 6 | * This applies only for the SPOT Exchange. 7 | 8 | ## What are Commission Rates? 9 | 10 | These are the rates that determine the commission to be paid on trades when your order fills for any amount. 11 | 12 | ## What are the different types of rates? 13 | 14 | There are 3 types: 15 | 16 | * `standardCommission` - Standard commission rates on trades from the order. 17 | * `taxCommission` - Tax commission rates on trades from the order. 18 | * `discount` - Discount rate on standard commission if paying the commission with BNB. 19 | 20 | ## How do I know what the commission rates are? 21 | 22 | You can find them using the following requests: 23 | 24 | REST API: `GET /api/v3/account/commission` 25 | 26 | WebSocket API: `account.commission` 27 | 28 | You can also find out the commission rates to a trade from an order using the test order requests with `computeCommissionRates`. 29 | 30 | ## What is the difference between the response sending a test order with `computeCommissionRates` vs the response from querying commission rates? 31 | 32 | This is an example of the former: 33 | 34 | ```json 35 | { 36 | "standardCommissionForOrder": { 37 | "maker": "0.00000050", 38 | "taker": "0.00000060" 39 | }, 40 | "taxCommissionForOrder": { 41 | "maker": "0.00000228", 42 | "taker": "0.00000230" 43 | }, 44 | "discount": { 45 | "enabledForAccount": true, 46 | "enabledForSymbol": true, 47 | "discountAsset": "BNB", 48 | "discount": "0.25000000" 49 | } 50 | } 51 | ``` 52 | 53 | When using the order test request using `computeCommissionRates`, the `standardCommissionForOrder` and `taxCommissionForOrder` shows the actual commission rate for trades from that order. Both `maker` and `taker` rates are returned regardless of the order parameters. 54 | 55 | The response for query commission rates gives the current commission rate for that symbol for your account. 56 | 57 | ## How is the commission calculated? 58 | 59 | Using an example commission configuration: 60 | 61 | ```json 62 | { 63 | "symbol": "BTCUSDT", 64 | "standardCommission": { 65 | "maker": "0.00000010", 66 | "taker": "0.00000020", 67 | "buyer": "0.00000030", 68 | "seller": "0.00000040" 69 | }, 70 | "taxCommission": { 71 | "maker": "0.00000112", 72 | "taker": "0.00000114", 73 | "buyer": "0.00000118", 74 | "seller": "0.00000116" 75 | }, 76 | "discount": { 77 | "enabledForAccount": true, 78 | "enabledForSymbol": true, 79 | "discountAsset": "BNB", 80 | "discount": "0.25000000" 81 | } 82 | } 83 | ``` 84 | 85 | If you placed an order with the following parameters which took immediately and fully filled in a single trade: 86 | 87 | |Parameter| Value| 88 | |--- | --- | 89 | |symbol |BTCUSDT| 90 | |price |35,000| 91 | |quantity |0.49975| 92 | |side |SELL | 93 | |type |MARKET | 94 | 95 | Since you sold BTC for USDT, the commission will be paid either in USDT or BNB. 96 | 97 | When standard commission is calculated, the received amount is multiplied with the sum of the rates. 98 | 99 | Since this order is on the `SELL` side, the received amount is the notional value. (For orders on the `BUY` side, the received amount would be `quantity`.) 100 | The order type was `MARKET`, making this the taker order for the trade. 101 | 102 | ``` 103 | Standard Commission = Notional value * (taker + seller) 104 | = (35000 * 0.49975) * (0.00000020 + 0.00000040) 105 | = 17491.25000000 * 0.00000060 106 | = 0.01049475 USDT 107 | ``` 108 | 109 | Tax commission (if applicable) is calculated similarly: 110 | 111 | ``` 112 | Tax commission = Notional value * (taker + seller) 113 | = (35000 * 0.49975) * (0.00000114 + 0.00000116) 114 | = 17491.25000000 * 0.00000230 115 | = 0.04022988 USDT 116 | ``` 117 | 118 | If not paying in BNB, the total commission are summed up and deducted from your received amount of `USDT`. 119 | 120 | Since `enabledforAccount` and `enabledForSymbol` under `discount` is set to `true`, this means the commission will be paid in BNB assuming you have a sufficient balance. 121 | 122 | If paying with BNB, then the standard commission will be reduced based on the `discount`. 123 | 124 | First the standard commission and tax commission will be converted into BNB based on the exchange rate. For this example, assume that 1 BNB = 260 USDT. 125 | 126 | ``` 127 | Standard commission (Discounted and in BNB) = (Standard commission * BNB exchange rate) * discount 128 | = (0.01049475 * 1/260) * 0.25 129 | = 0.000040364 * 0.25 130 | = 0.000010091 131 | ``` 132 | 133 | Note that the discount **does not apply to tax commissions**. 134 | 135 | ``` 136 | Tax Commission (in BNB) = Tax commission * BNB exchange rate 137 | = 0.04022988 * (1/260) 138 | = 0.00015473 139 | ``` 140 | 141 | ``` 142 | Total Commission (in BNB) = Standard commission (Discounted) + Tax commission (in BNB) 143 | = 0.000010091 + 0.00015473 144 | = 0.00016482 145 | ``` 146 | 147 | If you do not have enough BNB to pay the discounted commission, the full commission will be taken out of your received amount of USDT instead. 148 | 149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /faqs/commission_faq_CN.md: -------------------------------------------------------------------------------- 1 | # 佣金率 2 | 3 | **免责声明:** 4 | 5 | * 本文所用的佣金和价格都是虚构的,并不代表现实交易中的设置。 6 | * 本内容只适用于现货交易所。 7 | 8 | ## 什么是佣金率? 9 | 10 | 这些比率是用来决定当您的任何金额订单成交后,您所需要支付的佣金金额数目。 11 | 12 | ## 佣金率有哪些不同的类型? 13 | 14 | 有以下3种类型: 15 | 16 | * 标准佣金(`standardCommission`) - 来自订单的标准交易佣金率。 17 | * 税务佣金(`taxCommission`) - 来自订单的税费佣金率。 18 | * 折扣(`discount`) - 如果使用`BNB`支付佣金,在标准佣金基础上可以得到的折扣率。 19 | 20 | ## 我怎么才能知道佣金率是多少? 21 | 22 | 您可以通过以下请求找到它们: 23 | 24 | REST API: `GET /api/v3/account/commission` 25 | 26 | WebSocket API: `account.commission` 27 | 28 | 您也可以通过在测试订单请求中使用 `computeCommissionRates` 来找出订单交易的佣金比率。 29 | 30 | ## 在发送测试订单中使用`computeCommissionRates`得到的响应与查询佣金率的响应之间有什么不同? 31 | 32 | 以下是有关前者的一个例子: 33 | 34 | 35 | ```json 36 | { 37 | "standardCommissionForOrder": { 38 | "maker": "0.00000050", 39 | "taker": "0.00000060" 40 | }, 41 | "taxCommissionForOrder": { 42 | "maker": "0.00000228", 43 | "taker": "0.00000230" 44 | }, 45 | "discount": { 46 | "enabledForAccount": true, 47 | "enabledForSymbol": true, 48 | "discountAsset": "BNB", 49 | "discount": "0.25000000" 50 | } 51 | } 52 | ``` 53 | 54 | 当使用带有`computeCommissionRates`的订单测试请求时,`standardCommissionForOrder` 和 `taxCommissionForOrder` 显示了该订单交易的实际佣金率。无论订单参数如何设置,响应均会返回`maker`和`taker`的费率。 55 | 56 | 而查询佣金率的响应则提供了针对于您的帐户中该交易对的当前佣金率。 57 | 58 | 59 | ## 佣金是怎么计算的? 60 | 61 | 以下面的这个佣金配置为例: 62 | 63 | ```json 64 | { 65 | "symbol": "BTCUSDT", 66 | "standardCommission": { 67 | "maker": "0.00000010", 68 | "taker": "0.00000020", 69 | "buyer": "0.00000030", 70 | "seller": "0.00000040" 71 | }, 72 | "taxCommission": { 73 | "maker": "0.00000112", 74 | "taker": "0.00000114", 75 | "buyer": "0.00000118", 76 | "seller": "0.00000116" 77 | }, 78 | "discount": { 79 | "enabledForAccount": true, 80 | "enabledForSymbol": true, 81 | "discountAsset": "BNB", 82 | "discount": "0.25000000" 83 | } 84 | } 85 | ``` 86 | 87 | 如果您使用了下列参数来下一个订单,该订单立即执行并通过一次交易就全部成交: 88 | 89 | |参数 | 取值 | 90 | |--- | --- | 91 | |symbol |BTCUSDT| 92 | |price |35,000| 93 | |quantity |0.49975| 94 | |side |SELL | 95 | |type |MARKET | 96 | 97 | 由于您卖出了 `BTC` 来换取 `USDT` ,佣金将以 `USDT` 或 `BNB` 形式支付。 98 | 99 | 在计算标准佣金(`standard commission`)时,所接收的金额会与费率之和相乘。 100 | 101 | 由于此订单在`卖方` (`SELL`)一侧,所接收的金额是`名义价值` (`notional value`)。 对于`买方` (`BUY`)一侧的订单,所接收的金额则是`数量` (`quantity`)。 102 | 因为订单类型为`市价` (`MARKET`)的关系,使得此订单成为交易的`吃单方` (`taker`)。 103 | 104 | ``` 105 | 标准佣金 = 名义价值 * (taker + seller) 106 | = (35000 * 0.49975) * (0.00000020 + 0.00000040) 107 | = 17491.25000000 * 0.00000060 108 | = 0.01049475 USDT 109 | ``` 110 | 111 | 如果适用,税务佣金(`tax commission`)的计算方式类似于标准佣金: 112 | 113 | ``` 114 | 税务佣金 = 名义价值 * (taker + seller) 115 | = (35000 * 0.49975) * (0.00000114 + 0.00000116) 116 | = 17491.25000000 * 0.00000230 117 | = 0.04022988 USDT 118 | ``` 119 | 120 | 如果您不使用`BNB`支付佣金,佣金总数会被加起来并从您所接收的`USDT`金额中扣除。 121 | 122 | 由于`discount`下的`enabledforAccount`和`enabledForSymbol`被设置为`true`,这意味着如果您所持有的余额足够,那么佣金将用`BNB`支付。 123 | 124 | 如果用`BNB`支付,那么基于折扣(`discount`),您所需要支付的标准佣金将会减少。 125 | 126 | 首先,标准佣金和税务佣金将根据汇率转换成`BNB`。在这个例子中,假设1 BNB = 260 USDT。 127 | 128 | ``` 129 | 标准佣金(打折后以BNB支付) = (标准佣金 * BNB 汇率) * 折扣 130 | = (0.01049475 * 1/260) * 0.25 131 | = 0.000040364 * 0.25 132 | = 0.000010091 133 | ``` 134 | 135 | 请注意,折扣(`discount`)**不适用于税务佣金(`税务佣金`)**。 136 | 137 | ``` 138 | 税务佣金 (以BNB支付) = 税务佣金 * BNB 汇率 139 | = 0.04022988 * (1/260) 140 | = 0.00015473 141 | ``` 142 | 143 | ``` 144 | 佣金总数 (以BNB支付) = 标准佣金(打折后) + 税务佣金 (以BNB支付) 145 | = 0.000010091 + 0.00015473 146 | = 0.00016482 147 | ``` 148 | 149 | 如果您的`BNB`余额不足以支付折扣后的佣金,那么全部佣金将从您所接收的`USDT`金额中扣除。 150 | 151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /faqs/market_data_only.md: -------------------------------------------------------------------------------- 1 | # Market Data Only URLs 2 | 3 | These URLs do not require any authentication (i.e. The API key is not necessary) and serve only public market data. 4 | 5 | ## RESTful API 6 | 7 | On the RESTful API, these are the endpoints you can request on `data-api.binance.vision`: 8 | 9 | * [GET /api/v3/aggTrades](../rest-api.md#compressedaggregate-trades-list) 10 | * [GET /api/v3/avgPrice](../rest-api.md#current-average-price) 11 | * [GET /api/v3/depth](../rest-api.md#order-book) 12 | * [GET /api/v3/exchangeInfo](../rest-api.md#exchange-information) 13 | * [GET /api/v3/klines](../rest-api.md#klines) 14 | * [GET /api/v3/ping](../rest-api.md#ping) 15 | * [GET /api/v3/ticker](../rest-api.md#rolling-window-price-change-statistics) 16 | * [GET /api/v3/ticker/24hr](../rest-api.md#24hr-ticker-price-change-statistics) 17 | * [GET /api/v3/ticker/bookTicker](../rest-api.md#symbol-order-book-ticker) 18 | * [GET /api/v3/ticker/price](../rest-api.md#symbol-price-ticker) 19 | * [GET /api/v3/time](../rest-api.md#time) 20 | * [GET /api/v3/trades](../rest-api.md#recent-trades-list) 21 | * [GET /api/v3/uiKlines](../rest-api.md#uiKlines) 22 | 23 | Sample request: 24 | 25 | ``` 26 | curl -sX GET "https://data-api.binance.vision/api/v3/exchangeInfo?symbol=BTCUSDT" 27 | ``` 28 | 29 | ## Websocket Streams 30 | 31 | Public market data can also be retrieved through the websocket market data using the URL `data-stream.binance.vision`. 32 | The streams available through this domain are the same that can be found in the [Websocket Market Streams](../web-socket-streams.md) documentation. 33 | 34 | Note that User Data Streams **cannot** be accessed through this URL. 35 | 36 | Sample request: 37 | 38 | ``` 39 | wss://data-stream.binance.vision:443/ws/btcusdt@kline_1m 40 | ``` 41 | 42 | 43 | -------------------------------------------------------------------------------- /faqs/market_data_only_CN.md: -------------------------------------------------------------------------------- 1 | # 仅提供市场数据的URL 2 | 3 | 这些 URL 不需要任何身份验证(即不需要 API Key)并且仅提供公开市场数据。 4 | 5 | ## RESTful API 6 | 7 | 在 RESTful API 上,您可以在 `data-api.binance.vision` 上访问以下接口: 8 | 9 | * [GET /api/v3/aggTrades](../rest-api_CN.md#aggTrades) 10 | * [GET /api/v3/avgPrice](../rest-api_CN.md#avgPrice) 11 | * [GET /api/v3/depth](../rest-api_CN.md#depth) 12 | * [GET /api/v3/exchangeInfo](../rest-api_CN.md#exchangeInfo) 13 | * [GET /api/v3/klines](../rest-api_CN.md#klines) 14 | * [GET /api/v3/ping](../rest-api_CN.md#ping) 15 | * [GET /api/v3/ticker](../rest-api_CN.md#rollingwindowticker) 16 | * [GET /api/v3/ticker/24hr](../rest-api_CN.md#twentyfourhourticker) 17 | * [GET /api/v3/ticker/bookTicker](../rest-api_CN.md#bookTicker) 18 | * [GET /api/v3/ticker/price](../rest-api_CN.md#ticker-price) 19 | * [GET /api/v3/time](../rest-api_CN.md#time) 20 | * [GET /api/v3/trades](../rest-api_CN.md#trades) 21 | * [GET /api/v3/uiKlines](../rest-api_CN.md#uiKlines) 22 | 23 | 请求示例: 24 | 25 | ``` 26 | curl -sX GET "https://data-api.binance.vision/api/v3/exchangeInfo?symbol=BTCUSDT" 27 | ``` 28 | 29 | ## Websocket Streams 30 | 31 | 也可以通过 Websocket 市场数据的 URL `data-stream.binance.vision` 提取公共市场数据。 32 | 此域名所提供的 stream 与 [Websocket Market Streams_CN](../web-socket-streams_CN.md) 文档中的相同。 33 | 请注意账户信息推送**无法**从此 URL 获得。 34 | 35 | 请求示例: 36 | 37 | ``` 38 | wss://data-stream.binance.vision:443/ws/btcusdt@kline_1m 39 | ``` 40 | 41 | -------------------------------------------------------------------------------- /faqs/market_orders_faq.md: -------------------------------------------------------------------------------- 1 | # MARKET orders 2 | 3 | **Disclaimer:** 4 | 5 | * The commissions and prices used here are fictional and do not reflect the actual setup on the live exchange. 6 | * The explanation pertains to the behavior on the Spot Exchange. 7 | 8 | `MARKET` orders allow users to buy or sell an asset at the best available prices and liquidity until the order is fully filled or the order book's liquidity is exhausted. 9 | 10 | If you do not have sufficient balance for the order to be completely filled, the order will be rejected. 11 | 12 | If the exchange does not have enough liquidity to fill the order, your `MARKET` order will be partially filled to the extent of available liquidity, and the remaining quantity will expire. 13 | 14 | If the order expires due to insufficient liquidity, the `status` field of the API response will be `EXPIRED`. 15 | 16 | Additionally, if you monitor the User Data Stream, in the payload `ExecutionReport`, you will see that both the Execution Type (`x`) and Order Status (`X`) are marked as `EXPIRED`. 17 | 18 | Please refer to the sample payload below. 19 | 20 | **Sample API Response:** 21 | 22 | ```json 23 | { 24 | "symbol": "LTCBNB", 25 | "orderId": 32, 26 | "orderListId": -1, 27 | "clientOrderId": "8LGC97RRgNPVQk979VIhjt", 28 | "transactTime": 1719467634105, 29 | "price": "0.00000000", 30 | "origQty": "6.00000000", 31 | "executedQty": "4.00000000", 32 | "cummulativeQuoteQty": "4.00000000", 33 | "status": "EXPIRED", 34 | "timeInForce": "GTC", 35 | "type": "MARKET", 36 | "side": "BUY", 37 | "workingTime": 1719467634105, 38 | "fills": [ 39 | { 40 | "price": "1.00000000", 41 | "qty": "2.00000000", 42 | "commission": "0.00100000", 43 | "commissionAsset": "BNB", 44 | "tradeId": 7 45 | }, 46 | { 47 | "price": "1.00000000", 48 | "qty": "2.00000000", 49 | "commission": "0.00100000", 50 | "commissionAsset": "BNB", 51 | "tradeId": 8 52 | } 53 | ], 54 | "selfTradePreventionMode": "NONE" 55 | } 56 | ``` 57 | 58 | **Sample User Data Stream Payload:** 59 | 60 | ```json 61 | { 62 | "e": "executionReport", 63 | "E": 1719467634107, 64 | "s": "LTCBNB", 65 | "c": "8LGC97RRgNPVQk979VIhjt", 66 | "S": "BUY", 67 | "o": "MARKET", 68 | "f": "GTC", 69 | "q": "6.00000000", 70 | "p": "0.00000000", 71 | "P": "0.00000000", 72 | "F": "0.00000000", 73 | "g": -1, 74 | "C": "", 75 | "x": "NEW", 76 | "X": "NEW", 77 | "r": "NONE", 78 | "i": 32, 79 | "l": "0.00000000", 80 | "z": "0.00000000", 81 | "L": "0.00000000", 82 | "n": "0", 83 | "N": null, 84 | "T": 1719467634105, 85 | "t": -1, 86 | "I": 62, 87 | "w": true, 88 | "m": false, 89 | "M": false, 90 | "O": 1719467634105, 91 | "Z": "0.00000000", 92 | "Y": "0.00000000", 93 | "Q": "0.00000000", 94 | "W": 1719467634105, 95 | "V": "NONE" 96 | } 97 | { 98 | "e": "executionReport", 99 | "E": 1719467634107, 100 | "s": "LTCBNB", 101 | "c": "8LGC97RRgNPVQk979VIhjt", 102 | "S": "BUY", 103 | "o": "MARKET", 104 | "f": "GTC", 105 | "q": "6.00000000", 106 | "p": "0.00000000", 107 | "P": "0.00000000", 108 | "F": "0.00000000", 109 | "g": -1, 110 | "C": "", 111 | "x": "TRADE", 112 | "X": "PARTIALLY_FILLED", 113 | "r": "NONE", 114 | "i": 32, 115 | "l": "2.00000000", 116 | "z": "2.00000000", 117 | "L": "1.00000000", 118 | "n": "0.00100000", 119 | "N": "BNB", 120 | "T": 1719467634105, 121 | "t": 7, 122 | "I": 63, 123 | "w": false, 124 | "m": false, 125 | "M": true, 126 | "O": 1719467634105, 127 | "Z": "2.00000000", 128 | "Y": "2.00000000", 129 | "Q": "0.00000000", 130 | "W": 1719467634105, 131 | "V": "NONE" 132 | } 133 | { 134 | "e": "executionReport", 135 | "E": 1719467634107, 136 | "s": "LTCBNB", 137 | "c": "8LGC97RRgNPVQk979VIhjt", 138 | "S": "BUY", 139 | "o": "MARKET", 140 | "f": "GTC", 141 | "q": "6.00000000", 142 | "p": "0.00000000", 143 | "P": "0.00000000", 144 | "F": "0.00000000", 145 | "g": -1, 146 | "C": "", 147 | "x": "TRADE", 148 | "X": "PARTIALLY_FILLED", 149 | "r": "NONE", 150 | "i": 32, 151 | "l": "2.00000000", 152 | "z": "4.00000000", 153 | "L": "1.00000000", 154 | "n": "0.00100000", 155 | "N": "BNB", 156 | "T": 1719467634105, 157 | "t": 8, 158 | "I": 65, 159 | "w": false, 160 | "m": false, 161 | "M": true, 162 | "O": 1719467634105, 163 | "Z": "4.00000000", 164 | "Y": "2.00000000", 165 | "Q": "0.00000000", 166 | "W": 1719467634105, 167 | "V": "NONE" 168 | } 169 | { 170 | "e": "executionReport", 171 | "E": 1719467634107, 172 | "s": "LTCBNB", 173 | "c": "8LGC97RRgNPVQk979VIhjt", 174 | "S": "BUY", 175 | "o": "MARKET", 176 | "f": "GTC", 177 | "q": "6.00000000", 178 | "p": "0.00000000", 179 | "P": "0.00000000", 180 | "F": "0.00000000", 181 | "g": -1, 182 | "C": "", 183 | "x": "EXPIRED", 184 | "X": "EXPIRED", 185 | "r": "NONE", 186 | "i": 32, 187 | "l": "0.00000000", 188 | "z": "4.00000000", 189 | "L": "0.00000000", 190 | "n": "0", 191 | "N": null, 192 | "T": 1719467634105, 193 | "t": -1, 194 | "I": 67, 195 | "w": false, 196 | "m": false, 197 | "M": false, 198 | "O": 1719467634105, 199 | "Z": "4.00000000", 200 | "Y": "0.00000000", 201 | "Q": "0.00000000", 202 | "W": 1719467634105, 203 | "V": "NONE" 204 | } 205 | { 206 | "e": "outboundAccountPosition", 207 | "E": 1719467634107, 208 | "u": 1719467634105, 209 | "B": 210 | [ 211 | { 212 | "a": "LTC", 213 | "f": "3011.11745670", 214 | "l": "0.00000000" 215 | }, 216 | { 217 | "a": "BNB", 218 | "f": "996.11865670", 219 | "l": "0.00000000" 220 | } 221 | ] 222 | } 223 | ``` 224 | -------------------------------------------------------------------------------- /faqs/market_orders_faq_CN.md: -------------------------------------------------------------------------------- 1 | # 市价单 2 | 3 | **免责声明:** 4 | 5 | * 此处使用的佣金和价格是虚构的,并不反映实际交易所的设置。 6 | * 解释是针对现货交易所的行为。 7 | 8 | `MARKET` 订单允许用户以最佳可用价格和流动性买入或卖出资产,直到订单全部成交或订单簿的流动性耗尽。 9 | 10 | 如果您的余额不足以完全填充订单,订单将被拒绝。 11 | 12 | 如果交易所没有足够的流动性来填充订单,您的 `MARKET` 订单将会部分填充到可用流动性的程度,剩余的数量将会过期。 13 | 14 | 如果由于流动性不足订单过期,API 响应的 `status` 字段将显示为 `EXPIRED`。 15 | 16 | 此外,如果您监听用户数据流,在 payload `ExecutionReport` 中,您会看到执行类型 (`x`) 和订单状态 (`X`) 都标记为 `EXPIRED`。 17 | 18 | 请参阅下面的示例 payload。 19 | 20 | **示例 API 响应:** 21 | 22 | ```json 23 | { 24 | "symbol": "LTCBNB", 25 | "orderId": 32, 26 | "orderListId": -1, 27 | "clientOrderId": "8LGC97RRgNPVQk979VIhjt", 28 | "transactTime": 1719467634105, 29 | "price": "0.00000000", 30 | "origQty": "6.00000000", 31 | "executedQty": "4.00000000", 32 | "cummulativeQuoteQty": "4.00000000", 33 | "status": "EXPIRED", 34 | "timeInForce": "GTC", 35 | "type": "MARKET", 36 | "side": "BUY", 37 | "workingTime": 1719467634105, 38 | "fills": [ 39 | { 40 | "price": "1.00000000", 41 | "qty": "2.00000000", 42 | "commission": "0.00100000", 43 | "commissionAsset": "BNB", 44 | "tradeId": 7 45 | }, 46 | { 47 | "price": "1.00000000", 48 | "qty": "2.00000000", 49 | "commission": "0.00100000", 50 | "commissionAsset": "BNB", 51 | "tradeId": 8 52 | } 53 | ], 54 | "selfTradePreventionMode": "NONE" 55 | } 56 | ``` 57 | 58 | **示例用户数据流 Payload:** 59 | 60 | ```json 61 | { 62 | "e": "executionReport", 63 | "E": 1719467634107, 64 | "s": "LTCBNB", 65 | "c": "8LGC97RRgNPVQk979VIhjt", 66 | "S": "BUY", 67 | "o": "MARKET", 68 | "f": "GTC", 69 | "q": "6.00000000", 70 | "p": "0.00000000", 71 | "P": "0.00000000", 72 | "F": "0.00000000", 73 | "g": -1, 74 | "C": "", 75 | "x": "NEW", 76 | "X": "NEW", 77 | "r": "NONE", 78 | "i": 32, 79 | "l": "0.00000000", 80 | "z": "0.00000000", 81 | "L": "0.00000000", 82 | "n": "0", 83 | "N": null, 84 | "T": 1719467634105, 85 | "t": -1, 86 | "I": 62, 87 | "w": true, 88 | "m": false, 89 | "M": false, 90 | "O": 1719467634105, 91 | "Z": "0.00000000", 92 | "Y": "0.00000000", 93 | "Q": "0.00000000", 94 | "W": 1719467634105, 95 | "V": "NONE" 96 | } 97 | { 98 | "e": "executionReport", 99 | "E": 1719467634107, 100 | "s": "LTCBNB", 101 | "c": "8LGC97RRgNPVQk979VIhjt", 102 | "S": "BUY", 103 | "o": "MARKET", 104 | "f": "GTC", 105 | "q": "6.00000000", 106 | "p": "0.00000000", 107 | "P": "0.00000000", 108 | "F": "0.00000000", 109 | "g": -1, 110 | "C": "", 111 | "x": "TRADE", 112 | "X": "PARTIALLY_FILLED", 113 | "r": "NONE", 114 | "i": 32, 115 | "l": "2.00000000", 116 | "z": "2.00000000", 117 | "L": "1.00000000", 118 | "n": "0.00100000", 119 | "N": "BNB", 120 | "T": 1719467634105, 121 | "t": 7, 122 | "I": 63, 123 | "w": false, 124 | "m": false, 125 | "M": true, 126 | "O": 1719467634105, 127 | "Z": "2.00000000", 128 | "Y": "2.00000000", 129 | "Q": "0.00000000", 130 | "W": 1719467634105, 131 | "V": "NONE" 132 | } 133 | { 134 | "e": "executionReport", 135 | "E": 1719467634107, 136 | "s": "LTCBNB", 137 | "c": "8LGC97RRgNPVQk979VIhjt", 138 | "S": "BUY", 139 | "o": "MARKET", 140 | "f": "GTC", 141 | "q": "6.00000000", 142 | "p": "0.00000000", 143 | "P": "0.00000000", 144 | "F": "0.00000000", 145 | "g": -1, 146 | "C": "", 147 | "x": "TRADE", 148 | "X": "PARTIALLY_FILLED", 149 | "r": "NONE", 150 | "i": 32, 151 | "l": "2.00000000", 152 | "z": "4.00000000", 153 | "L": "1.00000000", 154 | "n": "0.00100000", 155 | "N": "BNB", 156 | "T": 1719467634105, 157 | "t": 8, 158 | "I": 65, 159 | "w": false, 160 | "m": false, 161 | "M": true, 162 | "O": 1719467634105, 163 | "Z": "4.00000000", 164 | "Y": "2.00000000", 165 | "Q": "0.00000000", 166 | "W": 1719467634105, 167 | "V": "NONE" 168 | } 169 | { 170 | "e": "executionReport", 171 | "E": 1719467634107, 172 | "s": "LTCBNB", 173 | "c": "8LGC97RRgNPVQk979VIhjt", 174 | "S": "BUY", 175 | "o": "MARKET", 176 | "f": "GTC", 177 | "q": "6.00000000", 178 | "p": "0.00000000", 179 | "P": "0.00000000", 180 | "F": "0.00000000", 181 | "g": -1, 182 | "C": "", 183 | "x": "EXPIRED", 184 | "X": "EXPIRED", 185 | "r": "NONE", 186 | "i": 32, 187 | "l": "0.00000000", 188 | "z": "4.00000000", 189 | "L": "0.00000000", 190 | "n": "0", 191 | "N": null, 192 | "T": 1719467634105, 193 | "t": -1, 194 | "I": 67, 195 | "w": false, 196 | "m": false, 197 | "M": false, 198 | "O": 1719467634105, 199 | "Z": "4.00000000", 200 | "Y": "0.00000000", 201 | "Q": "0.00000000", 202 | "W": 1719467634105, 203 | "V": "NONE" 204 | } 205 | { 206 | "e": "outboundAccountPosition", 207 | "E": 1719467634107, 208 | "u": 1719467634105, 209 | "B": 210 | [ 211 | { 212 | "a": "LTC", 213 | "f": "3011.11745670", 214 | "l": "0.00000000" 215 | }, 216 | { 217 | "a": "BNB", 218 | "f": "996.11865670", 219 | "l": "0.00000000" 220 | } 221 | ] 222 | } 223 | ``` -------------------------------------------------------------------------------- /faqs/order_amend_keep_priority.md: -------------------------------------------------------------------------------- 1 | # Order Amend Keep Priority 2 | 3 | **Disclaimer**: 4 | 5 | * The symbols and values used here are fictional and do not imply anything about the actual setup on the live exchange. 6 | * For simplicity, the examples in this document do not include commission. 7 | 8 | ## What is Order Amend Keep Priority? 9 | 10 | Order Amend Keep Priority request is used to modify (amend) an existing order **without losing order book priority**. 11 | 12 | The following order modifications are allowed: 13 | 14 | * reduce the quantity of the order 15 | 16 | ## How can I amend the quantity of my order? 17 | 18 | Use the following requests: 19 | 20 | | API | Request | 21 | | :---- | :---- | 22 | | REST API | `PUT /api/v3/order/amend/keepPriority` | 23 | | WebSocket API | `order.amend.keepPriority` | 24 | | FIX API | OrderAmendKeepPriorityRequest `` | 25 | 26 | ## What is the difference between "Cancel an Existing Order and Send a New Order" (cancel-replace) and "Order Amend Keep Priority"? 27 | 28 | **Cancel an Existing Order and Send a New Order** request cancels the old order and places a new order.
Time priority is lost. The new order executes after existing orders at the same price. 29 | 30 | **Order Amend Keep Priority** request modifies an existing order in-place.
The amended order keeps its time priority among existing orders at the same price. 31 | 32 | For example, consider the following order book: 33 | 34 | | User | Order ID | Side | Order price | quantity | 35 | | :---- | ----: | :---- | ----: | ----: | 36 | | User A | 10 | BUY | 87,000 | 1.00 | 37 | | ⭐️ YOU | 15 | BUY | 87,000 | 5.50 | 38 | | User B | 20 | BUY | 87,000 | 4.00 | 39 | | User C | 21 | BUY | 86,999 | 2.00 | 40 | 41 | Your order 15 is the second one in the queue based on price and time. 42 | 43 | You want to reduce the quantity from 5.50 down to 5.00. 44 | 45 | If you use **cancel-replace** to cancel `orderId=15` and place a new order with `qty=5.00`, the order book will look like this: 46 | 47 | | User | Order ID | Side | Order price | quantity | 48 | | :---- | ----: | :---- | ----: | ----: | 49 | | User A | 10 | BUY | 87,000 | 1.00 | 50 | | ~~⭐️ YOU~~ | ~~11~~ | ~~BUY~~ | ~~87,000~~ | ~~5.50~~ | 51 | | User B | 20 | BUY | 87,000 | 4.00 | 52 | | ⭐️ YOU | (new) 22 | BUY | 87,000 | 5.00 | 53 | | User C | 21 | BUY | 86,999 | 2.00 | 54 | 55 | Note that the new order gets a new order ID and you lose time priority: order 22 will trade after the order 20\. 56 | 57 | If instead you use **Order Amend Keep Priority** to reduce the quantity of `orderId=15` down to `qty=5.00`, the order book will look like this: 58 | 59 | | User | Order ID | Side | Order price | quantity | 60 | | :---- | ----: | :---- | ----: | ----: | 61 | | User A | 10 | BUY | 87,000 | 1.00 | 62 | | ⭐️ YOU | 15 | BUY | 87,000 | (amended) **5.00** | 63 | | User B | 20 | BUY | 87,000 | 4.00 | 64 | | User C | 21 | BUY | 86,999 | 2.00 | 65 | 66 | Note that the order ID stays the same and the order keeps its priority in the queue. Only the quantity of the order changes. 67 | 68 | ## Does Order Amend Keep Priority affect unfilled order count (rate limits)? 69 | 70 | Currently, Order Amend Keep Priority requests charge 0 for unfilled order count. 71 | 72 | ## How do I know if my order has been amended? 73 | 74 | If the order was amended successfully, the API response contains your order with the updated quantity. 75 | 76 | On User Data Stream, you will receive an `"executionReport"` event with execution type `"x": "REPLACED"`. 77 | 78 | If the amended order belongs to an order list and the client order ID has changed, you will also receive a "listStatus" event with list status type `"l": "UPDATED"`. 79 | 80 | You can also use the following requests to query order modification history: 81 | 82 | | API | Request | 83 | | :---- | :---- | 84 | | REST API | `GET /api/v3/order/amendments` | 85 | | WebSocket API | `order.amendments` | 86 | 87 | ## What happens if my amend request does not succeed? 88 | 89 | If the request fails for any reason (e.g. fails the filters, permissions, account restrictions, etc), then the order amend request is rejected and the order remains unchanged. 90 | 91 | ## Is it possible to reuse the current clientOrderId for my amended order? 92 | 93 | Yes. 94 | 95 | By default, amended orders get a random new client order ID, but you can pass the current client order ID in the `newClientOrderId` parameter if you wish to keep it. 96 | 97 | ## Can Iceberg Orders be amended? 98 | 99 | Yes. 100 | 101 | Note that an iceberg order's visible quantity will only change if `newQty` is below the pre-amended visible quantity. 102 | 103 | ## Can Order lists be amended? 104 | 105 | Orders in an order list can be amended. 106 | 107 | Note that OCO order pairs must have the same quantity, since only one of the orders can ever be executed. This means that amending either order affects both orders. 108 | 109 | For OTO orders, the working and pending orders can be amended individually. 110 | 111 | ## Which symbols allow Order Amend Keep Priority? 112 | 113 | This information is available in Exchange Information. 114 | Symbols that allow Order Amend Keep Priority requests have `amendAllowed` set to `true`. 115 | -------------------------------------------------------------------------------- /faqs/order_amend_keep_priority_CN.md: -------------------------------------------------------------------------------- 1 | # 保留优先级的修改订单请求(Order Amend Keep Priority) 常见问题 2 | 3 | **免责声明:** 4 | 5 | * 此处使用的交易对和价格是虚构的,并不反映实际交易所的设置。 6 | * 为了简化过程,本文档中的示例不包括佣金。 7 | 8 | ## 什么是 Order Amend Keep Priority? 9 | 10 | 保留优先级的修改订单请求(Order Amend Keep Priority)用于修改(修正)现有订单并 **不失去在订单簿上的优先级**。 11 | 12 | 允许进行以下订单修改: 13 | 14 | * 减少现有订单的原始数量。 15 | 16 | ## 我该如何修改我的订单数量? 17 | 18 | 使用以下请求: 19 | 20 | | API | 请求 | 21 | | :---- | :---- | 22 | | REST API | `PUT /api/v3/order/amend/keepPriority` | 23 | | WebSocket API | `order.amend.keepPriority` | 24 | | FIX API | OrderAmendKeepPriorityRequest `` | 25 | 26 | ## “撤消挂单再下单”(cancel-replace)和”保留优先级的修改订单请求“之间的区别? 27 | 28 | **撤消挂单再下单请求** 撤消挂单并重新下单。
在时间上的优先级会被丢失。 新订单在相同价格的现有订单之后执行。 29 | 30 | **留优先级的修改订单请求** 就地修改现有订单。
修改后的订单在相同价格的现有订单中保持其时间优先级。 31 | 32 | 比如,拿下面的订单簿为例: 33 | 34 | | 用户| 订单 ID | 订单方向 | 订单价格 | 数量 | 35 | | :---- | ----: | :---- | ----: | ----: | 36 | | 用户 A | 10 | BUY | 87,000 | 1.00 | 37 | | ⭐️ 你 | 15 | BUY | 87,000 | 5.50 | 38 | | 用户 B | 20 | BUY | 87,000 | 4.00 | 39 | | 用户 C | 21 | BUY | 86,999 | 2.00 | 40 | 41 | 您的订单 15 是根据价格和时间排在队列中的第二个订单。 42 | 43 | 您想将数量从 5.50 减少.50 降至 5.00。 44 | 45 | 如果您使用 **cancel-replace** 取消 `orderId=15` 并使用 `qty=5.00` 来下新订单, 订单簿将如下所示: 46 | 47 | | 用户| 订单 ID | 订单方向 | 订单价格 | 数量 | 48 | | :---- | ----: | :---- | ----: | ----: | 49 | | 用户 A | 10 | BUY | 87,000 | 1.00 | 50 | | ~~⭐️ 你~~ | ~~11~~ | ~~BUY~~ | ~~87,000~~ | ~~5.50~~ | 51 | | 用户 B | 20 | BUY | 87,000 | 4.00 | 52 | | ⭐️ 你 | (new) 22 | BUY | 87,000 | 5.00 | 53 | | 用户 C | 21 | BUY | 86,999 | 2.00 | 54 | 55 | 请注意:新订单将获得新的订单 ID,并且您会失去时间优先级:订单 22 将在订单 20 之后交易。 56 | 57 | 如果您改用 **保留优先级的修改订单请求** 将 `orderId=15` 的数量减少到 `qty=5.00`,订单簿将如下所示: 58 | 59 | | 用户| 订单 ID | 订单方向 | 订单价格 | 数量 | 60 | | :---- | ----: | :---- | ----: | ----: | 61 | | 用户 A | 10 | BUY | 87,000 | 1.00 | 62 | | ⭐️ 你 | 15 | BUY | 87,000 | (amended) **5.00** | 63 | | 用户 B | 20 | BUY | 87,000 | 4.00 | 64 | | 用户 C | 21 | BUY | 86,999 | 2.00 | 65 | 66 | 请注意:订单 ID 保持不变,订单在队列中保持其优先级。只有订单数量会发生变化。 67 | 68 | ## 保留优先级的修改订单请求是否会影响未成交订单数量(速率限制)? 69 | 70 | 目前,保留优先级的修改订单请求对未成交订单计数为 0。 71 | 72 | ## 我如何才能知道我的订单是否已被修改? 73 | 74 | 如果订单修改成功,API 响应会包含具有新数量的订单。 75 | 76 | 在账户信息流上,您将收到执行类型为 `"x": "REPLACED"` 的 `"executionReport"` 事件。 77 | 78 | 如果修改后的订单隶属于订单列表,并且 client order ID 已被更改,您还将收到一个列表状态类型为 `"l": "UPDATED"` 的 "listStatus" 事件。 79 | 80 | 您也可以使用以下请求来查询订单修改历史: 81 | 82 | | API | 请求 | 83 | | :---- | :---- | 84 | | REST API | `GET /api/v3/order/amendments` | 85 | | WebSocket API | `order.amendments` | 86 | 87 | ## 如果我的修改请求不成功,该怎么办? 88 | 89 | 如果请求由于任何原因失败(比如,因为过滤器,权限,帐户限制等而失败),那么订单修改请求会被拒绝,而订单将保持不变。 90 | 91 | ## 我有可能在我的修改订单请求中重用现在的 clientOrderId 么? 92 | 93 | 没问题。 94 | 95 | 默认状态下,被修改的订单会得到一个随即生成的新 client order ID。但是,你可以通过现有的 current client order ID 赋值给 `newClientOrderId` 参数的方式来重用数据。 96 | 97 | ## 我可以对冰山订单进行修改吗? 98 | 99 | 可以的。 100 | 101 | 请注意:只有当 `newQty` 低于未修改前的可见数量时,冰山订单的可见数量才能被改变。 102 | 103 | ## 我可以对订单列表进行修改吗? 104 | 105 | 在订单列表中的订单是可以被修改的。 106 | 107 | 请注意:OCO 订单对必须具有相同的数量,因为只有一个订单可以执行。这意味着修改任一订单都会影响两个订单。 108 | 109 | 对于 OTO 订单,您可以对生效订单和待处理订单进行单独修改。 110 | 111 | ## 哪些交易对允许保留优先级的修改订单请求? 112 | 113 | 相关信息可在 Exchange Information 中找到。 114 | 允许保留优先级的修改订单请求的交易对将会把 `amendAllowed` 设置为 `true`。 115 | -------------------------------------------------------------------------------- /faqs/order_count_decrement.md: -------------------------------------------------------------------------------- 1 | # Spot Unfilled Order Count Rules 2 | 3 | To ensure a fair and orderly Spot market, we limit the rate at which new orders may be placed. 4 | 5 | The rate limit applies to the number of new, *unfilled* orders placed within a time interval. That is, orders which are partially or fully filled do not count against the rate limit. 6 | 7 | > [!NOTE] 8 | > Unfilled order rate limit rewards efficient traders. 9 | > 10 | >**So long as your orders trade, you can keep trading.** 11 | > 12 | > More information: [How do filled orders affect the rate limit?](#filled-orders-rate-limit) 13 | 14 | ## What are the current rate limits? 15 | 16 | You can query current rate limits using the "exchange information" request. 17 | 18 | The `"rateLimitType": "ORDERS"` indicates the current unfilled order rate limit. 19 | 20 | Please refer to the API documentation: 21 | 22 | | API | Request | 23 | |:--------------|:-----------------------------------------------------------| 24 | | FIX API | [LimitQuery``](../fix-api.md#limitquery) | 25 | | REST API | [`GET /api/v3/exchangeInfo`](../rest-api.md#exchangeInfo) | 26 | | WebSocket API | [`exchangeInfo`](../web-socket-api.md#exchangeInfo) | 27 | 28 | > [!IMPORTANT] 29 | > Order placement requests are also affected by the general request rate limits on REST and WebSocket API and the message limits on FIX API. 30 | > 31 | > If you send too many requests at a high rate, you will be blocked by the API. 32 | 33 | 34 | 35 | ## How does the unfilled `ORDERS` rate limit work? 36 | 37 | Every successful request to place an order adds to the unfilled order count for the current time interval. If too many unfilled orders accumulate during the interval, subsequent requests will be rejected. 38 | 39 | For example, if the unfilled order rate limit is 100 per 10 seconds: 40 | 41 | ```javascript 42 | { 43 | "rateLimitType": "ORDERS", 44 | "interval": "SECOND", 45 | "intervalNum": 10, 46 | "limit": 100 47 | } 48 | ``` 49 | 50 | then you can place at most 100 new orders between 12:34:00 and 12:34:10, then 100 more from 12:34:10 to 12:34:20, and so on. 51 | 52 | >[!TIP] 53 | >If the newly placed orders receive fills, your unfilled order count decreases and you may place more orders during the time interval. 54 | > 55 | >More information: [How do filled orders affect the rate limit?](#filled-orders-rate-limit) 56 | 57 | When an order is rejected by the system due to the unfilled order rate limit, the HTTP status code is set to `429 Too Many Requests` and the error code is `-1015 "Too many new orders"`. 58 | 59 | If you encounter these errors, please stop sending orders until the affected rate limit interval expires. 60 | 61 | Please refer to the API documentation: 62 | 63 | | API | Documentation | 64 | |:--------------|:-----------------------------------------------------------------| 65 | | FIX API | [Unfilled Order Count](../fix-api.md#unfilled-order-count) | 66 | | REST API | [Unfilled Order Count](../rest-api.md#unfilled-order-count) | 67 | | WebSocket API | [Unfilled Order Count](../web-socket-api.md#unfilled-order-count) | 68 | 69 | ## Is the unfilled order count tracked by IP address? 70 | 71 | Unfilled order count is tracked **by (sub)account**. 72 | 73 | Unfilled order count is shared across all IP addresses, all API keys, and all APIs. 74 | 75 | 76 | 77 | ## How do filled orders affect the unfilled order count? 78 | 79 | When an order is filled for the first time (partially or fully), your unfilled order count is decremented by one order for all intervals of the `ORDERS` rate limit. Effectively, orders that trade do not count towards the rate limit, allowing efficient traders to keep placing new orders. 80 | 81 | Certain orders provide additional incentive: 82 | 83 | * **Orders that do not fill immediately (that is, first fill in the maker phase).** 84 | * Orders that fill large quantities. 85 | 86 | In these cases the unfilled order count may be decremented by more than one order for each order that starts trading. 87 | 88 | **Notes:** 89 | 90 | * **The examples only give a general idea of the behavior.** The 10-second interval is used for simplicity. The actual configuration on the live exchange may be different. 91 | * There is a short delay between the order being filled and the unfilled order count update. Please be careful when your unfilled order count is close to the limit. 92 | * Please refer to [How does unfilled `ORDERS` rate limit work?](#order-rate-limit) to see how you can monitor the unfilled order count depending on the API. 93 | 94 | **Example 1** — taker: 95 | 96 | | Time | Action | Unfilled order count | 97 | |:---------|:---------------------------|:-----------------------------| 98 | | 00:00:00 | | 0 | 99 | | 00:00:01 | Place LIMIT order A | 1 — new order (+1) | 100 | | 00:00:02 | Place LIMIT order B | 2 — new order (+1) | 101 | | | (order B partially filled) | 1 — first fill as taker (−1) | 102 | | 00:00:03 | Place LIMIT order C | 2 — new order (+1) | 103 | | 00:00:04 | (order B partially filled) | 2 | 104 | | 00:00:04 | (order B filled) | 2 | 105 | | 00:00:05 | Place MARKET order D | 3 — new order (+1) | 106 | | | (order D fully filled) | 2 — first fill as taker (−1) | 107 | 108 | Note how for every taker order that immediately trades, the unfilled order count is decremented later, allowing you to keep placing orders. 109 | 110 | **Example 2** — maker: 111 | 112 | | Time | Action | Unfilled order count | 113 | |:---------|:---------------------------|:-----------------------------| 114 | | 00:00:00 | | 0 | 115 | | 00:00:01 | Place LIMIT order A | 1 — new order (+1) | 116 | | 00:00:01 | Place LIMIT order B | 2 — new order (+1) | 117 | | 00:00:02 | Place LIMIT order C | 3 — new order (+1) | 118 | | 00:00:02 | Place LIMIT order D | 4 — new order (+1) | 119 | | 00:00:02 | Place LIMIT order E | 5 — new order (+1) | 120 | | 00:00:03 | (order A partially filled) | 0 — first fill as maker (−5) | 121 | | 00:00:04 | Place LIMIT order F | 1 — new order (+1) | 122 | | 00:00:04 | Place LIMIT order G | 2 — new order (+1) | 123 | | 00:00:05 | (order A partially filled) | 2 | 124 | | 00:00:05 | (order A filled) | 2 | 125 | | 00:00:05 | (order B partially filled) | 0 — first fill as maker (−5) | 126 | | 00:00:06 | Place LIMIT order H | 1 — new order (+1) | 127 | 128 | Note how for every maker order that is filled later, the unfilled order count is decremented by a higher amount, allowing you to place more orders. 129 | 130 | ## How do canceled or expired orders affect the unfilled order count? 131 | 132 | Canceling an order does not change the unfilled order count. 133 | 134 | Expired orders also do not change the unfilled order count. 135 | 136 | **Example:** 137 | 138 | | Time | Action | Unfilled order count | 139 | |:---------|:-------------------------------|:---------------------| 140 | | 00:00:00 | | 0 | 141 | | 00:00:01 | Place LIMIT order A | 1 — new order (+1) | 142 | | 00:00:02 | Cancel order A | 1 | 143 | | 00:00:02 | Place LIMIT order B | 2 — new order (+1) | 144 | | 00:00:03 | Place LIMIT FOK order C | 3 — new order (+1) | 145 | | | (order C is fully filled) | 2 — fill (−1) | 146 | | 00:00:05 | Place LIMIT order D | 3 — new order (+1) | 147 | | 00:00:06 | Place LIMIT FOK order E | 4 — new order (+1) | 148 | | | (order E expires with no fill) | 4 | 149 | | 00:00:07 | Cancel order D | 4 | 150 | | 00:00:07 | Place LIMIT order F | 5 — new order (+1) | 151 | 152 | ## Which time zone does `"interval":"DAY"` use? 153 | 154 | UTC 155 | 156 | ## What happens if I placed an order yesterday but it is filled the next day? 157 | 158 | New order fills decrease your *current* unfilled order count regardless of when the orders were placed. 159 | 160 | **Example:** 161 | 162 | | Time | Action | Unfilled order count | 163 | |:-----------------|:----------------------------|:---------------------| 164 | | 2024-01-01 09:00 | Place 5 orders: 1..5 | 5 | 165 | | 2024-01-02 00:00 | (rate limit interval reset) | 0 | 166 | | 2024-01-02 09:00 | Place 10 orders: 6..15 | 10 | 167 | | 2024-01-02 12:00 | (orders 1..5 are filled) | 5 | 168 | | 2024-01-02 13:00 | (orders 6..10 are filled) | 0 | 169 | | 2024-01-02 14:00 | Place 2 orders: 16, 17 | 2 | 170 | | 2024-01-02 15:00 | (orders 11..15 are filled) | 0 | 171 | 172 | **Note:** You do not get credit for order fills. That is, once the unfilled order count is down to zero, additional fills will not decrease it further. New orders will increase the count as usual. 173 | -------------------------------------------------------------------------------- /faqs/order_count_decrement_CN.md: -------------------------------------------------------------------------------- 1 | # 现货未成交订单计数规则 2 | 3 | 为确保公平有序的现货市场,我们限制了新订单的下达率。 4 | 5 | 速率限制适用于在时间间隔内下达的新的、*未成交*的订单数量。也就是说,部分或全部成交的订单不计入速率限制。 6 | 7 | > [!NOTE] 8 | > 未成交的订单速率限制奖励高效的交易者。 9 | > 只要您的订单成交,您就可以继续交易。 10 | > 详细信息:[已成交订单如何影响速率限制?](#filled-orders-rate-limit) 11 | 12 | ## 当前的速率限制是多少? 13 | 14 | 您可以使用 "exchange information" 请求查询当前的速率限制。 15 | 16 | `"rateLimitType": "ORDERS"` 表示当前未成交的订单速率限制。 17 | 18 | 请参考 API 文档: 19 | 20 | | API | 请求 | 21 | | :---- | :---- | 22 | | FIX API | [LimitQuery``](../fix-api_CN.md#limitquery) | 23 | | REST API | [`GET /api/v3/exchangeInfo`](../rest-api_CN.md#exchangeInfo) | 24 | | WebSocket API | [`exchangeInfo`](../web-socket-api_CN.md#exchangeInfo) | 25 | 26 | > [!IMPORTANT] 27 | > 下单请求还受到 REST 和 WebSocket API 上的常规请求速率限制以及 FIX API 上的消息限制的影响。 28 | > 如果您以高速率发送过多的请求,您将会被 API 阻止。 29 | 30 | 31 | 32 | ## 如何运作未成交的 `ORDERS` 速率限制? 33 | 34 | 每次成功下单的请求都会增加当前时间间隔内的未成交订单计数。如果在时间间隔内累积了太多未成交的订单,后续的请求将被拒绝。 35 | 36 | 例如,如果未成交的订单速率限制为每 10 秒 100 个: 37 | 38 | ```javascript 39 | { 40 | "rateLimitType": "ORDERS", 41 | "interval": "SECOND", 42 | "intervalNum": 10, 43 | "limit": 100 44 | } 45 | ``` 46 | 47 | 那么,您在 12:34:00 到 12:34:10 之间最多可以下 100 个新订单,然后在 12:34:10 到 12:34:20 之间再下 100 个新订单,依此类推。 48 | 49 | > [!TIP] 50 | >如果新下的订单成交,那么您的未成交订单数量会减少,您可能会在该时间间隔内下更多的订单。 51 | >详细信息:[已成交订单如何影响速率限制?](#filled-orders-rate-limit) 52 | 53 | 当订单因未成交订单速率限制而被系统拒绝时,HTTP 状态代码会被设置为`429 Too Many Requests`,错误代码为`-1015 "Too many new orders"`。 54 | 55 | 如果您遇到这些错误,请停止发送订单,直到受影响的速率限制间隔到期。 56 | 57 | 请参考 API 文档: 58 | 59 | | API | 文档 | 60 | | ---- | ---- | 61 | | FIX API | [未成交订单计数](../fix-api_CN.md#unfilled-order-count) | 62 | | REST API | [未成交订单计数](../rest-api_CN.md#unfilled-order-count) | 63 | | WebSocket API |[未成交订单计数](../web-socket-api_CN.md#unfilled-order-count) | 64 | 65 | ## 是否按 IP 地址来统计未成交的订单计数? 66 | 67 | 未成交订单计数是根据 **(子)账户** 来统计的。 68 | 69 | 未成交订单计数在所有 IP 地址、所有 API 密钥和所有 API 之间共享。 70 | 71 | 72 | 73 | ## 已成交的订单如何影响未成交的订单数量? 74 | 75 | 当订单首次(部分或全部)成交时,在 `ORDERS` 速率限制的所有时间间隔内,您的未成交订单数量将会减少一个订单。实际上,已成交的订单不计入速率限制,这将允许高效的交易者继续下新订单。 76 | 77 | 某些订单会提供额外的激励: 78 | 79 | * **未立即成交的订单(即,在 maker 阶段首次成交)。** 80 | * 大批量成交的订单。 81 | 82 | 在这些情况下,对于每个开始交易的订单,未成交的订单数量可能会减少多个订单。 83 | 84 | **注意:** 85 | 86 | * **这些示例仅给出了相关行为的通用概念。** 为了简单起见,请使用 10 秒间隔。实时交易平台上的实际配置可能会有所不同。 87 | * 在正在执行的订单和未成交订单计数更新之间有短暂的延迟。当您的未成交订单数量接近限制时,请务必小心。 88 | * 请参考 [如何运作未成交的 `ORDERS` 速率限制?](#order-rate-limit) 以了解如何根据 API 来监控未成交订单计数。 89 | 90 | **例 1** — taker: 91 | 92 | | 时间 | 操作 | 未成交订单数量| 93 | | :---- | :---- | :---- | 94 | | 00:00:00 | | 0 | 95 | | 00:00:01 | 下订单 A (限价单) | 1 — 新订单 (+1) | 96 | | 00:00:02 | 下订单 B (限价单) | 2 — 新订单 (+1) | 97 | | | (订单 B 部分成交) | 1 — 作为 taker 首次成交 (−1) | 98 | | 00:00:03 | 下订单 C (限价单) | 2 — 新订单 (+1) | 99 | | 00:00:04 | (订单 B 部分成交) | 2 | 100 | | 00:00:04 | (订单 B 已成交) | 2 | 101 | | 00:00:05 | 下订单 D (市价单) | 3 — 新订单 (+1) | 102 | | | (订单 D 全部成交) | 2 — 作为 taker 首次成交 (−1) | 103 | 104 | 请注意,对于每个立即交易的 taker 订单,未成交的订单数量稍后会减少,从而允许您继续下单。 105 | 106 | **例 2** — maker: 107 | 108 | | 时间 | 操作 | 未成交订单数量| 109 | | :---- | :---- | :---- | 110 | | 00:00:00 | | 0 | 111 | | 00:00:01 | 下订单 A (限价单) | 1 — 新订单 (+1) | 112 | | 00:00:01 | 下订单 B (限价单) | 2 — 新订单 (+1) | 113 | | 00:00:02 | 下订单 C (限价单) | 3 — 新订单 (+1) | 114 | | 00:00:02 | 下订单 D (限价单) | 4 — 新订单 (+1) | 115 | | 00:00:02 | 下订单 E (限价单) | 5 — 新订单 (+1) | 116 | | 00:00:03 | (订单 A 部分成交) | 0 — 作为 maker 首次成交 (−5) | 117 | | 00:00:04 | 下订单 F (限价单) | 1 — 新订单 (+1) | 118 | | 00:00:04 | 下订单 G (限价单) | 2 — 新订单 (+1) | 119 | | 00:00:05 | (订单 A 部分成交) | 2 | 120 | | 00:00:05 | (订单 A 已成交) | 2 | 121 | | 00:00:05 | (订单 B 部分成交) | 0 — 作为 maker 首次成交 (−5) | 122 | | 00:00:06 | 下订单 H (限价单) | 1 — 新订单 (+1) | 123 | 124 | 请注意,对于稍后执行的每个 maker 单,未执行的订单数量会减去更高的数量,从而允许您下更多订单。 125 | 126 | ## 取消或过期的订单如何影响未成交的订单数量? 127 | 128 | 取消订单不会更改未成交的订单计数。 129 | 130 | 过期的订单也不会改变未成交的订单计数。 131 | 132 | **例:** 133 | 134 | | 时间 | 操作 | 未成交订单数量| 135 | | :---- | :---- | :---- | 136 | | 00:00:00 | | 0 | 137 | | 00:00:01 | 下订单 A (限价单) | 1 — 新订单 (+1) | 138 | | 00:00:02 | 取消订单 A | 1 | 139 | | 00:00:02 | 下订单 B (限价单) | 2 — 新订单(+1) | 140 | | 00:00:03 | 下订单 C (限价 FOK 单) | 3 — 新订单 (+1) | 141 | | | (订单 C 已成交) | 2 — fill (−1) | 142 | | 00:00:05 | 下订单 D (限价单) | 3 — 新订单 (+1) | 143 | | 00:00:06 | 下订单 E (限价 FOK 单) | 4 — 新订单 (+1) | 144 | | | (订单 E 过期且没有成交) | 4 | 145 | | 00:00:07 | 取消订单 D | 4 | 146 | | 00:00:07 | 下订单 F (限价单) | 5 — 新订单 (+1) | 147 | 148 | ## `interval:DAY` 使用哪个时区? 149 | 150 | UTC。 151 | 152 | ## 如果我昨天下了订单,但第二天才成交,会发生什么情况? 153 | 154 | 无论订单是何时成交的,新成交的订单都会减少您当前未成交的订单数量。 155 | 156 | **例:** 157 | 158 | | 时间 | 操作 | 未成交订单数量| 159 | | :---- | :---- | :---- | 160 | | 2024-01-01 09:00 | 下 5 个订单: 1..5 | 5 | 161 | | 2024-01-02 00:00 | (速率间隔重置) | 0 | 162 | | 2024-01-02 09:00 | 下 10 个订单: 6..15 | 10 | 163 | | 2024-01-02 12:00 | (订单 1...5 已成交) | 5 | 164 | | 2024-01-02 13:00 | (订单 6...10 已成交) | 0 | 165 | | 2024-01-02 14:00 | 下 2 个订单: 16, 17 | 2 | 166 | | 2024-01-02 15:00 | (订单 11...15 已成交) | 0 | 167 | 168 | **注意:** 您不会因订单的成交而获得信用。也就是说,一旦未成交的订单数量减少到零,额外的成交将不会进一步影响未成交订单计数。新订单将像依旧增加计数。 169 | -------------------------------------------------------------------------------- /faqs/sbe_faq.md: -------------------------------------------------------------------------------- 1 | # Simple Binary Encoding (SBE) FAQ 2 | 3 | The goal of this document is to explain: 4 | 5 | * How to receive SBE responses in the SPOT API. 6 | * How to decode SBE responses. 7 | 8 | SBE is a serialization format used for low-latency. 9 | 10 | This implementation is based on the FIX SBE specification. 11 | * [GitHub repository](https://github.com/FIXTradingCommunity/fix-simple-binary-encoding) 12 | * [HTML document](https://www.fixtrading.org/standards/sbe-online) 13 | 14 | ## How to get an SBE response 15 | 16 | ### For REST API: 17 | 18 | * The `Accept` header must include `application/sbe`. 19 | * Provide the schema ID and version in the `X-MBX-SBE` header as `:`. 20 | 21 | Sample request (REST): 22 | 23 | ``` 24 | curl -sX GET -H "Accept: application/sbe" -H "X-MBX-SBE: 1:0" 'https://api.binance.com/api/v3/exchangeInfo?symbol=BTCUSDT' 25 | ``` 26 | **Notes:** 27 | 28 | * If you provide only `application/sbe` in the Accept header: 29 | * If SBE is not enabled in the exchange, you will receive an HTTP **406 Not Acceptable**. 30 | * If the `:` provided in the `X-MBX-SBE` header is malformed or invalid, the response will be an SBE-encoded error. 31 | * If the `X-MBX-SBE` header is missing, the response will be an SBE-encoded error. 32 | * If you provide both `application/sbe` and `application/json` in the Accept header: 33 | * If SBE is not enabled in the exchange, the response will fall back to JSON. 34 | * If the `:` provided in the `X-MBX-SBE` header is malformed or invalid, the response will fall back to JSON. 35 | * If the `X-MBX-SBE` header is missing, the response will fall back to JSON. 36 | 37 | ### For WebSocket API: 38 | 39 | * In the connection URL, add `responseFormat=sbe`. 40 | * Provide the schema ID and version in the parameters `sbeSchemaId=` and `sbeSchemaVersion=` respectively. 41 | 42 | Sample request (WebSocket): 43 | 44 | ```bash 45 | id=$(date +%s%3N) 46 | method="exchangeInfo" 47 | params='{"symbol":"BTCUSDT"}' 48 | 49 | request=$( jq -n \ 50 | --arg id "$id" \ 51 | --arg method "$method" \ 52 | --argjson params "$params" \ 53 | '{id: $id, method: $method, params: $params}' ) 54 | 55 | response=$(echo $request | websocat -n1 'wss://ws-api.binance.com:443/ws-api/v3?responseFormat=sbe&sbeSchemaId=1&sbeSchemaVersion=0') 56 | ``` 57 | 58 | **Notes:** 59 | 60 | * If you provide only `responseFormat=sbe` in the connection URL: 61 | * If SBE is not enabled in the exchange, the response will be HTTP 400. 62 | * If the `sbeSchemaId=` or `sbeSchemaVersion=` are malformed or invalid, the response will be HTTP 400. 63 | * If you provide both `responseFormat=sbe` and `responseFormat=json`, the response will be HTTP 400. 64 | * All error responses during the HTTP handshake are encoded as JSON with the `Content-Type` header set to `application/json;charset=UTF-8`. 65 | * Once a WebSocket session has been successfully established with SBE enabled, all method responses within that session are encoded in SBE, even in the event SBE becomes disabled. 66 | * This means that if SBE is disabled while your WebSocket connection is active, you will receive an SBE-encoded "SBE is not enabled" error in response to any subsequent request. 67 | * As of writing, we do not recommend using `websocat` to send any request as we have observed issues in how it decodes binary frames. The sample above is only used for reference to show the URL to get an SBE response. 68 | 69 | ## Supported APIs 70 | 71 | REST API and WebSocket API for SPOT support SBE. 72 | 73 | ## SBE Schema 74 | 75 | * The schema to use both for the live exchange and SPOT Testnet will be saved in this repository [here](https://github.com/binance/binance-spot-api-docs/tree/master/sbe/schemas). 76 | * Any updates to the schema will be noted in the [CHANGELOG](../CHANGELOG.md). 77 | 78 | **Regarding Legacy support:** 79 | 80 | * SBE schemas are versioned via two XML attributes, `id` and `version`. 81 | * `id` is incremented when a breaking change is introduced. When this occurs, `version` is reset to 0. 82 | * `version` is incremented when a non-breaking change is introduced. When this occurs, `id` is not modified. 83 | * When a new schema is live the old schema becomes deprecated. **Deprecation occurs even when the new schema only introduces non-breaking changes.** 84 | * A deprecated schema will be supported **for at least 6 months after deprecation**.
For example given this hypothetical timeline: 85 | * January 3024: Schema id 1 version 0 is released. This is the first version so this is usable once SBE is enabled in the exchange. 86 | * March 3024: Schema id 1 version 1 is released. This schema introduces a non-breaking change. 87 | * Schema id 1 version 0 is deprecated, but can still be used for at least another 6 months. 88 | * August 3024: Schema id 2 version 0 is released. This schema introduces a breaking change. 89 | * Schema id 1 version 0 is deprecated, but can still be used for at least another 1 month. 90 | * Schema id 1 version 1 is deprecated, but can still be used for at least another 6 months. 91 | * September 3024: 6 months have passed since the release of Schema id 1 version 1. 92 | * Schema id 1 version 0 is retired. 93 | * February 3025: Schema id 2 version 1 is released. This schema introduces a non-breaking change. 94 | * Schema id 1 version 1 is retired. 95 | * Schema id 2 version 0 is deprecated, but can still be used for at least another 6 months. 96 | * HTTP responses will contain a `X-MBX-SBE-DEPRECATED` header for requests specifying a deprecated `:` in their `X-MBX-SBE` header. 97 | * For WebSocket responses, the field `sbeSchemaIdVersionDeprecated` will be set to `true` for requests specifying a deprecated `sbeSchemaId` and `sbeSchemaVersion` in their connection URL. 98 | * Requests specifying a retired `:` (REST API) or `sbeSchemaId` and `sbeSchemaVersion` (WebSocket API) will fail with HTTP 400. 99 | * JSON file regarding the schema life-cycle with the dates of the latest, deprecated, and retired schemas for both the live exchange and SPOT Testnet will be saved in this repository [here](https://github.com/binance/binance-spot-api-docs/tree/master/sbe/schemas).
Below is an example JSON based on the hypothetical timeline above: 100 | 101 | ```json 102 | { 103 | "environment": "PROD", 104 | "latestSchema": { 105 | "id": 2, 106 | "version": 1, 107 | "releaseDate": "3025-02-01" 108 | }, 109 | "deprecatedSchemas": [ 110 | { 111 | "id": 2, 112 | "version": 0, 113 | "releaseDate": "3024-08-01", 114 | "deprecatedDate": "3025-02-01" 115 | } 116 | ], 117 | "retiredSchemas": [ 118 | { 119 | "id": 1, 120 | "version": 1, 121 | "releaseDate": "3024-03-01", 122 | "deprecatedDate": "3024-08-01", 123 | "retiredDate": "3025-02-01", 124 | }, 125 | { 126 | "id": 1, 127 | "version": 0, 128 | "releaseDate": "3024-01-01", 129 | "deprecatedDate": "3024-03-01", 130 | "retiredDate": "3024-09-01", 131 | } 132 | ] 133 | } 134 | ``` 135 | 136 | ## Generate SBE decoders: 137 | 138 | 1. Download the schema: 139 | * [`spot_prod_latest.xml`](../sbe/schemas/spot_prod_latest.xml) for the live exchange. 140 | * [`spot_testnet_latest.xml`](../sbe/schemas/spot_testnet_latest.xml) for [SPOT Testnet](https://testnet.binance.vision). 141 | 2. Clone and build [`simple-binary-encoding`](https://github.com/real-logic/simple-binary-encoding): 142 | ```shell 143 | $ git clone https://github.com/real-logic/simple-binary-encoding.git 144 | $ cd simple-binary-encoding 145 | $ ./gradlew 146 | ``` 147 | 3. Run the SbeTool code generator. (Here are samples for [Java](https://github.com/binance/binance-sbe-java-sample-app), [C++](https://github.com/binance/binance-sbe-cpp-sample-app) and [Rust](https://github.com/binance/binance-sbe-rust-sample-app) decoding the payload from Exchange Information.) 148 | 149 | ### Decimal field encoding 150 | 151 | Unlike the FIX SBE specification, decimal fields have their mantissa and exponent fields encoded separately as primitive fields in order to minimize payload size and the number of encoded fields within messages. 152 | 153 | ### Timestamp field encoding 154 | 155 | Timestamps in SBE responses are in microseconds. This differs from JSON responses, which contain millisecond timestamps. 156 | 157 | ### Custom field attributes in the schema file 158 | 159 | A few field attributes prefixed with `mbx:` were added to the schema file for documentation purposes: 160 | - `mbx:exponent`: Points to the exponent field corresponding to the mantissa field 161 | - `mbx:jsonPath`: Contains the name of the equivalent field in the JSON response 162 | - `mbx:jsonValue`: Contains the name of the equivalent ENUM value in the JSON response 163 | 164 | 165 | 166 | 167 | 168 | 169 | -------------------------------------------------------------------------------- /faqs/sbe_faq_CN.md: -------------------------------------------------------------------------------- 1 | # 简单二进制编码 (SBE) 常见问题 2 | 3 | 本文档的目标是解释下列疑问: 4 | 5 | * 如何在现货交易API中启用 `SBE` 响应。 6 | * 如何对 `SBE` 的响应进行解码。 7 | 8 | SBE 是一种用于实现低延迟的序列化格式。 9 | 10 | 本实现是基于 `FIX SBE` 规范。 11 | * [GitHub repository](https://github.com/FIXTradingCommunity/fix-simple-binary-encoding) 12 | * [HTML document](https://www.fixtrading.org/standards/sbe-online) 13 | 14 | ### 如何获取 SBE 响应 15 | 16 | #### REST API 17 | 18 | * `Accept` 报文头必须包含 `application/sbe`。 19 | * 在 `X-MBX-SBE` 报文头中以 `:` 的形式提供 `schema ID` 和 `version`。 20 | 21 | 样本请求(REST): 22 | 23 | ``` 24 | curl -sX GET -H "Accept: application/sbe" -H "X-MBX-SBE: 1:0" 'https://api.binance.com/api/v3/exchangeInfo?symbol=BTCUSDT' 25 | ``` 26 | 27 | **注意:** 28 | 29 | * 如果你只在 `Accept` 报文头中提供了 `application/sbe` 30 | * 如果交易所不支持 `SBE`,你将收到一个**406 不可接受**的响应。 31 | * 如果在 `X-MBX-SBE` 报文头中提供的 XML 模式是属于格式错误或不正确的情况,那你得到的响应将会是一个 `SBE` 解码错误。 32 | * 如果 `X-MBX-SBE` 报文头缺失,那你得到的响应将会是一个 `SBE` 解码错误。 33 | * 如果你在 `Accept` 报文头中同时提供了 `application/sbe` 和 `application/json`: 34 | * 如果交易所不支持 `SBE`,那么响应将会被回退到 `JSON`。 35 | * 如果在 `X-MBX-SBE` 报文头中提供的 XML 模式是属于格式错误或不正确的情况,那么响应将会被回退到 `JSON`。 36 | * 如果 `X-MBX-SBE` 报文头缺失,那么响应将会被回退到 `JSON`。 37 | 38 | 39 | #### WebSocket API 40 | 41 | * 在请求的URL中添加 `responseFormat=sbe`。 42 | * 添加schema ID 和 version 到参数 `sbeSchemaId=` 和 `sbeSchemaVersion=`。 43 | 44 | 样本请求 (WebSocket): 45 | 46 | ```bash 47 | id=$(date +%s%3N) 48 | method="exchangeInfo" 49 | params='{"symbol":"BTCUSDT"}' 50 | 51 | request=$( jq -n \ 52 | --arg id "$id" \ 53 | --arg method "$method" \ 54 | --argjson params "$params" \ 55 | '{id: $id, method: $method, params: $params}' ) 56 | 57 | response=$(echo $request | websocat -n1 'wss://ws-api.binance.com:443/ws-api/v3?responseFormat=sbe&sbeSchemaId=1&sbeSchemaVersion=0') 58 | ``` 59 | 60 | **注意:** 61 | 62 | * 如果你只在连接URL中添加 `responseFormat=sbe` : 63 | * 如果交易所没有开启 SBE,请求返回 HTTP 400. 64 | * 如果 `sbeSchemaId=` 或者 `sbeSchemaVersion=` 格式不正确或者无效,请求返回 HTTP 400. 65 | * 如果你同时提供 `responseFormat=sbe` 和 `responseFormat=json`, 请求返回 HTTP 400. 66 | * 在HTTP握手期间的所有错误响应都编码为JSON,`Content-Type`头设置为`application/json;charset=UTF-8`. 67 | * 一旦成功建立了启用了SBE的WebSocket会话,在该会话中的所有方法响应都编码为SBE,即使在SBE被禁用的情况下也是如此。 68 | * 这意味着,如果在您的WebSocket连接处于活动状态时禁用了SBE,那么在对您的后续请求做出响应时,您将会收到一个被SBE编码了的“SBE未启用”错误。 69 | * 就目前而言,我们不建议使用`websocat`发送任何请求,因为我们观察到了它解码二进制帧的问题。上面的样本仅用作参考,显示获取SBE响应的URL。 70 | 71 | 72 | ### 支持的 APIs 73 | 74 | 目前现货交易的 REST API 和 WebSocket API 支持 `SBE`。 75 | 76 | 77 | ### SBE 模式 78 | 79 | * 将被使用的模式 (schema) 会被保存在此仓库 (repository) 中,[请看这里](https://github.com/binance/binance-spot-api-docs/tree/master/sbe/schemas)。 80 | * 对于模式的任何更新将会被记录在[更改日志](../CHANGELOG_CN.md)中。 81 | 82 | **关于对旧版本的支持:** 83 | 84 | * SBE 模式通过两个 XML 属性进行版本控制,`id` 和 `version`。 85 | * 当引入破坏性更改时,`id` 会增加。当这种情况发生时,`version` 会被重置为0。 86 | * 当引入非破坏性更改时,`version` 会增加。当这种情况发生时,`id` 不会被修改。 87 | * 当新模式发布时,旧模式会被废止。 **即便新模式只引入非破坏性更改,这种情况也会导致废止。** 88 | * 已废止的模式将在被废止后**依然得到至少6个月的支持**。
用以下这个假设的时间线为例: 89 | * 3024年1月:发布模式 id 1 version 0。这是第一版,一旦交易所启用 `SBE`,用户就立刻可以开始使用该模式。 90 | * 3024年3月:发布模式 id 1 version 1。这个模式引入了一个非破坏性的变化。 91 | * 模式 id 1 version 0 此时已被废止,但还可以至少再被使用6个月。 92 | * 3024年8月:发布模式 id 2 version 0。这个模式引入了一个破坏性的变化。 93 | * 模式 id 1 version 0 已被废止,但还可以再被使用至少1个月。 94 | * 模式 id 1 version 1 此时已被废止,但还可以再被使用至少6个月。 95 | * 3024年9月:自模式 id 1 version 1 发布以来已经过去6个月。 96 | * 模式 id 1 version 0 已被停用。 97 | * 3025年2月:发布模式id 2 版本 1。这个模式引入了一个非破坏性的变化。 98 | * 模式 id 1 version 1 已被停用。 99 | * 模式 id 2 version 0 此时已被废止,但还可以再被使用至少另外6个月。 100 | * HTTP将在针对 `X-MBX-SBE header` 中已被废止的 `SBE` 模式版本请求的响应中包含一个 `X-MBX-SBE-DEPRECATED` 报文头 。 101 | * 对于WebSocket响应,如果在其连接URL中指定了已弃用的`sbeSchemaId`和`sbeSchemaVersion`,`sbeSchemaIdVersionDeprecated`字段将被设置为`true`。 102 | * 指定已废止的`:`(REST API)或`sbeSchemaId`和`sbeSchemaVersion` (WebSocket API)的请求将会返回HTTP 400错误。 103 | * 关于模式生命周期的 `JSON` 文件将被保存在此仓库中,[请看这里](https://github.com/binance/binance-spot-api-docs/tree/master/sbe/schemas)。这个文件包含了关于实时交易所和现货测试网的最新、被废止和被停用模式的具体发生日期。
以下是一个基于上述假设时间线的 `JSON` 示例: 104 | 105 | ```json 106 | { 107 | "environment": "PROD", 108 | "latestSchema": { 109 | "id": 2, 110 | "version": 1, 111 | "releaseDate": "3025-02-01" 112 | }, 113 | "deprecatedSchemas": [ 114 | { 115 | "id": 2, 116 | "version": 0, 117 | "releaseDate": "3024-08-01", 118 | "deprecatedDate": "3025-02-01" 119 | } 120 | ], 121 | "retiredSchemas": [ 122 | { 123 | "id": 1, 124 | "version": 1, 125 | "releaseDate": "3024-03-01", 126 | "deprecatedDate": "3024-08-01", 127 | "retiredDate": "3025-02-01", 128 | }, 129 | { 130 | "id": 1, 131 | "version": 0, 132 | "releaseDate": "3024-01-01", 133 | "deprecatedDate": "3024-03-01", 134 | "retiredDate": "3024-09-01", 135 | } 136 | ] 137 | } 138 | ``` 139 | 140 | ### 生成解码器: 141 | 142 | 1. 下载模式: 143 | * [`spot_prod_latest.xml`](../sbe/schemas/spot_prod_latest.xml) 适用于实时交易所。 144 | * [`spot_testnet_latest.xml`](../sbe/schemas/spot_testnet_latest.xml) 适用于 [现货测试网](https://testnet.binance.vision)。 145 | 2. 克隆并构建 [`simple-binary-encoding`](https://github.com/real-logic/simple-binary-encoding): 146 | ```shell 147 | $ git clone https://github.com/real-logic/simple-binary-encoding.git 148 | $ cd simple-binary-encoding 149 | $ ./gradlew 150 | ``` 151 | 3. 运行 `SbeTool` 代码生成器。(请参考这里分别使用[Java](https://github.com/binance/binance-sbe-java-sample-app), [C++](https://github.com/binance/binance-sbe-cpp-sample-app) 和 [Rust](https://github.com/binance/binance-sbe-rust-sample-app) 解码交易所信息 payload 的样本。) 152 | 153 | #### 十进制字段编码 154 | 155 | 不同于 `FIX SBE` 的规范,十进制字段的尾数和指数字段被单独编码为原始字段,以便使负载量和消息内编码字段的数量达到最小化。 156 | 157 | #### 时间戳字段编码 158 | 159 | SBE响应中的时间戳(Timestamps)是以微秒为单位。这与包含毫秒时间戳的JSON响应不同。 160 | 161 | #### 模式文件中的自定义字段属性 162 | 163 | 在模式文件中添加了一些以 `mbx:` 为前缀的字段属性,供文档使用: 164 | - `mbx:exponent`:指向对应于尾数字段的指数域 165 | - `mbx:jsonPath`:包含了 `JSON` 响应中相应字段的名称 166 | - `mbx:jsonValue`: 包含了 `JSON` 响应中等价 `ENUM` 值的名称 167 | -------------------------------------------------------------------------------- /faqs/sor_faq.md: -------------------------------------------------------------------------------- 1 | # Smart Order Routing (SOR) 2 | 3 | **Disclaimer:** 4 | 5 | * The symbols and values used here are fictional, and do not imply anything about the actual setup on the live exchange. 6 | * For simplicity, the examples in this document do not include commission. 7 | 8 | ## What is Smart Order Routing (SOR)? 9 | 10 | **Smart Order Routing (SOR)** allows you to potentially get better liquidity by filling an order with liquidity from other order books with the same base asset and interchangeable quote assets. **Interchangeable quote assets** are quote assets with fixed 1 to 1 exchange rate, such as stablecoins pegged to the same fiat currency. 11 | 12 | Note that even though the quote assets are interchangeable, when selling the base asset you will always receive the quote asset of the symbol in your order. 13 | 14 | When you place an order using SOR, it goes through the eligible order books, looks for best price levels for each order book in that SOR configuration, and takes from those books if possible. 15 | 16 | **Note:** If the order using SOR cannot fully fill based on the eligible order books' liquidity, `LIMIT IOC` or `MARKET` orders will immediately expire, while `LIMIT GTC` orders will place the remaining quantity on the order book you originally submitted the order to. 17 | 18 | ### Example 1 19 | 20 | Let's consider a SOR configuration containing the symbols `BTCUSDT`, `BTCUSDC` and `BTCUSDP`, and the following `ASK` (`SELL` side) order books for those symbols: 21 | 22 | ``` 23 | BTCUSDT quantity 3 price 30,800 24 | BTCUSDT quantity 3 price 30,500 25 | 26 | BTCUSDC quantity 1 price 30,000 27 | BTCUSDC quantity 1 price 28,000 28 | 29 | BTCUSDP quantity 1 price 35,000 30 | BTCUSDP quantity 1 price 29,000 31 | ``` 32 | 33 | If you send a `LIMIT GTC BUY` order for `BTCUSDT` with `quantity=0.5` and `price=31000`, you would match with the best SELL price on the BTCUSDT book at 30,500. You would spend 15,250 USDT and receive 0.5 BTC. 34 | 35 | If you send a `LIMIT GTC BUY` order _using SOR_ for `BTCUSDT` with `quantity=0.5` and `price=31000`, you would match with the best SELL price across _all symbols in the SOR_, which is BTCUSDC at price 28,000. You would spend 14,000 USDT (_not_ USDC!) and receive 0.5 BTC. 36 | 37 | ```javascript 38 | { 39 | "symbol": "BTCUSDT", 40 | "orderId": 2, 41 | "orderListId": -1, 42 | "clientOrderId": "sBI1KM6nNtOfj5tccZSKly", 43 | "transactTime": 1689149087774, 44 | "price": "31000.00000000", 45 | "origQty": "0.50000000", 46 | "executedQty": "0.50000000", 47 | "cummulativeQuoteQty": "14000.00000000", 48 | "status": "FILLED", 49 | "timeInForce": "GTC", 50 | "type": "LIMIT", 51 | "side": "BUY", 52 | "workingTime": 1689149087774, 53 | "fills": [ 54 | { 55 | "matchType": "ONE_PARTY_TRADE_REPORT", 56 | "price": "28000.00000000", 57 | "qty": "0.50000000", 58 | "commission": "0.00000000", 59 | "commissionAsset": "BTC", 60 | "tradeId": -1, 61 | "allocId": 0 62 | } 63 | ], 64 | "workingFloor": "SOR", 65 | "selfTradePreventionMode": "NONE", 66 | "usedSor": true 67 | } 68 | ``` 69 | 70 | ### Example 2 71 | 72 | Using the same order book as Example 1: 73 | 74 | ``` 75 | BTCUSDT quantity 3 price 30,800 76 | BTCUSDT quantity 3 price 30,500 77 | 78 | BTCUSDC quantity 1 price 30,000 79 | BTCUSDC quantity 1 price 28,000 80 | 81 | BTCUSDP quantity 1 price 35,000 82 | BTCUSDP quantity 1 price 29,000 83 | ``` 84 | 85 | If you send a `LIMIT GTC BUY` order for `BTCUSDT` with `quantity=5` and `price=31000`, you would: 86 | 87 | * match with the 3 BTCUSDT at 30,500, and buy 3 BTC for 91,500 USDT 88 | * then match with the 3 BTCUSDT at 30,800, and buy 2 BTC for 61,600 USDT 89 | 90 | In total, you spend 153,100 USDT and receive 5 BTC. 91 | 92 | If you send the same `LIMIT GTC BUY` order _using SOR_ for `BTCUSDT` with `quantity=5` and `price=31000`, you would: 93 | 94 | * match with 1 BTCUSDC at 28,000, and buy 1 BTC for 28,000 USDT 95 | * match with 1 BTCUSDP at 29,000, and buy 1 BTC for 29,000 USDT 96 | * match with 1 BTCUSDC at 30,000, and buy 1 BTC for 30,000 USDT 97 | * match with 3 BTCUSDT at 30,500, and buy 2 BTC for 61,000 USDT 98 | 99 | In total, you spend 148,000 USDT and receive 5 BTC. 100 | 101 | ```javascript 102 | { 103 | "symbol": "BTCUSDT", 104 | "orderId": 2, 105 | "orderListId": -1, 106 | "clientOrderId": "tHonoNjWfOSaKiTygN3bfY", 107 | "transactTime": 1689146154686, 108 | "price": "31000.00000000", 109 | "origQty": "5.00000000", 110 | "executedQty": "5.00000000", 111 | "cummulativeQuoteQty": "148000.00000000", 112 | "status": "FILLED", 113 | "timeInForce": "GTC", 114 | "type": "LIMIT", 115 | "side": "BUY", 116 | "workingTime": 1689146154686, 117 | "fills": [ 118 | { 119 | "matchType": "ONE_PARTY_TRADE_REPORT", 120 | "price": "28000.00000000", 121 | "qty": "1.00000000", 122 | "commission": "0.00000000", 123 | "commissionAsset": "BTC", 124 | "tradeId": -1, 125 | "allocId": 0 126 | }, 127 | { 128 | "matchType": "ONE_PARTY_TRADE_REPORT", 129 | "price": "29000.00000000", 130 | "qty": "1.00000000", 131 | "commission": "0.00000000", 132 | "commissionAsset": "BTC", 133 | "tradeId": -1, 134 | "allocId": 1 135 | }, 136 | { 137 | "matchType": "ONE_PARTY_TRADE_REPORT", 138 | "price": "30000.00000000", 139 | "qty": "1.00000000", 140 | "commission": "0.00000000", 141 | "commissionAsset": "BTC", 142 | "tradeId": -1, 143 | "allocId": 2 144 | }, 145 | { 146 | "matchType": "ONE_PARTY_TRADE_REPORT", 147 | "price": "30500.00000000", 148 | "qty": "2.00000000", 149 | "commission": "0.00000000", 150 | "commissionAsset": "BTC", 151 | "tradeId": -1, 152 | "allocId": 3 153 | } 154 | ], 155 | "workingFloor": "SOR", 156 | "selfTradePreventionMode": "NONE", 157 | "usedSor": true 158 | } 159 | ``` 160 | 161 | ### Example 3 162 | 163 | Using the same order book as Example 1 and 2: 164 | 165 | ``` 166 | BTCUSDT quantity 3 price 30,800 167 | BTCUSDT quantity 3 price 30,500 168 | 169 | BTCUSDC quantity 1 price 30,000 170 | BTCUSDC quantity 1 price 28,000 171 | 172 | BTCUSDP quantity 1 price 35,000 173 | BTCUSDP quantity 1 price 29,000 174 | ``` 175 | 176 | If you send a `MARKET BUY` order for `BTCUSDT` _using SOR_ with `quantity=11`, there is only 10 BTC in total available across all eligible order books. Once all the order books in SOR configuration have been exhausted, the remaining quantity of 1 expires. 177 | 178 | ```javascript 179 | { 180 | "symbol": "BTCUSDT", 181 | "orderId": 2, 182 | "orderListId": -1, 183 | "clientOrderId": "jdFYWTNyzplbNvVJEzQa0o", 184 | "transactTime": 1689149513461, 185 | "price": "0.00000000", 186 | "origQty": "11.00000000", 187 | "executedQty": "10.00000000", 188 | "cummulativeQuoteQty": "305900.00000000", 189 | "status": "EXPIRED", 190 | "timeInForce": "GTC", 191 | "type": "MARKET", 192 | "side": "BUY", 193 | "workingTime": 1689149513461, 194 | "fills": [ 195 | { 196 | "matchType": "ONE_PARTY_TRADE_REPORT", 197 | "price": "28000.00000000", 198 | "qty": "1.00000000", 199 | "commission": "0.00000000", 200 | "commissionAsset": "BTC", 201 | "tradeId": -1, 202 | "allocId": 0 203 | }, 204 | { 205 | "matchType": "ONE_PARTY_TRADE_REPORT", 206 | "price": "29000.00000000", 207 | "qty": "1.00000000", 208 | "commission": "0.00000000", 209 | "commissionAsset": "BTC", 210 | "tradeId": -1, 211 | "allocId": 1 212 | }, 213 | { 214 | "matchType": "ONE_PARTY_TRADE_REPORT", 215 | "price": "30000.00000000", 216 | "qty": "1.00000000", 217 | "commission": "0.00000000", 218 | "commissionAsset": "BTC", 219 | "tradeId": -1, 220 | "allocId": 2 221 | }, 222 | { 223 | "matchType": "ONE_PARTY_TRADE_REPORT", 224 | "price": "30500.00000000", 225 | "qty": "3.00000000", 226 | "commission": "0.00000000", 227 | "commissionAsset": "BTC", 228 | "tradeId": -1, 229 | "allocId": 3 230 | }, 231 | { 232 | "matchType": "ONE_PARTY_TRADE_REPORT", 233 | "price": "30800.00000000", 234 | "qty": "3.00000000", 235 | "commission": "0.00000000", 236 | "commissionAsset": "BTC", 237 | "tradeId": -1, 238 | "allocId": 4 239 | }, 240 | { 241 | "matchType": "ONE_PARTY_TRADE_REPORT", 242 | "price": "35000.00000000", 243 | "qty": "1.00000000", 244 | "commission": "0.00000000", 245 | "commissionAsset": "BTC", 246 | "tradeId": -1, 247 | "allocId": 5 248 | } 249 | ], 250 | "workingFloor": "SOR", 251 | "selfTradePreventionMode": "NONE", 252 | "usedSor": true 253 | } 254 | ``` 255 | 256 | ### Example 4 257 | 258 | Let's consider a SOR configuration containing the symbols `BTCUSDT`, `BTCUSDC` and `BTCUSDP` and the following `BID` (`BUY` side) order book for those symbols: 259 | 260 | ``` 261 | BTCUSDT quantity 5 price 29,500 262 | 263 | BTCUSDC quantity 5 price 35,000 264 | BTCUSDC quantity 5 price 30,000 265 | 266 | BTCUSDP quantity 5 price 28,000 267 | ``` 268 | 269 | If you send a `LIMIT GTC SELL` order for `BTCUSDT` with `price=29000` and `quantity=10`, you would sell 5 BTC and receive 147,500 USDT. Since there is no better price available on the BTCUSDT book, the remaining (unfilled) quantity of the order will rest there at the price of 29,000. 270 | 271 | If you send a `LIMIT GTC SELL` order _using SOR_ for `BTCUSDT`, you would: 272 | 273 | * match with 5 BTCUSDC at 35,000 and sell 5 BTC for 175,000 USDT 274 | * match with 5 BTCUSDC at 30,000 and sell 5 BTC for 150,000 USDT 275 | 276 | In total, you sell 10 BTC and receive 325,000 USDT. 277 | 278 | ```javascript 279 | { 280 | "symbol": "BTCUSDT", 281 | "orderId": 1, 282 | "orderListId": -1, 283 | "clientOrderId": "W1iXSng1fS77dvanQJDGA5", 284 | "transactTime": 1689147920113, 285 | "price": "29000.00000000", 286 | "origQty": "10.00000000", 287 | "executedQty": "10.00000000", 288 | "cummulativeQuoteQty": "325000.00000000", 289 | "status": "FILLED", 290 | "timeInForce": "GTC", 291 | "type": "LIMIT", 292 | "side": "SELL", 293 | "workingTime": 1689147920113, 294 | "fills": [ 295 | { 296 | "matchType": "ONE_PARTY_TRADE_REPORT", 297 | "price": "35000.00000000", 298 | "qty": "5.00000000", 299 | "commission": "0.00000000", 300 | "commissionAsset": "USDT", 301 | "tradeId": -1, 302 | "allocId": 0 303 | }, 304 | { 305 | "matchType": "ONE_PARTY_TRADE_REPORT", 306 | "price": "30000.00000000", 307 | "qty": "5.00000000", 308 | "commission": "0.00000000", 309 | "commissionAsset": "USDT", 310 | "tradeId": -1, 311 | "allocId": 1 312 | } 313 | ], 314 | "workingFloor": "SOR", 315 | "selfTradePreventionMode": "NONE", 316 | "usedSor": true 317 | } 318 | ``` 319 | 320 | **Summary: The goal of SOR is to potentially access better liquidity across order books with interchangeable quote assets. Better liquidity access can fill orders more fully and at better prices during an order's taker phase.** 321 | 322 | ## What symbols support SOR? 323 | 324 | You can find the current SOR configuration in Exchange Information (`GET /api/v3/exchangeInfo` for Rest, and `exchangeInfo` on Websocket API). 325 | 326 | ```json 327 | "sors": [ 328 | { 329 | "baseAsset": "BTC", 330 | "symbols": [ 331 | "BTCUSDT", 332 | "BTCUSDC", 333 | "BTCUSDP" 334 | ] 335 | } 336 | ] 337 | ``` 338 | 339 | The `sors` field is optional. 340 | It is omitted in responses if SOR is not available. 341 | 342 | ## How do I place an order using SOR? 343 | 344 | On the Rest API, the request is `POST /api/v3/sor/order`. 345 | 346 | On the WebSocket API, the request is `sor.order.place`. 347 | 348 | ## In the API response, there's a field called `workingFloor`. What does that field mean? 349 | 350 | This is a term used to determine where the order's last activity occurred (filling, expiring, or being placed as new, etc.). 351 | 352 | If the `workingFloor` is `SOR`, this means your order interacted with other eligible order books in the SOR configuration. 353 | 354 | If the `workingFloor` is `EXCHANGE`, this means your order interacted on the order book that you sent that order to. 355 | 356 | ## In the API response, `fills` contain fields `matchType` and `allocId`. What do they mean? 357 | 358 | `matchType` field indicates a non-standard order fill. 359 | 360 | When your order is filled by SOR, you will see `matchType: ONE_PARTY_TRADE_REPORT`, indicating that you did not trade directly on the exchange (`tradeId: -1`). Instead your order is filled by _allocations_. 361 | 362 | `allocId` field identifies the allocation so that you can query it later. 363 | 364 | ## What are allocations? 365 | 366 | **An allocation** is a transfer of an asset from the exchange to your account. For example, when SOR takes liquidity from eligible order books, your order is filled by allocations. In this case you don't trade directly, but rather receive allocations from SOR corresponding to the trades made by SOR on your behalf. 367 | 368 | ```javascript 369 | [ 370 | { 371 | "symbol": "BTCUSDT", // Symbol the order was submitted to 372 | "allocationId": 0, 373 | "allocationType": "SOR", 374 | "orderId": 2, 375 | "orderListId": -1, 376 | "price": "30000.00000000", // Price of the fill 377 | "qty": "5.00000000", // Quantity of the fill 378 | "quoteQty": "150000.00000000", 379 | "commission": "0.00000000", 380 | "commissionAsset": "BTC", 381 | "time": 1688379272280, // Time the allocation occurred 382 | "isBuyer": true, 383 | "isMaker": false, 384 | "isAllocator": false 385 | } 386 | ] 387 | ``` 388 | 389 | ## How do I query orders that used SOR? 390 | 391 | You can find them the same way you query any other order. The main difference is that in the response for an order that used SOR there are two extra fields: `usedSor` and `workingFloor`. 392 | 393 | 394 | ## How do I get details of my fills for orders that used SOR? 395 | 396 | When SOR orders trade against order books other than the symbol submitted with the order, the order is filled with an **allocation** and not a trade. Orders placed with SOR can potentially have both allocations and trades. 397 | 398 | In the API response, you can review the `fills` fields. Allocations have an `allocId` and `"matchType": "ONE_PARTY_TRADE_REPORT"`, while trades will have a non-negative `tradeId`. 399 | 400 | Allocations can be queried using `GET /api/v3/myAllocations` (Rest API) or `myAllocations` (WebSocket API). 401 | 402 | Trades can be queried using `GET /api/v3/myTrades` (Rest API) or `myTrades` (WebSocket API). 403 | -------------------------------------------------------------------------------- /faqs/sor_faq_CN.md: -------------------------------------------------------------------------------- 1 | # 智能指令路由 (SOR) 2 | 3 | **声明:** 4 | 5 | * 这里使用的符号和数值是虚构的,并不意味着真实交易所中的设置。 6 | * 为简单起见,本文档中的示例不包括佣金。 7 | 8 | ## 什么是智能指令路由 (SOR)? 9 | 10 | **智能订单路由**(Smart Order Routing,简称SOR)允许客户通过使用具有相同基础资产(`base asset `)和可互换报价资产(`interchangeable quote assets`)的其他订单簿(order books)中的流动性来潜在获得更好的流动性。可互换报价资产是具有固定的1比1兑换率的报价资产,例如与同一法定货币挂钩的稳定币。 11 | 12 | 请注意,尽管报价资产(quote assets)是可互换的,但在出售基础资产(base asset)时,您将始终收到订单中交易对(symbol)对应的报价资产(quote asset)。 13 | 14 | 当您使用`SOR`下单时,它会在SOR配置的订单簿(order books)里,寻找每个订单簿的最佳价格水平,并在可能的情况下从中交易。 15 | 16 | **注意:** 如果使用SOR的订单无法根据符合条件的订单簿流动性完全成交,IOC限价单(`LIMIT IOC`)或市价单(`MARKET`)将立即过期,而GTC限价单(`LIMIT GTC`)将把剩余数量放置在您最初提交订单的订单簿(order book)上。 17 | 18 | 示例 1: 19 | 20 | 让我们考虑一个包含交易对`BTCUSDT`,`BTCUSDC`和`BTCUSDP`的SOR配置,并给出以下这些符号的卖出(`ASK`)方向的订单簿: 21 | 22 | ``` 23 | BTCUSDT quantity 3 price 30,800 24 | BTCUSDT quantity 3 price 30,500 25 | 26 | BTCUSDC quantity 1 price 30,000 27 | BTCUSDC quantity 1 price 28,000 28 | 29 | BTCUSDP quantity 1 price 35,000 30 | BTCUSDP quantity 1 price 29,000 31 | ``` 32 | 33 | 如果您以价格为31000、数量为0.5的限价挂单买入`BTCUSDT`,并且在`BTCUSDT`的订单簿中找到最佳的卖出价格为30,500 USDT,您将花费15,250 USDT 并收到0.5 BTC。 34 | 35 | 如果您通过使用SOR下达了一笔GTC限价买单(`LIMIT GTC BUY`),购买`BTCUSDT`,数量为 0.5,价格为 31000,您将与SOR涵盖的所有交易对中最佳的卖出价格相匹配,即`BTCUSDC`,价格为 28,000。您将花费 14,000 USDT(不是 USDC!),并收到 0.5 BTC。 36 | 37 | ```javascript 38 | { 39 | "symbol": "BTCUSDT", 40 | "orderId": 2, 41 | "orderListId": -1, 42 | "clientOrderId": "sBI1KM6nNtOfj5tccZSKly", 43 | "transactTime": 1689149087774, 44 | "price": "31000.00000000", 45 | "origQty": "0.50000000", 46 | "executedQty": "0.50000000", 47 | "cummulativeQuoteQty": "14000.00000000", 48 | "status": "FILLED", 49 | "timeInForce": "GTC", 50 | "type": "LIMIT", 51 | "side": "BUY", 52 | "workingTime": 1689149087774, 53 | "fills": [ 54 | { 55 | "matchType": "ONE_PARTY_TRADE_REPORT", 56 | "price": "28000.00000000", 57 | "qty": "0.50000000", 58 | "commission": "0.00000000", 59 | "commissionAsset": "BTC", 60 | "tradeId": -1, 61 | "allocId": 0 62 | } 63 | ], 64 | "workingFloor": "SOR", 65 | "selfTradePreventionMode": "NONE", 66 | "usedSor": true 67 | } 68 | ``` 69 | 70 | 示例 2: 71 | 72 | 使用示例1中同样的订单薄: 73 | 74 | ``` 75 | BTCUSDT quantity 3 price 30,800 76 | BTCUSDT quantity 3 price 30,500 77 | 78 | BTCUSDC quantity 1 price 30,000 79 | BTCUSDC quantity 1 price 28,000 80 | 81 | BTCUSDP quantity 1 price 35,000 82 | BTCUSDP quantity 1 price 29,000 83 | ``` 84 | 85 | 如果您下达一笔GTC限价买单(`LIMIT GTC BUY`)购买`BTCUSDT`,数量为 5,价格为 31,000,则: 86 | 87 | * 与 `BTCUSDT` 订单簿中价格为 30,500 USDT 的 3 个 `BTCUSDT` 成交,以 91,500 USDT 的价格购买 3 个 BTC。 88 | * 然后与 `BTCUSDT` 订单簿中价格为 30,800 USDT 的 3 个 `BTCUSDT` 成交,以 61,600 USDT 的价格购买 2 个 BTC。 89 | 90 | 总计您花费了 153,100 USDT 并获得了 5 BTC。 91 | 92 | 如果您通过使用SOR下达相同的GTC限价买单(`LIMIT GTC BUY`)购买 `BTCUSDT`,数量为 5,价格为 31,000,则: 93 | 94 | * 与 `BTCUSDC` 订单簿中价格为 28,000 的 1 个 BTCUSDC 成交,以 28,000 USDT 的价格购买 1 个 BTC。 95 | * 与 `BTCUSDP` 订单簿中价格为 29,000 的 1 个 BTCUSDP 成交,以 29,000 USDT 的价格购买 1 个 BTC。 96 | * 与 `BTCUSDC` 订单簿中价格为 30,000 的 1 个 BTCUSDC 成交,以 30,000 USDT 的价格购买 1 个 BTC。 97 | * 与 `BTCUSDT` 订单簿中价格为 30,500 的 3 个 BTCUSDT 成交,以 61,000 USDT 的价格购买 2 个 BTC。 98 | 99 | 总计您花费了 148,000 USDT 并获得了 5 BTC。 100 | 101 | ```javascript 102 | { 103 | "symbol": "BTCUSDT", 104 | "orderId": 2, 105 | "orderListId": -1, 106 | "clientOrderId": "tHonoNjWfOSaKiTygN3bfY", 107 | "transactTime": 1689146154686, 108 | "price": "31000.00000000", 109 | "origQty": "5.00000000", 110 | "executedQty": "5.00000000", 111 | "cummulativeQuoteQty": "148000.00000000", 112 | "status": "FILLED", 113 | "timeInForce": "GTC", 114 | "type": "LIMIT", 115 | "side": "BUY", 116 | "workingTime": 1689146154686, 117 | "fills": [ 118 | { 119 | "matchType": "ONE_PARTY_TRADE_REPORT", 120 | "price": "28000.00000000", 121 | "qty": "1.00000000", 122 | "commission": "0.00000000", 123 | "commissionAsset": "BTC", 124 | "tradeId": -1, 125 | "allocId": 0 126 | }, 127 | { 128 | "matchType": "ONE_PARTY_TRADE_REPORT", 129 | "price": "29000.00000000", 130 | "qty": "1.00000000", 131 | "commission": "0.00000000", 132 | "commissionAsset": "BTC", 133 | "tradeId": -1, 134 | "allocId": 1 135 | }, 136 | { 137 | "matchType": "ONE_PARTY_TRADE_REPORT", 138 | "price": "30000.00000000", 139 | "qty": "1.00000000", 140 | "commission": "0.00000000", 141 | "commissionAsset": "BTC", 142 | "tradeId": -1, 143 | "allocId": 2 144 | }, 145 | { 146 | "matchType": "ONE_PARTY_TRADE_REPORT", 147 | "price": "30500.00000000", 148 | "qty": "2.00000000", 149 | "commission": "0.00000000", 150 | "commissionAsset": "BTC", 151 | "tradeId": -1, 152 | "allocId": 3 153 | } 154 | ], 155 | "workingFloor": "SOR", 156 | "selfTradePreventionMode": "NONE", 157 | "usedSor": true 158 | } 159 | ``` 160 | 161 | 示例 3: 162 | 163 | 使用示例1和2中同样的订单薄: 164 | 165 | ``` 166 | BTCUSDT quantity 3 price 30,800 167 | BTCUSDT quantity 3 price 30,500 168 | 169 | BTCUSDC quantity 1 price 30,000 170 | BTCUSDC quantity 1 price 28,000 171 | 172 | BTCUSDP quantity 1 price 35,000 173 | BTCUSDP quantity 1 price 29,000 174 | ``` 175 | 176 | 如果您通过使用SOR下市价买单(`MARKET` `BUY`) 购买 `BTCUSDT`,数量为 11,但在所有符合条件的订单簿中总共只有 10 个BTC可供交易。一旦所有SOR配置中的订单簿都耗尽了,剩余的数量1将过期。 177 | 178 | ```javascript 179 | { 180 | "symbol": "BTCUSDT", 181 | "orderId": 2, 182 | "orderListId": -1, 183 | "clientOrderId": "jdFYWTNyzplbNvVJEzQa0o", 184 | "transactTime": 1689149513461, 185 | "price": "0.00000000", 186 | "origQty": "11.00000000", 187 | "executedQty": "10.00000000", 188 | "cummulativeQuoteQty": "305900.00000000", 189 | "status": "EXPIRED", 190 | "timeInForce": "GTC", 191 | "type": "MARKET", 192 | "side": "BUY", 193 | "workingTime": 1689149513461, 194 | "fills": [ 195 | { 196 | "matchType": "ONE_PARTY_TRADE_REPORT", 197 | "price": "28000.00000000", 198 | "qty": "1.00000000", 199 | "commission": "0.00000000", 200 | "commissionAsset": "BTC", 201 | "tradeId": -1, 202 | "allocId": 0 203 | }, 204 | { 205 | "matchType": "ONE_PARTY_TRADE_REPORT", 206 | "price": "29000.00000000", 207 | "qty": "1.00000000", 208 | "commission": "0.00000000", 209 | "commissionAsset": "BTC", 210 | "tradeId": -1, 211 | "allocId": 1 212 | }, 213 | { 214 | "matchType": "ONE_PARTY_TRADE_REPORT", 215 | "price": "30000.00000000", 216 | "qty": "1.00000000", 217 | "commission": "0.00000000", 218 | "commissionAsset": "BTC", 219 | "tradeId": -1, 220 | "allocId": 2 221 | }, 222 | { 223 | "matchType": "ONE_PARTY_TRADE_REPORT", 224 | "price": "30500.00000000", 225 | "qty": "3.00000000", 226 | "commission": "0.00000000", 227 | "commissionAsset": "BTC", 228 | "tradeId": -1, 229 | "allocId": 3 230 | }, 231 | { 232 | "matchType": "ONE_PARTY_TRADE_REPORT", 233 | "price": "30800.00000000", 234 | "qty": "3.00000000", 235 | "commission": "0.00000000", 236 | "commissionAsset": "BTC", 237 | "tradeId": -1, 238 | "allocId": 4 239 | }, 240 | { 241 | "matchType": "ONE_PARTY_TRADE_REPORT", 242 | "price": "35000.00000000", 243 | "qty": "1.00000000", 244 | "commission": "0.00000000", 245 | "commissionAsset": "BTC", 246 | "tradeId": -1, 247 | "allocId": 5 248 | } 249 | ], 250 | "workingFloor": "SOR", 251 | "selfTradePreventionMode": "NONE", 252 | "usedSor": true 253 | } 254 | ``` 255 | 256 | 示例 4: 257 | 258 | 假设有一个包含 `BTCUSDT`, `BTCUSDC` 和 `BTCUSDP` 交易对的SOR配置, 以及下面这些交易对买方(`BID`)的订单簿: 259 | 260 | ``` 261 | BTCUSDT quantity 5 price 29,500 262 | 263 | BTCUSDC quantity 5 price 35,000 264 | BTCUSDC quantity 5 price 30,000 265 | 266 | BTCUSDP quantity 5 price 28,000 267 | ``` 268 | 269 | 如果您在`BTCUSDT`下一笔GTC限价卖单(`LIMIT GTC SELL`) 订单,价格是29000, 卖出10 BTC,那么您将卖出 5 个 BTC 并获得 147,500 USDT。由于`BTCUSDT`订单簿上没有更好的价格可用,订单的剩余(未成交)数量将会以29,000的价格保持在订单簿上。 270 | 271 | 如果您通过使用SOR下GTC限价卖单(`LIMIT GTC SELL`) 卖出 `BTCUSDT`,则会: 272 | 273 | * 与 `BTCUSDC` 订单簿中价格为 35,000 的 5 个 BTCUSDC 成交,以 175,000 USDT 的价格出售 5 个 BTC。 274 | * 与 `BTCUSDC` 订单簿中价格为 30,000 的 5 个 BTCUSDC 成交,以 150,000 USDT 的价格出售 5 个 BTC。 275 | 276 | 总计您卖出 10 个 BTC 并获得 325,000 USDT。 277 | 278 | ```javascript 279 | { 280 | "symbol": "BTCUSDT", 281 | "orderId": 1, 282 | "orderListId": -1, 283 | "clientOrderId": "W1iXSng1fS77dvanQJDGA5", 284 | "transactTime": 1689147920113, 285 | "price": "29000.00000000", 286 | "origQty": "10.00000000", 287 | "executedQty": "10.00000000", 288 | "cummulativeQuoteQty": "325000.00000000", 289 | "status": "FILLED", 290 | "timeInForce": "GTC", 291 | "type": "LIMIT", 292 | "side": "SELL", 293 | "workingTime": 1689147920113, 294 | "fills": [ 295 | { 296 | "matchType": "ONE_PARTY_TRADE_REPORT", 297 | "price": "35000.00000000", 298 | "qty": "5.00000000", 299 | "commission": "0.00000000", 300 | "commissionAsset": "USDT", 301 | "tradeId": -1, 302 | "allocId": 0 303 | }, 304 | { 305 | "matchType": "ONE_PARTY_TRADE_REPORT", 306 | "price": "30000.00000000", 307 | "qty": "5.00000000", 308 | "commission": "0.00000000", 309 | "commissionAsset": "USDT", 310 | "tradeId": -1, 311 | "allocId": 1 312 | } 313 | ], 314 | "workingFloor": "SOR", 315 | "selfTradePreventionMode": "NONE", 316 | "usedSor": true 317 | } 318 | ``` 319 | 320 | **概要:SOR的目标是潜在地在具有可互换报价资产(`interchangeable quote assets`)的订单簿之间获得更好的流动性。更好的流动性可以使订单以更好的价格,并更充分成交。** 321 | 322 | ## 什么交易对支持SOR? 323 | 324 | 当前SOR配置可以在交易所信息接口查询(Restful接口`GET /api/v3/exchangeInfo`, Websocket API的 `exchangeInfo`). 325 | 326 | ```json 327 | "sors": [ 328 | { 329 | "baseAsset": "BTC", 330 | "symbols": [ 331 | "BTCUSDT", 332 | "BTCUSDC", 333 | "BTCUSDP" 334 | ] 335 | } 336 | ] 337 | ``` 338 | 339 | `sors` 字段是可选的。 340 | 如果 SOR 不可用, 该字段在响应中会被忽略。 341 | 342 | ## 如何下SOR订单? 343 | 344 | 通过Rest API接口 `POST /api/v3/sor/order`. 345 | 346 | 通过WebSocket API接口 `sor.order.place`. 347 | 348 | ## 在API响应里, 有个字段workingFloor是什么意思? 349 | 350 | 这是一个用于确定订单的最后更新操作(成交、过期或作为新订单下达等)的术语。 351 | 352 | 如果 workingFloor 是 SOR,这表示您的订单与SOR配置中的其他符合条件的订单簿进行了交互。 353 | 354 | 如果 workingFloor 是 EXCHANGE,这表示您的订单在您发送该订单的订单簿上进行了交互。 355 | 356 | ## 如果查询订单是否使用过SOR? 357 | 358 | 您可以像查询任何其他订单一样来查询。主要的区别是对于使用SOR的订单,在响应中会有两个额外的字段:`usedSor` 和 `workingFloor`。 359 | 360 | ## 什么是资产分配? 361 | 362 | **资产分配**是从交易所转移资产到您的账户。例如,当SOR从符合条件的订单簿中获取流动性时,您的订单将通过资产分配来填充。在这种情况下,您不直接进行交易,而是通过SOR代表您进行交易,并接收对应于SOR为您进行的交易的资产分配。 363 | 364 | ```javascript 365 | [ 366 | { 367 | "symbol": "BTCUSDT", // Symbol the order was submitted to 368 | "allocationId": 0, 369 | "allocationType": "SOR", 370 | "orderId": 2, 371 | "orderListId": -1, 372 | "price": "30000.00000000", // Price of the fill 373 | "qty": "5.00000000", // Quantity of the fill 374 | "quoteQty": "150000.00000000", 375 | "commission": "0.00000000", 376 | "commissionAsset": "BTC", 377 | "time": 1688379272280, // Time the allocation occurred 378 | "isBuyer": true, 379 | "isMaker": false, 380 | "isAllocator": false 381 | } 382 | ] 383 | ```` 384 | 385 | ## 如何获取使用SOR的订单成交细节? 386 | 387 | 当SOR订单与非提交订单的订单簿进行交易时,订单将通过资产分配(allocation)而不是交易(trade)来成交。使用SOR下达的订单可能同时拥有资产分配和交易。 388 | 389 | 在API响应中,您可以查看`fills`字段。资产分配具有`allocId`和`matchType`: "ONE_PARTY_TRADE_REPORT",而交易将具有非负的`tradeId`。 390 | 391 | 您可以使用以下方式查询资产分配和交易: 392 | 393 | 查询资产分配:使用Rest API接口 `GET /api/v3/myAllocations` 或 WebSocket API 的 `myAllocations`。 394 | 395 | 查询交易:使用Rest API接口 `GET /api/v3/myTrades` 或 WebSocket API 的 `myTrades`。 396 | 397 | ## 什么交易对支持SOR? 398 | 399 | 当前SOR配置可以在交易所信息接口查询(Rest API接口`GET /api/v3/exchangeInfo`, WebSocket API的 `exchangeInfo`). 400 | 401 | ```json 402 | "sors": [ 403 | { 404 | "baseAsset": "BTC", 405 | "symbols": [ 406 | "BTCUSDT", 407 | "BTCUSDC", 408 | "BTCUSDP" 409 | ] 410 | } 411 | ] 412 | ``` 413 | 414 | 415 | -------------------------------------------------------------------------------- /faqs/spot_glossary_CN.md: -------------------------------------------------------------------------------- 1 | # 现货交易API术语表 2 | 3 | **声明:** 此术语表只适用现货交易(`SPOT`);用于合约、期权或者其他币安API相应的术语可能有不一样的表达。 4 | 5 | ### A 6 | 7 | `ACK` 8 | * `newOrderRespType` 的枚举值,设置时下单的返回值只包括下面的字段: `symbol`,`orderId`,`orderListId`,`clientOrderId` 和 `transactTime`。 9 | 10 | `aggTrade` 11 | * 归集交易信息;此交易信息归集了在同一个时间同一个 `taker` 的订单生成的相同价格的交易信息。 12 | 13 | allocation 14 | * 在这里,分配指的是将资产从交易所转移到个人账户的过程(e.g. 当一个订单通过 SOR 成交而不是直接交易)。 15 | 16 | `allocationId` 17 | * 此字段是一个唯一识别码,用来标识针对某个交易对上进行的分配(allocation)。 18 | 19 | `allocationType` 20 | * 参考 [ 分配类型 ](../enums_CN.md#allocationtype) 21 | 22 | `askPrice` 23 | * `ticker` 请求返回的来自“卖"方的最低价格。 24 | 25 | `askQty` 26 | * `ticker` 请求返回的“卖"方以最低价格提供的总数量。 27 | 28 | `asks` 29 | * 卖单 30 | 31 | `avgPrice` 32 | * 表示相应 N 分钟之内的平均价格。 33 | 34 | --- 35 | 36 | ### B 37 | 38 | `baseAsset` 39 | * 基准资产;指代交易对中的第一个资产(比如 `BTCUSDT` 中的 `BTC`),表示被出售或者买进的资产。 40 | 41 | `baseAssetPrecision` 42 | * 基准资产精度;Exchange Information 响应中的一个字段,代表了基准资产(`baseAsset`)可以允许的最多小数位数。 43 | 44 | `baseCommissionPrecision` 45 | * Exchange Information 响应中用来表示基准资产手续费可以允许的最多小数位数。 46 | 47 | `bidPrice` 48 | * `ticker` 请求返回的来自“买"方的最高价格。 49 | 50 | `bidQty` 51 | * `ticker` 请求返回的“买"方以最高价格提供的总数量。 52 | 53 | `bids` 54 | * 买单。 55 | 56 | `BREAK` 57 | * 交易对的一个交易状态,用来表示某交易对无法交易。处于此状态的交易对无法产生市场行情数据。 58 | 59 | `BUY` 60 | * `side` 的一个枚举值,用来表示用户期望购买一个资产(比如 `BTC`)。 61 | 62 | --- 63 | 64 | ### C 65 | 66 | `CANCELED` 67 | * 订单的一个状态,用来表示订单被用户取消。 68 | 69 | `cancelReplaceMode` 70 | * 撤消挂单再下单接口的一个参数,用来定义如果取消订单的请求失败之后,是否继续下新的订单。 71 | 72 | `clientOrderId` 73 | * 用于下单请求,用户可以用此字段来设置自定义值,便于用来跟踪订单。 74 | 75 | `commission` 76 | * 交易费 77 | 78 | `commissionAsset` 79 | * 用于计算交易费的资产。 80 | 81 | Counter Order Id 82 | * 用户数据流 execution reports 中的一个字段,用来表示被阻止的撮合交易事务中的对手方订单。 83 | 84 | Counter Symbol 85 | * 用户数据流 execution reports 中的一个字段,用来表示被阻止的撮合交易事务中的对手方订单所使用的交易对。 86 | 87 | `cummulativeQuoteQty` 88 | * 订单的成交交易记录里面所有价格(`price`)乘以数量(`qty`)的和。 89 | 90 | --- 91 | 92 | ### D 93 | 94 | Data Source 95 | * 发送请求后得到数据的地方,比如数据库,缓存等。 96 | 97 | --- 98 | 99 | ### E 100 | 101 | `executedQty` 102 | * 订单中成交的数量。 103 | 104 | `EXPIRED` 105 | * 订单的一个状态,用来表示订单因为交易规则而取消,也可能是直接被交易所取消。 106 | 107 | `EXPIRED_IN_MATCH` 108 | * 订单的一个状态,用来表示订单由于 STP 而过期 (e.g. 带有 `EXPIRE_TAKER` 的订单与订单簿上属于同账户或同 `tradeGroupId` 的订单撮合)。 109 | 110 | --- 111 | 112 | ### F 113 | 114 | `filters` 115 | * 过滤器;用于定义交易规则。 116 | 117 | `FOK`/ Fill or Kill 118 | * `timeInForce` 的枚举值,用于下单时要求订单全部成交,不然就取消。 119 | 120 | `free` 121 | * 用户的可用余额,可以用来交易或者提取的金额。 122 | 123 | `FULL` 124 | * `newOrderRespType` 的枚举值,设置在下单接口时,请求会返回所有的交易信息,包括了成交记录(`fills`)。 125 | 126 | --- 127 | 128 | ### G 129 | 130 | `GTC`/ Good Til Canceled 131 | * `timeInForce` 的枚举值,表示订单会一直有效,直到全部成交或者被取消。 132 | 133 | --- 134 | 135 | ### H 136 | 137 | `HALT` 138 | * 交易对的一个交易状态,可以用来表示交易处于紧急暂停状态。此时市场信息还会生成。 139 | 140 | --- 141 | 142 | ### I 143 | 144 | `intervalNum` 145 | * 表示间隔时间,例如如果 `interval` 的值是 `SECOND`,并且 `intervalNum` 是 5,那么表示为每5秒钟间隔。 146 | 147 | `IOC` / Immediate or Canceled 148 | * `timeInForce` 的枚举值,表示订单会尽量的成交,而不能成交的部分则会被交易所取消。 149 | 150 | `isBestMatch` 151 | * 表示交易的价格是不是当时的最优价。 152 | 153 | `isBuyerMaker` 154 | * 表示交易双方的买家是否是市场的做市商(`Maker`)。 155 | 156 | `isWorking` 157 | * 表示订单是否出现在订单薄上。 158 | 159 | --- 160 | 161 | ### K 162 | 163 | `kline` 164 | * K线;包括了一定时期内的开盘价,收盘价,最高价,最低价,交易量,以及其他的市场数据。通常也被成为蜡烛图。 165 | 166 | --- 167 | 168 | ### L 169 | 170 | Last Prevented Quantity 171 | * 最后被阻止交易的数量。这仅在订单因 STP 触发而过期时可见。 172 | 173 | `lastPrice` 174 | * 最新一笔交易的成交价格。 175 | 176 | `lastQty` 177 | * 以 'lastPrice' 交易的总数量。 178 | 179 | `LIMIT` 180 | * 限价;一种订单形式,其订单的成交价格会是指定价格,或者更好的价格。 181 | 182 | `LIMIT_MAKER` 183 | * 一种订单形式,其订单会保证成为做市订单(`MAKER`),不会立刻成交进而成为`TAKER`。 184 | 185 | `limitClientOrderId` 186 | * OCO 订单下单接口的一个参数,方便用户自定义ID来标记 OCO 里的 `LIMIT_MAKER` 订单。 187 | 188 | `listClientOrderId` 189 | * OCO 订单下单接口的一个参数,方便用户自定义ID来标记 OCO 订单。 190 | 191 | `listenKey` 192 | * 系统提供的一个 Key,以方便用户来获取 WebSocket 中的用户相关信息。 193 | 194 | `locked` 195 | * 表示用户的某个资产余额中当前锁定在挂单或者被其他系统占用的数量。 196 | 197 | --- 198 | 199 | ### M 200 | 201 | `MARKET` 202 | * 一个订单的类型;其订单会在系统中尽可能的全部成交,除非市场没有流动性,无法成交部分会被交易取消。 203 | 204 | Matching Engine 205 | * 在数据源(`Data Source`)的部分指代的是请求获得数据的地方。 206 | * 也可以指代的是处理所有请求,撮合所有订单的后台系统。 207 | 208 | Match Type 209 | * 订单响应或 execution reports 中的一个字段,用来表示该订单是否通过 [智能指令路由 (SOR)](./sor_faq_CN.md) 成交。 210 | 211 | Memory 212 | * 数据源(`Data Source`)中指代数据存储在系统内部的缓冲。 213 | 214 | --- 215 | 216 | ### N 217 | 218 | `NEW` 219 | * 一个订单的状态,表示订单成功被发送到了交易引擎。 220 | 221 | `newClientOrderId` 222 | * 一个订单相关(下单,撤销订单等)请求中的参数;在请求的返回的时候,此值会被设置为 `clientOrderId`。 223 | 224 | Notional value 225 | * 订单的名义价值,值为 `price` * `qty`。 226 | 227 | --- 228 | 229 | ### O 230 | 231 | `OCO` 232 | 233 | * 二选一订单(`One-Cancels-the-Other`);订单支持用户同时提交一系列订单,比如现价单(`LIMIT_MAKER`)和止盈止损订单(`STOP_LOSS` or `STOP_LOSS_LIMIT`)。 当执行其中一个订单时,另一个订单将自动取消。 234 | 235 | Order Book 236 | * 订单薄;包括了当前市场上买卖挂单。 237 | 238 | 239 | Order List 240 | * 订单列表;将多个订单组合为一个单元。请参考 `OCO` 与/或 `OTO` 241 | 242 | `orderId` 243 | * 订单数据里用来唯一标识的ID。 244 | 245 | `origQty` 246 | * 发送订单请求中的原始数量。 247 | 248 | `origClientOrderId` 249 | * 在查询或者取消订单请求中,用户设置在 `clientOrderId` 的值。 250 | 251 | `OTO` 252 | * 一个订单触发另一个订单(`One-Triggers-the-Other`);这个订单列表含有一个生效订单和一个待处理订单。 253 | * 当生效订单完全成交时,待处理订单才会被自动下单。 254 | 255 | `OTOCO` 256 | * 由一个订单触发另一个二选一订单(`One-Triggers-a-One-Cancels-the-Other`);这个订单列表含有一个生效订单和一个待处理的 OCO 订单。 257 | * 当生效订单完全成交时,待处理订单才会被自动下单。 258 | 259 | --- 260 | 261 | ### P 262 | 263 | `PARTIALLY_FILLED` 264 | * 订单的一种状态,表示订单被部分成交。 265 | 266 | Pending order 267 | * 订单列表中的订单,仅在相应的生效订单完全成交时才会被放在订单簿上。 268 | * 每个订单列表可以包含一个待处理订单,也可以包含2个可组成 `OCO` 的待处理订单。 269 | * 在单一订单的情况下,几乎支持任何订单类型,但不包括使用 `quoteOrderQty` 的 `MARKET` 的订单。 270 | 271 | `PENDING_NEW` 272 | * 订单 `status`;表示引擎已接受订单列表的待处理订单,但是待处理订单并没有被放到订单簿上。 273 | 274 | Prevented execution price 275 | * 用户数据流 execution reports 中的一个字段,用来表示被阻止的自我交易中的价格。参阅 [自我交易预防 (Self Trade Prevention - STP) 常见问题](stp_faq_CN.md)。 276 | 277 | Prevented execution quantity 278 | * 用户数据流 execution reports 中的一个字段,用来表示被阻止的自我交易中的订单量。参阅 [自我交易预防 (Self Trade Prevention - STP) 常见问题](stp_faq_CN.md)。 279 | 280 | Prevented execution quote quantity 281 | * 用户数据流 execution reports 中的一个字段,用来表示被阻止的自我交易中的报价订单量。参阅 [自我交易预防 (Self Trade Prevention - STP) 常见问题](stp_faq_CN.md)。 282 | 283 | `preventedQuantity` 284 | * 因为 STP 导致订单失效的数量。 285 | 286 | `preventedMatchId` 287 | * 与 `symbol` 结合使用时,可用于查询因为 STP 导致订单失效的过期订单。 288 | 289 | --- 290 | 291 | ### Q 292 | 293 | `quantity` 294 | * 订单量;买卖订单时候基本资产(`base asset`)的数量。 295 | 296 | `quoteAsset` 297 | * 定价资产;在交易对中的第二个资产,比如交易对 `BTCUSDT` 中的 `USDT`。 298 | 299 | `quoteAssetPrecision` 300 | * Exchange Information 响应中用来指明 `quoteAsset` 允许的最多小数位数。 301 | 302 | `quoteCommissionPrecision` 303 | * Exchange Information 响应中用来指明交易费用是 `quoteAsset` 允许的最多小数位数。 304 | 305 | `quoteOrderQty` 306 | * 市价单(`MARKET`)的下单接口中用于下反向市价单中的数量。 307 | 308 | `quoteQty` 309 | * 名义价值;为订单中数量(`qty`)乘以价格(`price`)。 310 | 311 | --- 312 | 313 | ### R 314 | 315 | `recvWindow` 316 | * API中的一个参数,值为毫秒;用以设定请求从 `timestamp` 开始的有效期。 317 | 318 | `RESULT` 319 | * `newOrderRespType` 的一个枚举值。用于下单的接口,会返回除了成交部分(`fills`)的所有值。 320 | 321 | Reverse `MARKET` order 322 | * 反向市价单;下市价单的时候使用 `quoteOrderQty`,而不是 `quantity`。 323 | 324 | --- 325 | 326 | ### S 327 | 328 | Self Trade Prevention (STP) 329 | * 自我交易预防;此功能能阻止订单与来自同一账户或者同一 `tradeGroupId` 下的账户的订单撮合交易。请阅读 [自我交易预防 (Self Trade Prevention - STP) 常见问题](./stp_faq_CN.md) 来了解更多详情。 330 | 331 | `selfTradePreventionMode` 332 | * 如果发生自我交易情况,此参数用来通知系统如何处理订单。 333 | 334 | `SELL` 335 | * 方向(`side`)的一个枚举值,用于用户希望卖出某一资产。 336 | 337 | Smart Order Routing (SOR) 338 | * 智能订单路由;使用可互换的定价资产(`quote asset`)来提高流动性。请阅读 [SOR 常见问题](./sor_faq_CN.md) 来了解更多详情。 339 | 340 | `SPOT` 341 | * 现货交易; 此种交易时候,买卖相应的资产会立刻到账。 342 | 343 | `stopClientOrderId` 344 | * 用于下OCO订单的接口;此ID可以用来标识OCO中 `STOP_LOSS` 或 `STOP_LOSS_LIMIT` 的订单。 345 | 346 | `stopPrice` 347 | * 用于设置逻辑订单(比如 `STOP_LOSS`, `TAKE_PROFIT`)中的触发价;此价格被触发后,订单会被放置到订单薄里面(`OrderBook`)。 348 | * 用于设置追踪止盈止损订单中的触发价;此价格被触发后,订单会被开始追踪。 349 | 350 | `STOP_LOSS` 351 | * 止损单;一种逻辑订单,市场价格达到 `stopPrice` 的时候,此订单会以市价单(`MARKET`)的形式执行。 352 | 353 | `STOP_LOSS_LIMIT` 354 | * 限价止损单;一种逻辑订单,市场价格达到 `stopPrice` 的时候,此订单会以限价单(`LIMIT`)的形式执行。 355 | 356 | `strategyId` 357 | * 策略单ID;用以关联此订单对应的交易策略。 358 | 359 | `strategyType` 360 | * 策略单类型;用以显示此订单对应的交易策略。 361 | 362 | `symbol` 363 | * 交易对;由交易对象(`base asset`)和定价资产(`quote asset`)组成。 364 | 365 | --- 366 | 367 | ### T 368 | 369 | `TAKE_PROFIT` 370 | * 止盈订单;当市场价格触及 `stopPrice` 价,此订单会以市价单(`MARKET`)被执行。 371 | 372 | `TAKE_PROFIT_LIMIT` 373 | * 限价止盈订单;当市场价格触及 `stopPrice` 价,此订单会以限价单(`LIMIT`)被执行。 374 | 375 | `ticker` 376 | * 用以汇报过去一段时间内的价格变动等市场信息。 377 | 378 | `time` 379 | * 对于交易/分配查询:交易/分配执行的时间。 380 | * 订单查询:订单创建时间。 381 | 382 | `timeInForce` 383 | * 定义订单的时效性,用以表明订单会在 orderbook 中的时长。 384 | * 支持的值包括了:`GTC`,`IOC` 和 `FOK`。 385 | 386 | `tradeGroupId` 387 | * 属于同一个交易组的账户组。 388 | 389 | `TRADING` 390 | * 一种交易状态,表明某交易对可以进行交易。 391 | 392 | `trailingDelta` 393 | * 用以定义追踪止盈止损订单被触发的价格差。 394 | 395 | `trailingTime` 396 | * 追踪单被激活和跟踪价格变化的时间。 397 | 398 | `transactTime` 399 | * 订单的更新时间:下单,成交或者取消。默认情况下,此字段(以及所有与时间戳相关的字段)在 JSON 响应中单位是毫秒。 400 | 401 | --- 402 | 403 | ### U 404 | 405 | `uiKlines` 406 | * 为了前端展示而优化的K线。 407 | 408 | `updateTime` 409 | * 订单的上次更新时间。默认情况下,此字段(以及所有与时间戳相关的字段)在 JSON 响应中单位是毫秒。 410 | 411 | User Data Stream 412 | * 通过 WebSocket 推送及时的个人用户信息,包括了账户余额的变动,订单的更新等。请阅读 [WebSocket 账户接口](../user-data-stream_CN.md) 来了解更多详情。 413 | 414 | `usedSor` 415 | * 用以标识该订单是否是通过 [智能指令路由 (SOR)](sor_faq_CN.md) 提交的。 416 | 417 | --- 418 | 419 | ### W 420 | 421 | `weightedAveragePrice` 422 | * 成交量加权平均价;将过去N分钟内所有交易的价格按各自的成交量加权而算出的平均价。 423 | 424 | `workingFloor` 425 | * 工作平台;该字段用于定义订单是通过 SOR 还是由订单提交到的订单薄(order book)成交的。 426 | 427 | Working order 428 | * 订单列表中的订单,该订单会立即放置在订单簿上。当此订单完全成交时,一个或多个待处理订单的自动下单会被触发。 429 | * 一个隶属于订单列表的订单,只能是单个 `LIMIT` 或 `LIMIT_MAKER` 类型的订单。 430 | 431 | `workingTime` 432 | * 指示订单何时添加到了 order book。 433 | --- 434 | 435 | ### X 436 | 437 | `X-MBX-ORDER-COUNT-XX` 438 | * 请求的返回 Header 里面一个自定义值,用来表明当前用户下单限制额的所剩额度。 439 | 440 | `X-MBX-USED-WEIGHT-XX` 441 | * 请求的返回 Header 里面一个自定义值,用来表明当前 IP 在一定时间内所剩的请求额度。 442 | -------------------------------------------------------------------------------- /faqs/trailing-stop-faq_CN.md: -------------------------------------------------------------------------------- 1 | # 追踪止盈止损(Trailing Stop)订单常见问题 2 | 3 | ## 什么是追踪止盈止损订单? 4 | 5 | 追踪止盈止损是一种用于追踪市场价格变动的工具. 现货的API中多了一个新参数 `trailingDelta`, 用来定义订单触发时机, 其值为基点(BIPS). 6 | 7 | 显然追踪止盈止损订单允许价格在有利的方向变动,同时限制在不利方向上的价格变动. 8 | 9 | 买单: _价格低_ 是有利的. 持续的价格 _下跌_ 是被允许的. 但是如果市场价格基于下单后的最低点 _上涨_ 了预定义的价格差, 订单会被触发. 10 | 11 | 卖单: _价格高_ 是有利的. 持续的价格 _上涨_ 是被允许的. 但是如果市场价格基于下单后的最高点 _下跌_ 了预定义的价格差, 订单会被触发. 12 | 13 | ## 什么是基点(BIPs)? 14 | 15 | 基点,又称为bps或bips,是金融学中用来描述百分比变化. 16 | 17 | 基点数 | 百分比 | 小数形式 18 | ---- | ---------- | ---------- 19 | 1 | 0.01% | 0.0001 20 | 10 | 0.1% | 0.001 21 | 100 | 1% | 0.01 22 | 1000 | 10% | 0.1 23 | 24 | 比如, 一个设置`trailingDelta=100`的止损(STOP_LOSS)卖单,则会构成一个追踪止损卖单, 此订单在提交后会跟踪价格变动,当价格从提交后的最高价下跌`1%`的时候会被触发为市价单卖掉. 25 | 26 | ## 什么样的订单可以成追踪止盈止损单? 27 | 28 | `STOP_LOSS`, `STOP_LOSS_LIMIT`, `TAKE_PROFIT`, 和 `TAKE_PROFIT_LIMIT` 支持追踪止盈止损功能. 29 | 30 | 限价止盈止损单订单(OCO)在其止盈止损单中支持追踪止盈止损功能. 如果追踪止盈止损被触发,其中的限价单(LIMIT)会被取消. 31 | 32 | ## 如果下追踪止盈止损订单? 33 | 34 | 追踪止盈止损订单的使用和`STOP_LOSS`, `STOP_LOSS_LIMIT`, `TAKE_PROFIT`, 或者 `TAKE_PROFIT_LIMIT` 订单很类似,但是多了一个`trailingDelta`参数. 此参数必须在交易对的`TRAILING_DELTA`过滤器定义范围内. 具体值可以参见接口 `GET /api/v3/exchangeInfo`. 35 | 36 | 不同于一般的止盈止损单,追踪止盈止损订单中的`stopPrice`是可选的. 如果`stopPrice`被设置了,那么订单只有当这个`stopPrice`价格被触发了后,才开始追踪价格变动.如果`stopPrice`被忽略,则会立刻开始追踪价格变化. 37 | 38 | ## 什么样的价格变动会触发追踪止盈止损订单? 39 | 40 | 追踪的订单类型 | 方向 | 止盈止损价(Stop price)条件 | 触发所需的价格变动 41 | ------------------- | ---- | -------------------------- | ---------------------------------- 42 | `TAKE_PROFIT` | 卖出 | 市场价 >= 止盈价 | 从最高价*回调* 43 | `TAKE_PROFIT_LIMIT` | 卖出 | 市场价 >= 止盈价 | 从最高价*回调* 44 | `STOP_LOSS` | 卖出 | 市场价 <= 止损价 | 从最高价*回调* 45 | `STOP_LOSS_LIMIT` | 卖出 | 市场价 <= 止损价 | 从最高价*回调* 46 | `STOP_LOSS` | 买入 | 市场价 >= 止损价 | 从最低价*上涨* 47 | `STOP_LOSS_LIMIT` | 买入 | 市场价 >= 止损价 | 从最低价*上涨* 48 | `TAKE_PROFIT` | 买入 | 市场价 <= 止盈价 | 从最低价*上涨* 49 | `TAKE_PROFIT_LIMIT` | 买入 | 市场价 <= 止盈价 | 从最低价*上涨* 50 | 51 | ## 如果使用 `TRAILING_DELTA` 过滤器? 52 | 53 | 对于 `STOP_LOSS` 买单, `STOP_LOSS_LIMIT` 买单, `TAKE_PROFIT` 卖单, 和 `TAKE_PROFIT_LIMIT` 卖单: 54 | 55 | * `trailingDelta` >= `minTrailingAboveDelta` 56 | * `trailingDelta` <= `maxTrailingAboveDelta` 57 | 58 | 对于 `STOP_LOSS` 卖单, `STOP_LOSS_LIMIT` 卖单, `TAKE_PROFIT` 买单, 和 `TAKE_PROFIT_LIMIT` 买单: 59 | 60 | * `trailingDelta` >= `minTrailingBelowDelta` 61 | * `trailingDelta` <= `maxTrailingBelowDelta` 62 | 63 | ## 追踪止盈止损订单用例 64 | 65 | ### 用例 A - 追踪止损限价买单 66 | 67 | 在 `12:01:00` 的时候,市场最新价为40,000. 这时候有一个限价止损买单(`STOP_LOSS_LIMIT`)进入交易所, 并且设置了止损价(`stopPrice`)为44,000, `trailingDelta`为500 (5%), 以及限价(`LIMIT`) 45,000. 68 | 69 | 在 `12:01:00` 到 `12:02:00` 之间市场上一系列的交易让最新价下跌到37,000. 到这里价格下跌了7.5%(750 BIPS), 超过了设置价格差值(`trailingDelta`). 但是因为还没有开始追踪市场, 所以价格变动被忽略. 70 | 71 | 在 `12:02:00` 到 `12:03:00` 之间市场上一系列的交易让价格开始上涨. 当一个交易(trade)价格等于,或者超过了止损价(`stopPrice`)(44,000),这时候订单立刻开始追踪价格变动. 满足条件的第一个交易会被看作"最低价", 在这个例子里就是44,000. 如果价格从44,000上涨了500个基点, 订单就会被触发. 72 | 这时候市场持续交易, 并将最新价推高到45,000. 73 | 74 | 在 `12:03:00` 到 `12:04:00` 之间市场的交易让最新价上涨到46,000. 这时价格已经从之前标记的最低价(44,000)上涨了大约454个基点, 但是还不到触发订单的要求(500个基点). 75 | 76 | 在 `12:04:00` 到 `12:05:00` 之间市场上一系列的交易让最新价开始下跌到42,000. 这是从之前的标记的最低价开始的下跌, 最低价被标记为当前价(42,000). 如果市场从这里上涨500个基点, 订单会被触发. 77 | 78 | 在 `12:05:00` 到 `12:05:30` 之间市场交易让最新价上涨到44,100. 最新的交易价格到达或者超过了订单设置的500个基点要求(`44,100 = 42,000 * 1.05`). 这导致了订单被触发, 然后被以限价45,000的价格放到订单薄(order book)里面. 79 | 80 | image 81 | 82 | ### 用例 B - 追踪止损限价卖单 83 | 84 | 在 `12:01:00` 的时候, 市场最新价为40,000. 这时候有一个限价止损卖单(`STOP_LOSS_LIMIT`)进入交易所, 并且设置了止损价(`stopPrice`)为39,000, `trailingDelta`为1,000 (10%), 以及限价(LIMIT) 38,000. 85 | 86 | 在 `12:01:00` 到 `12:02:00` 之间市场上一系列的交易让最新价上涨到41,500. 87 | 88 | 在 `12:02:00` 到 `12:03:00` 之间市场的交易让价格开始下跌. 当一个交易(trade)价格等于, 或者低于了止损价(`stopPrice`)(39,000), 这时候订单立刻开始追踪价格变动. 满足条件的第一个交易会被看作"最高价", 在这个例子里就是39,000. 如果价格从39,000下跌了1,000个基点, 订单就会被触发. 89 | 90 | 在 `12:03:00` 到 `12:04:00` 之间市场上一系列的交易让最新价开始下跌到37,000. 这时价格已经从之前标记的最高价(39,000)回落了大约512个基点, 但是还不到触发订单的要求(1000个基点). 91 | 92 | 在 `12:04:00` 到 `12:05:00` 之间市场上一系列的交易让最新价开始上涨到41,000. 这是从之前的标记的最高价开始的上涨, 最高价被标记为当前价(41,000). 如果这时候有1000个基点下跌, 订单会被触发. 93 | 94 | 在 `12:05:00` 到 `12:05:30` 之间的一些市场交易让最新价下跌到36,900. 最新的交易价格到达或者超过了订单设置的1000个基点要求(`36,900 = 41,000 * 0.90`). 这导致了订单被触发, 然后被以限价38,000的价格放到订单薄(order book)里面. 95 | 96 | image 97 | 98 | ### 用例 C - 追踪止盈限价买单 99 | 100 | 在 `12:01:00` 的时候, 市场最新价为40,000. 这时候有一个限价止盈买单(`TAKE_PROFIT_LIMIT`)进入交易所, 并且设置了止盈价(`stopPrice`)为38,000, `trailingDelta`为 850 (8.5%), 以及限价(LIMIT) 38,500. 101 | 102 | 在 `12:01:00` 到 `12:02:00` 之间市场上一系列的交易让最新价上涨到42,000. 103 | 104 | 在 `12:02:00` 到 `12:03:00` 之间市场交易让价格开始下跌. 当一个交易(trade)价格等于, 或者超过了止盈价(`stopPrice`)(38,000), 这时候订单立刻开始追踪价格变动. 满足条件的第一个交易会被看作"最低价", 在这个例子里就是38,000. 105 | 市场的持续交易,让最新价下跌到37,000. 这时最低价被设为37,000. 如果价格从37,000上涨了850个基点, 订单就会被触发. 106 | 107 | 在 `12:03:00` 到 `12:04:00` 之间市场上一系列的交易让最新价开始上涨到39,000. 这时价格已经从之前标记的最低价(37,000)上涨了大约540个基点, 但是还不到触发订单的要求(850个基点). 108 | 109 | 在 `12:04:00` 到 `12:05:00` 之间市场上一系列的交易让最新价开始下跌到38,000, 没有低于之前的最低价, 所以不会有任何变化. 110 | 111 | 在 `12:05:00` 到 `12:05:30` 之间的一些市场交易让最新价上涨到40,145. 最新的交易价格到达或者超过了订单设置的850个基点要求(`40,145 = 37,000 * 1.085`). 这导致了订单被触发, 然后被以限价38,500的价格放到订单薄(order book)里面. 112 | 113 | image 114 | 115 | ### 用例 D - 追踪止盈限价卖单 116 | 117 | 在 `12:01:00` 的时候,市场最新价为40,000. 这时候有一个限价止盈卖单(`TAKE_PROFIT_LIMIT`)进入交易所, 并且设置了止盈价(`stopPrice`)为42,000, `trailingDelta`为 750 (7.5%), 以及限价(LIMIT) 41,000. 118 | 119 | 在 `12:01:00` 到 `12:02:00` 之间市场上一系列的交易让最新价上涨到41,500. 120 | 121 | 在 `12:02:00` 到 `12:03:00` 之间市场上一系列的交易让价格开始下跌到39,000. 122 | 123 | 在 `12:03:00` 到 `12:04:00` 之间市场上一系列的交易让最新价开始上涨. 124 | 当最新的交易价格到达或者超过了订单设置的止盈价(`stopPrice`),订单就会立刻开始追踪. 第一个满足条件的交易价就被设为"最高价". 在这个例子中, 最高价是42,000. 如果从最高价下跌750个基点, 订单就会被触发. 125 | 126 | 这时市场价格持续上涨,最新价到了45,000. 追踪止盈订单的"最高价"也被设置成了45,000. 如果价格从这里下跌750个基点, 订单会被触发. 127 | 128 | 在 `12:04:00` 到 `12:05:00` 之间市场上一系列的交易让最新价开始下跌到44,000. 这相当于从之前的最高价(45,000)下跌了大约222个基点, 不过没有达到追踪止盈订单设置的750个基点要求, 所以不会触发. 129 | 130 | 在 `12:05:00` 到 `12:06:00` 之间的一些市场交易让最新价上涨到46,500. 因为市场上涨,之前的最高价被设置成当前价(46,500). 如果价格从这里下跌750个基点, 订单会被触发. 131 | 132 | 在 `12:06:00` 到 `12:06:50` 之间的一些市场交易让最新价下跌到43,012.5. 当前价格达到或者超过了追踪订单设定的750个基点(`43,012.5 = 46,500 * 0.925`), 导致订单被触发, 以限价(LIMIT)41,000的价格被放入订单薄. 133 | 134 | image 135 | 136 | ### 用例 E - 不设置限价的追踪止盈止损订单 137 | 138 | 在 `12:01:00` 的时候, 市场最新价为40,000. 这时候有一个限价止损卖单(`STOP_LOSS_LIMIT`)进入交易所, 并且设置了`trailingDelta`为 700 (7%), 以及限价(LIMIT) 39,000, 但是没有设置限价(`stopPrice`). 订单创建后就开始追踪价格. 如果价格从40,000下跌了700个基点, 订单就会被触发. 139 | 140 | 在 `12:01:00` 到 `12:02:00` 之间市场上一系列的交易让价格开始上涨到42,000, 使追踪的"最高价"变成42,000. 如果价格从这里(42,000)开始下跌700个基点, 订单会被触发. 141 | 142 | 在 `12:02:00` 到 `12:03:00` 之间市场上一系列的交易让价格下跌到39,500, 这让市场从之前追踪的最高价(42,000)下跌了大约595个基点, 不过没有达到700个基点的要求, 订单不会被触发. 143 | 144 | 在 `12:03:00` 到 `12:04:00` 之间市场上一系列的交易让价格上涨到45,500. 市场的上涨, 让追踪的最高价变成当前价45,500. 如果价格从这里45,500下跌了700个基点, 订单就会被触发. 145 | 146 | 在 `12:04:00` 到 `12:04:45` 之间市场上一系列的交易让价格下跌到42,315. 当前价格达到或者超过了追踪订单设定的700个基点(`42,315 = 45,500 * 0.93`), 导致订单被触发, 以限价(LIMIT)39,000的价格被放入订单薄. 147 | 148 | image 149 | 150 | ## 追踪止盈止损下单示例 151 | 152 | 假设当前最新价是40,000. 153 | 154 | 下一个追踪止损(`STOP_LOSS_LIMIT`)的买单, 设置价格为42,000, 追踪价差(`trailingDelta`)为5%. 155 | 156 | ```bash 157 | # 不设置止损价(stop price) 158 | POST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=BUY&type=STOP_LOSS_LIMIT&timeInForce=GTC&quantity=0.01&price=42000&trailingDelta=500×tamp=&signature=' 159 | 160 | # 设置止损价(stop price)43,000 161 | POST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=BUY&type=STOP_LOSS_LIMIT&timeInForce=GTC&quantity=0.01&price=42000&stopPrice=43000&trailingDelta=500×tamp=&signature=' 162 | ``` 163 | 164 | 下一个追踪止损(`STOP_LOSS_LIMIT`)的卖单, 设置价格为37,500, 追踪价差(`trailingDelta`)为2.5%. 165 | 166 | ```bash 167 | # 不设置止损价(stop price) 168 | POST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=SELL&type=STOP_LOSS_LIMIT&timeInForce=GTC&quantity=0.01&price=37500&trailingDelta=250×tamp=&signature=' 169 | 170 | # 设置止损价(stop price)39,000 171 | POST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=SELL&type=STOP_LOSS_LIMIT&timeInForce=GTC&quantity=0.01&price=37500&stopPrice=39000&trailingDelta=250×tamp=&signature=' 172 | ``` 173 | 174 | 下一个追踪止盈(`TAKE_PROFIT_LIMIT`)的买单, 设置价格为38,000, 追踪价差(`trailingDelta`)为5%. 175 | 176 | ```bash 177 | # 不设置止盈价(stop price) 178 | POST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=BUY&type=TAKE_PROFIT_LIMIT&timeInForce=GTC&quantity=0.01&price=38000&trailingDelta=500×tamp=&signature=' 179 | 180 | # 设置止盈价(stop price)36,000 181 | POST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=BUY&type=TAKE_PROFIT_LIMIT&timeInForce=GTC&quantity=0.01&price=38000&stopPrice=36000&trailingDelta=500×tamp=&signature=' 182 | ``` 183 | 184 | 下一个追踪止盈(`TAKE_PROFIT_LIMIT`)的卖单, 设置价格为41,500, 追踪价差(`trailingDelta`)为1.75%. 185 | 186 | ```bash 187 | # 不设置止盈价(stop price) 188 | POST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=SELL&type=TAKE_PROFIT_LIMIT&timeInForce=GTC&quantity=0.01&price=41500&trailingDelta=175×tamp=&signature=' 189 | 190 | # 设置止盈价(stop price) 42,500 191 | POST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=SELL&type=TAKE_PROFIT_LIMIT&timeInForce=GTC&quantity=0.01&price=41500&stopPrice=42500&trailingDelta=175×tamp=&signature=' 192 | ``` 193 | -------------------------------------------------------------------------------- /filters.md: -------------------------------------------------------------------------------- 1 | # Filters 2 | Filters define trading rules on a symbol or an exchange. 3 | Filters come in two forms: `symbol filters` and `exchange filters`. 4 | 5 | ## Symbol filters 6 | ### PRICE_FILTER 7 | The `PRICE_FILTER` defines the `price` rules for a symbol. There are 3 parts: 8 | 9 | * `minPrice` defines the minimum `price`/`stopPrice` allowed; disabled on `minPrice` == 0. 10 | * `maxPrice` defines the maximum `price`/`stopPrice` allowed; disabled on `maxPrice` == 0. 11 | * `tickSize` defines the intervals that a `price`/`stopPrice` can be increased/decreased by; disabled on `tickSize` == 0. 12 | 13 | Any of the above variables can be set to 0, which disables that rule in the `price filter`. In order to pass the `price filter`, the following must be true for `price`/`stopPrice` of the enabled rules: 14 | 15 | * `price` >= `minPrice` 16 | * `price` <= `maxPrice` 17 | * `price` % `tickSize` == 0 18 | 19 | **/exchangeInfo format:** 20 | ```javascript 21 | { 22 | "filterType": "PRICE_FILTER", 23 | "minPrice": "0.00000100", 24 | "maxPrice": "100000.00000000", 25 | "tickSize": "0.00000100" 26 | } 27 | ``` 28 | 29 | ### PERCENT_PRICE 30 | The `PERCENT_PRICE` filter defines the valid range for the price based on the average of the previous trades. 31 | `avgPriceMins` is the number of minutes the average price is calculated over. 0 means the last price is used. 32 | 33 | In order to pass the `percent price`, the following must be true for `price`: 34 | * `price` <= `weightedAveragePrice` * `multiplierUp` 35 | * `price` >= `weightedAveragePrice` * `multiplierDown` 36 | 37 | **/exchangeInfo format:** 38 | ```javascript 39 | { 40 | "filterType": "PERCENT_PRICE", 41 | "multiplierUp": "1.3000", 42 | "multiplierDown": "0.7000", 43 | "avgPriceMins": 5 44 | } 45 | ``` 46 | 47 | ### PERCENT_PRICE_BY_SIDE 48 | The `PERCENT_PRICE_BY_SIDE` filter defines the valid range for the price based on the average of the previous trades.
49 | `avgPriceMins` is the number of minutes the average price is calculated over. 0 means the last price is used.
50 | There is a different range depending on whether the order is placed on the `BUY` side or the `SELL` side. 51 | 52 | Buy orders will succeed on this filter if: 53 | * `Order price` <= `weightedAveragePrice` * `bidMultiplierUp` 54 | * `Order price` >= `weightedAveragePrice` * `bidMultiplierDown` 55 | 56 | Sell orders will succeed on this filter if: 57 | * `Order Price` <= `weightedAveragePrice` * `askMultiplierUp` 58 | * `Order Price` >= `weightedAveragePrice` * `askMultiplierDown` 59 | 60 | **/exchangeInfo format:** 61 | ```javascript 62 | { 63 | "filterType": "PERCENT_PRICE_BY_SIDE", 64 | "bidMultiplierUp": "1.2", 65 | "bidMultiplierDown": "0.2", 66 | "askMultiplierUp": "5", 67 | "askMultiplierDown": "0.8", 68 | "avgPriceMins": 1 69 | } 70 | ``` 71 | 72 | 73 | ### LOT_SIZE 74 | The `LOT_SIZE` filter defines the `quantity` (aka "lots" in auction terms) rules for a symbol. There are 3 parts: 75 | 76 | * `minQty` defines the minimum `quantity`/`icebergQty` allowed. 77 | * `maxQty` defines the maximum `quantity`/`icebergQty` allowed. 78 | * `stepSize` defines the intervals that a `quantity`/`icebergQty` can be increased/decreased by. 79 | 80 | In order to pass the `lot size`, the following must be true for `quantity`/`icebergQty`: 81 | 82 | * `quantity` >= `minQty` 83 | * `quantity` <= `maxQty` 84 | * `quantity` % `stepSize` == 0 85 | 86 | **/exchangeInfo format:** 87 | ```javascript 88 | { 89 | "filterType": "LOT_SIZE", 90 | "minQty": "0.00100000", 91 | "maxQty": "100000.00000000", 92 | "stepSize": "0.00100000" 93 | } 94 | ``` 95 | 96 | ### MIN_NOTIONAL 97 | The `MIN_NOTIONAL` filter defines the minimum notional value allowed for an order on a symbol. 98 | An order's notional value is the `price` * `quantity`. 99 | `applyToMarket` determines whether or not the `MIN_NOTIONAL` filter will also be applied to `MARKET` orders. 100 | Since `MARKET` orders have no price, the average price is used over the last `avgPriceMins` minutes. 101 | `avgPriceMins` is the number of minutes the average price is calculated over. 0 means the last price is used. 102 | 103 | 104 | **/exchangeInfo format:** 105 | ```javascript 106 | { 107 | "filterType": "MIN_NOTIONAL", 108 | "minNotional": "0.00100000", 109 | "applyToMarket": true, 110 | "avgPriceMins": 5 111 | } 112 | ``` 113 | 114 | ### NOTIONAL 115 | The `NOTIONAL` filter defines the acceptable notional range allowed for an order on a symbol.

116 | `applyMinToMarket` determines whether the `minNotional` will be applied to `MARKET` orders.
117 | `applyMaxToMarket` determines whether the `maxNotional` will be applied to `MARKET` orders. 118 | 119 | In order to pass this filter, the notional (`price * quantity`) has to pass the following conditions: 120 | 121 | * `price * quantity` <= `maxNotional` 122 | * `price * quantity` >= `minNotional` 123 | 124 | For `MARKET` orders, the average price used over the last `avgPriceMins` minutes will be used for calculation.
125 | If the `avgPriceMins` is 0, then the last price will be used. 126 | 127 | **/exchangeInfo format:** 128 | ```javascript 129 | { 130 | "filterType": "NOTIONAL", 131 | "minNotional": "10.00000000", 132 | "applyMinToMarket": false, 133 | "maxNotional": "10000.00000000", 134 | "applyMaxToMarket": false, 135 | "avgPriceMins": 5 136 | } 137 | ``` 138 | 139 | ### ICEBERG_PARTS 140 | The `ICEBERG_PARTS` filter defines the maximum parts an iceberg order can have. The number of `ICEBERG_PARTS` is defined as `CEIL(qty / icebergQty)`. 141 | 142 | **/exchangeInfo format:** 143 | ```javascript 144 | { 145 | "filterType": "ICEBERG_PARTS", 146 | "limit": 10 147 | } 148 | ``` 149 | 150 | ### MARKET_LOT_SIZE 151 | The `MARKET_LOT_SIZE` filter defines the `quantity` (aka "lots" in auction terms) rules for `MARKET` orders on a symbol. There are 3 parts: 152 | 153 | * `minQty` defines the minimum `quantity` allowed. 154 | * `maxQty` defines the maximum `quantity` allowed. 155 | * `stepSize` defines the intervals that a `quantity` can be increased/decreased by. 156 | 157 | In order to pass the `market lot size`, the following must be true for `quantity`: 158 | 159 | * `quantity` >= `minQty` 160 | * `quantity` <= `maxQty` 161 | * `quantity` % `stepSize` == 0 162 | 163 | **/exchangeInfo format:** 164 | ```javascript 165 | { 166 | "filterType": "MARKET_LOT_SIZE", 167 | "minQty": "0.00100000", 168 | "maxQty": "100000.00000000", 169 | "stepSize": "0.00100000" 170 | } 171 | ``` 172 | 173 | ### MAX_NUM_ORDERS 174 | The `MAX_NUM_ORDERS` filter defines the maximum number of orders an account is allowed to have open on a symbol. 175 | Note that both "algo" orders and normal orders are counted for this filter. 176 | 177 | **/exchangeInfo format:** 178 | ```javascript 179 | { 180 | "filterType": "MAX_NUM_ORDERS", 181 | "maxNumOrders": 25 182 | } 183 | ``` 184 | 185 | ### MAX_NUM_ALGO_ORDERS 186 | The `MAX_NUM_ALGO_ORDERS` filter defines the maximum number of "algo" orders an account is allowed to have open on a symbol. 187 | "Algo" orders are `STOP_LOSS`, `STOP_LOSS_LIMIT`, `TAKE_PROFIT`, and `TAKE_PROFIT_LIMIT` orders. 188 | 189 | **/exchangeInfo format:** 190 | ```javascript 191 | { 192 | "filterType": "MAX_NUM_ALGO_ORDERS", 193 | "maxNumAlgoOrders": 5 194 | } 195 | ``` 196 | 197 | ### MAX_NUM_ICEBERG_ORDERS 198 | The `MAX_NUM_ICEBERG_ORDERS` filter defines the maximum number of `ICEBERG` orders an account is allowed to have open on a symbol. 199 | An `ICEBERG` order is any order where the `icebergQty` is > 0. 200 | 201 | **/exchangeInfo format:** 202 | ```javascript 203 | { 204 | "filterType": "MAX_NUM_ICEBERG_ORDERS", 205 | "maxNumIcebergOrders": 5 206 | } 207 | ``` 208 | 209 | ### MAX_POSITION 210 | 211 | The `MAX_POSITION` filter defines the allowed maximum position an account can have on the base asset of a symbol. An account's position defined as the sum of the account's: 212 | 1. free balance of the base asset 213 | 1. locked balance of the base asset 214 | 1. sum of the qty of all open BUY orders 215 | 216 | `BUY` orders will be rejected if the account's position is greater than the maximum position allowed. 217 | 218 | If an order's `quantity` can cause the position to overflow, this will also fail the `MAX_POSITION` filter. 219 | 220 | **/exchangeInfo format:** 221 | ```javascript 222 | { 223 | "filterType":"MAX_POSITION", 224 | "maxPosition":"10.00000000" 225 | } 226 | ``` 227 | 228 | ### TRAILING_DELTA 229 | 230 | The `TRAILING_DELTA` filter defines the minimum and maximum value for the parameter `trailingDelta`. 231 | 232 | In order for a trailing stop order to pass this filter, the following must be true: 233 | 234 | For `STOP_LOSS BUY`, `STOP_LOSS_LIMIT_BUY`,`TAKE_PROFIT SELL` and `TAKE_PROFIT_LIMIT SELL` orders: 235 | 236 | * `trailingDelta` >= `minTrailingAboveDelta` 237 | * `trailingDelta` <= `maxTrailingAboveDelta` 238 | 239 | For `STOP_LOSS SELL`, `STOP_LOSS_LIMIT SELL`, `TAKE_PROFIT BUY`, and `TAKE_PROFIT_LIMIT BUY` orders: 240 | 241 | * `trailingDelta` >= `minTrailingBelowDelta` 242 | * `trailingDelta` <= `maxTrailingBelowDelta` 243 | 244 | 245 | **/exchangeInfo format:** 246 | 247 | ```javascript 248 | { 249 | "filterType": "TRAILING_DELTA", 250 | "minTrailingAboveDelta": 10, 251 | "maxTrailingAboveDelta": 2000, 252 | "minTrailingBelowDelta": 10, 253 | "maxTrailingBelowDelta": 2000 254 | } 255 | ``` 256 | 257 | 258 | ## Exchange Filters 259 | ### EXCHANGE_MAX_NUM_ORDERS 260 | The `EXCHANGE_MAX_NUM_ORDERS` filter defines the maximum number of orders an account is allowed to have open on the exchange. 261 | Note that both "algo" orders and normal orders are counted for this filter. 262 | 263 | **/exchangeInfo format:** 264 | ```javascript 265 | { 266 | "filterType": "EXCHANGE_MAX_NUM_ORDERS", 267 | "maxNumOrders": 1000 268 | } 269 | ``` 270 | 271 | ### EXCHANGE_MAX_NUM_ALGO_ORDERS 272 | The `EXCHANGE_MAX_NUM_ALGO_ORDERS` filter defines the maximum number of "algo" orders an account is allowed to have open on the exchange. 273 | "Algo" orders are `STOP_LOSS`, `STOP_LOSS_LIMIT`, `TAKE_PROFIT`, and `TAKE_PROFIT_LIMIT` orders. 274 | 275 | **/exchangeInfo format:** 276 | ```javascript 277 | { 278 | "filterType": "EXCHANGE_MAX_NUM_ALGO_ORDERS", 279 | "maxNumAlgoOrders": 200 280 | } 281 | ``` 282 | 283 | ### EXCHANGE_MAX_NUM_ICEBERG_ORDERS 284 | The `EXCHANGE_MAX_NUM_ICEBERG_ORDERS` filter defines the maximum number of iceberg orders an account is allowed to have open on the exchange. 285 | 286 | **/exchangeInfo format:** 287 | ```javascript 288 | { 289 | "filterType": "EXCHANGE_MAX_NUM_ICEBERG_ORDERS", 290 | "maxNumIcebergOrders": 10000 291 | } 292 | ``` 293 | -------------------------------------------------------------------------------- /filters_CN.md: -------------------------------------------------------------------------------- 1 | # 过滤器 2 | 过滤器,即Filter,定义了一系列交易规则。 3 | 共有两类,分别是针对交易对的过滤器`symbol filters`,和针对整个交易所的过滤器`exchange filters` 4 | 5 | ## 交易对过滤器 6 | ### PRICE_FILTER 价格过滤器 7 | 价格过滤器用于检测order订单中price参数的合法性 8 | * `minPrice` 定义了 `price`/`stopPrice` 允许的最小值; `minPrice` == 0 的时候则失效。 9 | * `maxPrice` 定义了 `price`/`stopPrice` 允许的最大值; `maxPrice` == 0 的时候则失效。 10 | * `tickSize` 定义了 `price`/`stopPrice` 的步进间隔; `tickSize` == 0 的时候则失效。 11 | 12 | 以上每一项均可为0,为0时代表这一项不再做限制。 13 | 14 | 逻辑伪代码如下: 15 | * `price` >= `minPrice` 16 | * `price` <= `maxPrice` 17 | * `price` % `tickSize` == 0 18 | 19 | **/exchangeInfo 响应中的格式:** 20 | ```javascript 21 | { 22 | "filterType": "PRICE_FILTER", 23 | "minPrice": "0.00000100", 24 | "maxPrice": "100000.00000000", 25 | "tickSize": "0.00000100" 26 | } 27 | ``` 28 | 29 | ### PERCENT_PRICE 价格振幅过滤器 30 | 可以理解为一个瞬时的涨跌停限制,不允许价格瞬间剧烈浮动。 31 | `avgPriceMins` 指用过去几分钟的平均价格来计算价格基准. 0 表示用最新成交价格作为价格计准。 32 | 33 | 逻辑伪代码如下: 34 | * `price` <= `weightedAveragePrice` * `multiplierUp` 35 | * `price` >= `weightedAveragePrice` * `multiplierDown` 36 | 37 | **/exchangeInfo 响应中的格式:** 38 | ```javascript 39 | { 40 | "filterType": "PERCENT_PRICE", 41 | "multiplierUp": "1.3000", 42 | "multiplierDown": "0.7000", 43 | "avgPriceMins": 5 44 | } 45 | ``` 46 | 47 | #### PERCENT_PRICE_BY_SIDE 48 | `PERCENT_PRICE_BY_SIDE` 过滤器定义了基于交易对平均价格的合法价格范围. 取决于`BUY`或者`SELL`, 价格范围可能有所不同.
49 | 50 | `avgPriceMins` 是用来计算平均价格的分钟数. 0 表示用最新价(last price).
51 | 52 | 买向订单需要满足: 53 | 54 | * `Order price` <= `weightedAveragePrice` * `bidMultiplierUp` 55 | * `Order price` >= `weightedAveragePrice` * `bidMultiplierDown` 56 | 57 | 卖向订单需要满足: 58 | 59 | * `Order Price` <= `weightedAveragePrice` * `askMultiplierUp` 60 | * `Order Price` >= `weightedAveragePrice` * `askMultiplierDown` 61 | 62 | 63 | **/exchangeInfo 响应中的格式:** 64 | ```javascript 65 | { 66 | "filterType": "PERCENT_PRICE_BY_SIDE", 67 | "bidMultiplierUp": "1.2", 68 | "bidMultiplierDown": "0.2", 69 | "askMultiplierUp": "5", 70 | "askMultiplierDown": "0.8", 71 | "avgPriceMins": 1 72 | } 73 | ``` 74 | 75 | ### LOT_SIZE 订单尺寸 76 | "lots" 是拍卖术语,这个过滤器对订单中的 `quantity` 也就是数量参数进行合法性检查。包含三个部分: 77 | 78 | * `minQty` 表示 `quantity`/`icebergQty` 允许的最小值. 79 | * `maxQty` 表示 `quantity`/`icebergQty` 允许的最大值 80 | * `stepSize` 表示 `quantity`/`icebergQty` 允许的步进值。 81 | 82 | 逻辑伪代码如下: 83 | 84 | * `quantity` >= `minQty` 85 | * `quantity` <= `maxQty` 86 | * `quantity` % `stepSize` == 0 87 | 88 | **/exchangeInfo 响应中的格式:** 89 | ```javascript 90 | { 91 | "filterType": "LOT_SIZE", 92 | "minQty": "0.00100000", 93 | "maxQty": "100000.00000000", 94 | "stepSize": "0.00100000" 95 | } 96 | ``` 97 | 98 | ### MIN_NOTIONAL 最小金额 99 | MIN_NOTIONAL过滤器定义了交易对订单所允许的最小名义价值(成交额)。 100 | 订单的名义价值是`价格`*`数量`。 101 | 如果是高级订单(比如止盈止损订单`STOP_LOSS_LIMIT`),名义价值会按照`stopPrice` * `quantity`来计算。 102 | 如果是冰山订单,名义价值会按照`price` * `icebergQty`来计算。 103 | `applyToMarket`确定 `MIN_NOTIONAL`过滤器是否也将应用于`MARKET`订单。 104 | 由于`MARKET`订单没有价格,因此会在最后`avgPriceMins`分钟内使用平均价格。 105 | `avgPriceMins`是计算平均价格的分钟数。 0表示使用最后的价格。 106 | 107 | 108 | **/exchangeInfo 响应中的格式:** 109 | ```javascript 110 | { 111 | "filterType": "MIN_NOTIONAL", 112 | "minNotional": "0.00100000", 113 | "applyToMarket": true, 114 | "avgPriceMins": 5 115 | } 116 | ``` 117 | 118 | ### NOTIONAL 名义价值 119 | 120 | **/exchangeInfo 响应中的格式:** 121 | 122 | ```javascript 123 | { 124 | "filterType": "NOTIONAL", 125 | "minNotional": "10.00000000", 126 | "applyMinToMarket": false, 127 | "maxNotional": "10000.00000000", 128 | "applyMaxToMarket": false, 129 | "avgPriceMins": 5 130 | } 131 | ``` 132 | 133 | 名义价值过滤器(`NOTIONAL`)定义了订单在一个交易对上可以下单的名义价值区间.

134 | `applyMinToMarket` 定义了 `minNotional` 是否适用于市价单(`MARKET`)
135 | `applyMaxToMarket` 定义了 `maxNotional` 是否适用于市价单(`MARKET`). 136 | 137 | 要通过此过滤器, 订单的名义价值 (单价 x 数量, `price * quantity`) 需要满足如下条件: 138 | 139 | * `price * quantity` <= `maxNotional` 140 | * `price * quantity` >= `minNotional` 141 | 142 | 对于市价单(`MARKET`), 用于计算的价格采用的是在 `avgPriceMins` 定义的时间之内的平均价.
143 | 如果 `avgPriceMins` 为 0, 则采用最新的价格. 144 | 145 | ### ICEBERG_PARTS 冰山订单拆分数 146 | `ICEBERG_PARTS` 代表冰山订单最多可以拆分成多少个小订单。 147 | 计算方法为 `向上取整(qty / icebergQty)`. 148 | 149 | **/exchangeInfo 响应中的格式:** 150 | ```javascript 151 | { 152 | "filterType": "ICEBERG_PARTS", 153 | "limit": 10 154 | } 155 | ``` 156 | 157 | ### MARKET_LOT_SIZE 市价订单尺寸 158 | `MARKET_LOT_SIZE`过滤器为交易对上的`MARKET`订单定义了`数量`(即拍卖中的"手数")规则。 共有3部分: 159 | 160 | * `minQty`定义了允许的最小`quantity`。 161 | * `maxQty`定义了允许的最大数量。 162 | * `stepSize`定义了可以增加/减少数量的间隔。 163 | 164 | 为了通过 `market lot size`,`quantity` 必须满足以下条件: 165 | 166 | * `quantity` >= `minQty` 167 | * `quantity` <= `maxQty` 168 | * `quantity` % `stepSize` == 0 169 | 170 | **/exchangeInfo 响应中的格式:** 171 | ```javascript 172 | { 173 | "filterType": "MARKET_LOT_SIZE", 174 | "minQty": "0.00100000", 175 | "maxQty": "100000.00000000", 176 | "stepSize": "0.00100000" 177 | } 178 | ``` 179 | 180 | ### MAX_NUM_ORDERS 最多订单数 181 | 定义了某个交易对最多允许的挂单数量(不包括已关闭的订单) 182 | 普通订单与条件订单均计算在内 183 | 184 | **/exchangeInfo 响应中的格式:** 185 | ```javascript 186 | { 187 | "filterType": "MAX_NUM_ORDERS", 188 | "maxNumOrders": 25 189 | } 190 | ``` 191 | 192 | ### MAX_NUM_ALGO_ORDERS 最多条件单数 193 | `MAX_NUM_ALGO_ORDERS`过滤器定义允许账户在交易对上开设的"algo"订单的最大数量。 194 | "Algo"订单是`STOP_LOSS`,`STOP_LOSS_LIMIT`,`TAKE_PROFIT`和`TAKE_PROFIT_LIMIT`止盈止损单。 195 | 196 | **/exchangeInfo 响应中的格式:** 197 | ```javascript 198 | { 199 | "filterType": "MAX_NUM_ALGO_ORDERS", 200 | "maxNumAlgoOrders": 5 201 | } 202 | ``` 203 | 204 | ### MAX_NUM_ICEBERG_ORDERS 最多冰山单数 205 | `MAX_NUM_ICEBERG_ORDERS`过滤器定义了允许在交易对上开设账户的`ICEBERG`订单的最大数量。 206 | `ICEBERG`订单是icebergQty大于0的任何订单。 207 | 208 | **/exchangeInfo 响应中的格式:** 209 | ```javascript 210 | { 211 | "filterType": "MAX_NUM_ICEBERG_ORDERS", 212 | "maxNumIcebergOrders": 5 213 | } 214 | ``` 215 | 216 | ### MAX_POSITION 过滤器 217 | 218 | 这个过滤器定义账户允许的基于`base asset`的最大仓位。一个用户的仓位可以定义为如下资产的总和: 219 | 1. `base asset`的可用余额 220 | 1. `base asset`的锁定余额 221 | 1. 所有处于open的买单的数量总和 222 | 223 | 如果用户的仓位大于最大的允许仓位,买单会被拒绝。 224 | 225 | 如果一个订单的数量(`quantity`) 可能导致持有仓位溢出, 会触发过滤器 `MAX_POSITION`. 226 | 227 | **/exchangeInfo 响应中的格式:** 228 | ```javascript 229 | { 230 | "filterType": "MAX_POSITION", 231 | "maxPosition": "10.00000000" 232 | } 233 | ``` 234 | 235 | ### TRAILING_DELTA 过滤器 236 | 237 | 238 | 此过滤器定义了参数`trailingDelta`的最大和最小值. 239 | 240 | 下追踪止损订单, 需要满足条件: 241 | 242 | 对于 `STOP_LOSS BUY`, `STOP_LOSS_LIMIT_BUY`, `TAKE_PROFIT SELL` 和 `TAKE_PROFIT_LIMIT SELL` 订单: 243 | 244 | * `trailingDelta` >= `minTrailingAboveDelta` 245 | * `trailingDelta` <= `maxTrailingAboveDelta` 246 | 247 | 对于 `STOP_LOSS SELL`, `STOP_LOSS_LIMIT SELL`, `TAKE_PROFIT BUY`, 和 `TAKE_PROFIT_LIMIT BUY` 订单: 248 | 249 | * `trailingDelta` >= `minTrailingBelowDelta` 250 | * `trailingDelta` <= `maxTrailingBelowDelta` 251 | 252 | **/exchangeInfo format:** 253 | ```javascript 254 | { 255 | "filterType": "TRAILING_DELTA", 256 | "minTrailingAboveDelta": 10, 257 | "maxTrailingAboveDelta": 2000, 258 | "minTrailingBelowDelta": 10, 259 | "maxTrailingBelowDelta": 2000 260 | } 261 | ``` 262 | 263 | ## 交易所级别过滤器 264 | ### EXCHANGE_MAX_NUM_ORDERS 最多订单数 265 | `EXCHANGE_MAX_NUM_ORDERS`过滤器定义了允许在交易对上开设账户的最大订单数。 266 | 请注意,此过滤器同时计算"algo"订单和常规订单。 267 | 268 | **/exchangeInfo 响应中的格式:** 269 | ```javascript 270 | { 271 | "filterType": "EXCHANGE_MAX_NUM_ORDERS", 272 | "maxNumOrders": 1000 273 | } 274 | ``` 275 | 276 | ### EXCHANGE_MAX_NUM_ALGO_ORDERS 最多条件单数 277 | `EXCHANGE_MAX_ALGO_ORDERS`过滤器定义了允许在交易上开设账户的"algo"订单的最大数量。 278 | "Algo"订单是`STOP_LOSS`,`STOP_LOSS_LIMIT`,`TAKE_PROFIT`和`TAKE_PROFIT_LIMIT`订单。 279 | 280 | **/exchangeInfo 响应中的格式:** 281 | ```javascript 282 | { 283 | "filterType": "EXCHANGE_MAX_NUM_ALGO_ORDERS", 284 | "maxNumAlgoOrders": 200 285 | } 286 | ``` 287 | 288 | ### EXCHANGE_MAX_NUM_ICEBERG_ORDERS 冰山订单的最大订单数 289 | 290 | 此过滤器定义了允许账号持有的最大冰山订单数量. 291 | 292 | 293 | **/exchangeInfo 响应中的格式:** 294 | 295 | ```javascript 296 | { 297 | "filterType": "EXCHANGE_MAX_NUM_ICEBERG_ORDERS", 298 | "maxNumIcebergOrders": 10000 299 | } 300 | ``` -------------------------------------------------------------------------------- /fix/schemas/spot-fix-md.xml: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | > 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 |
261 | -------------------------------------------------------------------------------- /sbe-market-data-streams.md: -------------------------------------------------------------------------------- 1 | # SBE Market Data Streams 2 | 3 | ## General Information 4 | 5 | * The base endpoint is **stream-sbe.binance.com** or **stream-sbe.binance.com:9443**. 6 | * To retrieve market data in JSON format, please refer to [this page](web-socket-streams.md). 7 | * SBE schema used for decoding the streams can be found [here](https://github.com/binance/binance-spot-api-docs/blob/master/sbe/schemas/stream_1_0.xml). 8 | * All symbols in stream names are **lowercase**. 9 | * You can subscribe to a single stream at **/ws/\**. 10 | * You can subscribe to multiple streams at **/stream?streams=\/\/\**. 11 | * A single connection to **stream-sbe.binance.com** is **only valid for 24 hours**; expect to be disconnected at the 24 hour mark. 12 | * All time and timestamp fields are in **microseconds**. 13 | * **An API Key is necessary for access**. 14 | * Only Ed25519 keys are allowed. 15 | * Please put your API Key in the `X-MBX-APIKEY` header when opening the connection. Timestamp and signature are not necessary. 16 | * No extra API key permissions are necessary to access public market data. Symbol whitelist also does not affect access to SBE Market Data Streams. 17 | * However, if you use an IP whitelist for the API key, only specified IP addresses are allowed to use the API key. 18 | * The server sends a `ping frame` every 20 seconds. 19 | * If the server does not receive a `pong frame` back from you within a minute, the connection will be closed. 20 | * When you receive a ping, you must send a pong with a copy of ping's payload as soon as possible. 21 | * Unsolicited `pong frames` are allowed, but will not prevent disconnection. **It is recommended that the payload for these pong frames are empty.** 22 | * [Live Subscribing and Unsubscribing](web-socket-streams.md#live-subscribingunsubscribing-to-streams) is also supported. 23 | * You must send the subscription requests in JSON, and will receive the subscription response also in JSON. 24 | * You can differentiate subscription responses from market data events by looking at the WebSocket frame type: subscription responses are always sent in text frames (containing JSON), and events are always sent in binary frames (containing SBE). 25 | 26 | ## WebSocket Limits 27 | 28 | * WebSocket connections have a rate limit of **5 requests per second**. 29 | * Only messages from your client are considered: 30 | * `PING frame` 31 | * `PONG frame` 32 | * `Text frame` with JSON control request 33 | * Events pushed by the server are not rate-limited. 34 | * Connections that go beyond the limit will be closed. Repeatedly disconnected IP addresses may be banned. 35 | * A single connection can listen to a maximum of 1024 streams. 36 | * There is a limit of **300 connection attempts every 5 minutes per IP address**. 37 | 38 | ## Available Streams 39 | 40 | ### Trades Streams 41 | 42 | Raw trade information, pushed in real-time. 43 | 44 | **SBE Message Name:** `TradesStreamEvent` 45 | 46 | **Stream Name**: \@trade 47 | 48 | **Update Speed**: Real time 49 | 50 | ### Best Bid/Ask Streams 51 | 52 | The best bid and ask price and quantity, pushed in real-time when the order book changes. 53 | 54 | > [!NOTE] 55 | > Best bid/ask streams in SBE are the equivalent of bookTicker streams in JSON, except they support auto-culling, and also include the `eventTime` field. 56 | 57 | **SBE Message Name:** `BestBidAskStreamEvent` 58 | 59 | **Stream Name**: \@bestBidAsk 60 | 61 | **Update Speed**: Real time 62 | 63 | 64 | SBE best bid/ask streams use **auto-culling**: when our system is under high load, we may drop outdated events instead of queuing all events and delivering them with a delay. 65 | 66 | For example, if a best bid/ask event is generated at time T2 when we still have an undelivered event queued at time T1 (where T1 < T2), the event for T1 is dropped, and we will deliver only the event for T2. This is done on a per-symbol basis. 67 | 68 | ### Diff. Depth Streams 69 | 70 | Incremental updates to the order book, pushed at regular intervals. Use this stream to maintain a local order book. 71 | 72 | [How to manage a local order book.](web-socket-streams.md#how-to-manage-a-local-order-book-correctly) 73 | 74 | **SBE Message Name:** `DepthDiffStreamEvent` 75 | 76 | **Stream Name**: \@depth 77 | 78 | **Update Speed:** 100 ms 79 | 80 | ### Partial Book Depth Streams 81 | 82 | Snapshots of the top 20 levels of the order book, pushed at regular intervals. 83 | 84 | **SBE Message Name:** `DepthSnapshotStreamEvent` 85 | 86 | **Stream Name**: \@depth20 87 | 88 | **Update Speed:** 100ms 89 | -------------------------------------------------------------------------------- /sbe-market-data-streams_CN.md: -------------------------------------------------------------------------------- 1 | # SBE 市场数据流 2 | 3 | ## WSS 基本信息 4 | 5 | * 基本访问地址是 **stream-sbe.binance.com** 或 **stream-sbe.binance.com:9443**。 6 | * 要以 JSON 格式检索市场数据,请参阅 [此页面](web-socket-streams_CN.md)。 7 | * 可以在[此处](https://github.com/binance/binance-spot-api-docs/blob/master/sbe/schemas/stream_1_0.xml)找到用于对数据流进行解码的 SBE 模式。 8 | * stream 名称中所有交易对均为**小写**。 9 | * 订阅单个streams时,可用的URL格式示例: **/ws/\**。 10 | * 订阅组合streams时,可用的URL格式示例: **/stream?streams=\/\/\**。 11 | * 每个到**stream-sbe.binance.com**的链接有效期不超过24小时,请妥善处理断线重连。 12 | * 所有时间和时间戳相关的字段均以 **微秒** 为单位。 13 | * **需要 API Key 身份验证。** 14 | * 只允许使用 Ed25519 密钥。 15 | * 打开连接时,请将您的 API Key 放在 `X-MBX-APIKEY` 标头中。时间戳和签名不是必需的。 16 | * 无需额外的 API 密钥权限即可访问公开市场数据。交易对白名单也不会影响对 SBE 市场数据流的访问。 17 | * 但是,如果 API 密钥使用 IP 白名单,则仅允许指定的 IP 地址使用 API 密钥。 18 | * WebSocket 服务器会**每20秒**发送 PING 帧。 19 | * 如果websocket 服务器没有在一分钟之内收到 PONG 帧响应,连接会被断开。 20 | * 当客户收到 PING 帧,必须尽快回复 PONG 帧,同时 payload 需要和 PING 帧一致。 21 | * 服务器允许未经请求的 PONG 帧,但这不会保证连接不断开。**对于这种类型的 PONG 帧,建议设置其 payload 为空。** 22 | * [支持实时订阅和取消订阅](web-socket-streams_CN.md#实时订阅/取消数据流)。 23 | * 您必须以 JSON 格式发送订阅请求,并且还将以 JSON 格式接收订阅响应。 24 | * 您可以通过查看 websocket 帧类型来区分订阅响应和市场数据事件:订阅响应始终以 text 帧(包含 JSON)发送,而事件始终以 二进制帧(包含 SBE)发送。 25 | 26 | ## WebSocket 连接限制 27 | 28 | * WebSocket服务器**每秒最多接受5个消息**。 29 | * 消息包括: 30 | * PING 帧 31 | * PONG 帧 32 | * Text 帧JSON格式的控制请求 33 | * 由服务器推送的事件不受速率限制。 34 | * 如果用户发送的消息数超过限制,连接会被断开连接。反复被断开连接的IP有可能被服务器屏蔽。 35 | * 单个连接最多可以订阅1024个 Streams。 36 | * 每个IP地址的请求限制为 **每5分钟最多可以发送300次连接请求**。 37 | 38 | ## 可供用户使用的 Stream 39 | 40 | ### 逐笔交易 41 | 42 | 实时推送的原始交易信息 43 | 44 | **SBE 消息名称:** `TradesStreamEvent` 45 | 46 | **Stream 名称**: \@trade 47 | 48 | **更新速度:** 实时 49 | 50 | ### 最优挂单信息 51 | 52 | 当订单簿发生变化时,会实时推送最优买入价和卖出价和数量。 53 | 54 | **SBE 消息名称:** `BestBidAskStreamEvent` 55 | 56 | **Stream 名称**: \@bestBidAsk 57 | 58 | **更新速度**: 实时 59 | 60 | SBE 最优挂单信息流使用**自动剔除**(’**auto-culling‘**) 策略:当我们的系统处于高负载下时,我们可能会丢弃过时的事件,而不是将所有事件排队并延迟交付它们。 61 | 62 | 例如,如果在时间点 T2 处生成了一个新的最优挂单事件, 同时已有一个事件在时间点 T1 处排队(其中 T1 \< T2),那么在 时间点T1 处的事件将被丢弃,我们将仅传推送 在时间点 T2 处的事件。这个策略是基于每个交易对的。 63 | 64 | ### 增量深度信息stream 65 | 66 | 定期推送订单簿的增量更新。使用此流来维护本地订单簿。 67 | 68 | [如何管理本地订单簿。](web-socket-streams_CN.md#如何正确在本地维护一个order-book副本) 69 | 70 | **SBE 消息名称:** `DepthDiffStreamEvent` 71 | 72 | **Stream 名称**: \@depth 73 | 74 | **更新速度:** 100 ms 75 | 76 | ### 有限档深度信息 77 | 78 | 订单簿前 20 档的快照,定期推送。 79 | 80 | **SBE 消息名称:** `DepthSnapshotStreamEvent` 81 | 82 | **Stream 名称**: \@depth20 83 | 84 | **更新速度:** 100ms 85 | -------------------------------------------------------------------------------- /sbe/schemas/sbe_schema_lifecycle_prod.json: -------------------------------------------------------------------------------- 1 | { 2 | "environment": "PROD", 3 | "latestSchema": 4 | { 5 | "id": 3, 6 | "version": 0, 7 | "releaseDate": "2025-04-24" 8 | }, 9 | "deprecatedSchemas": 10 | [ 11 | { 12 | "id": 2, 13 | "version": 1, 14 | "releaseDate": "2024-12-12", 15 | "deprecatedDate": "2025-04-24" 16 | } 17 | ], 18 | "retiredSchemas": 19 | [ 20 | { 21 | "id": 2, 22 | "version": 0, 23 | "releaseDate": "2024-04-25", 24 | "deprecatedDate": "2024-12-12", 25 | "retiredDate": "2025-06-12" 26 | }, 27 | { 28 | "id": 1, 29 | "version": 0, 30 | "releaseDate": "2024-03-05", 31 | "deprecatedDate": "2024-04-25", 32 | "retiredDate": "2024-10-25" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /sbe/schemas/sbe_schema_lifecycle_testnet.json: -------------------------------------------------------------------------------- 1 | { 2 | "environment": "TESTNET", 3 | "latestSchema": 4 | { 5 | "id": 3, 6 | "version": 0, 7 | "releaseDate": "2025-04-02" 8 | }, 9 | "deprecatedSchemas": 10 | [ 11 | { 12 | "id": 2, 13 | "version": 1, 14 | "releaseDate": "2024-11-28", 15 | "deprecatedDate": "2025-04-02" 16 | } 17 | ], 18 | "retiredSchemas": 19 | [ 20 | { 21 | "id": 2, 22 | "version": 0, 23 | "releaseDate": "2024-04-04", 24 | "deprecatedDate": "2024-11-28", 25 | "retiredDate": "2025-05-28" 26 | }, 27 | { 28 | "id": 1, 29 | "version": 0, 30 | "releaseDate": "2023-12-08", 31 | "deprecatedDate": "2024-04-04", 32 | "retiredDate": "2024-10-04" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /sbe/schemas/spot_prod_latest.xml: -------------------------------------------------------------------------------- 1 | spot_3_0.xml -------------------------------------------------------------------------------- /sbe/schemas/spot_testnet_latest.xml: -------------------------------------------------------------------------------- 1 | spot_3_0.xml -------------------------------------------------------------------------------- /sbe/schemas/stream_1_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 40 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 0 50 | 1 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /testnet/TESTNET-TERMS-OF-USE.md: -------------------------------------------------------------------------------- 1 | # SPOT Testnet Terms of Use 2 | 3 | The Binance Spot Testnet and Futures Testnet are subject to the [Testnet Terms of Use](https://www.binance.com/en/about-legal/terms-testnets).
4 | Please read it carefully before proceeding. 5 | -------------------------------------------------------------------------------- /testnet/enums.md: -------------------------------------------------------------------------------- 1 | # ENUM Definitions 2 | 3 | This will apply for both REST API and WebSocket API. 4 | 5 | ## Symbol status (status): 6 | 7 | * `TRADING` 8 | * `END_OF_DAY` 9 | * `HALT` 10 | * `BREAK` 11 | 12 | 13 | 14 | ## Account and Symbol Permissions (permissions) 15 | 16 | * `SPOT` 17 | 18 | ## Order status (status) 19 | 20 | Status | Description 21 | -----------| -------------- 22 | `NEW` | The order has been accepted by the engine. 23 | `PENDING_NEW`|The order is in a pending phase until the working order of an order list has been fully filled. 24 | `PARTIALLY_FILLED`| A part of the order has been filled. 25 | `FILLED` | The order has been completed. 26 | `CANCELED` | The order has been canceled by the user. 27 | `PENDING_CANCEL` | Currently unused 28 | `REJECTED` | The order was not accepted by the engine and not processed. 29 | `EXPIRED` | The order was canceled according to the order type's rules (e.g. LIMIT FOK orders with no fill, LIMIT IOC or MARKET orders that partially fill)
or by the exchange, (e.g. orders canceled during liquidation, orders canceled during maintenance) 30 | `EXPIRED_IN_MATCH` | The order was expired by the exchange due to STP. (e.g. an order with `EXPIRE_TAKER` will match with existing orders on the book with the same account or same `tradeGroupId`) 31 | 32 | ## Order List Status (listStatusType) 33 | 34 | Status | Description 35 | -----------| -------------- 36 | `RESPONSE` | This is used when the ListStatus is responding to a failed action. (E.g. order list placement or cancellation) 37 | `EXEC_STARTED`| The order list has been placed or there is an update to the order list status. 38 | `UPDATED` | The clientOrderId of an order in the order list has been changed. 39 | `ALL_DONE` | The order list has finished executing and thus is no longer active. 40 | 41 | ## Order List Order Status (listOrderStatus) 42 | 43 | Status | Description 44 | -----------| -------------- 45 | `EXECUTING` | Either an order list has been placed or there is an update to the status of the list. 46 | `ALL_DONE`| An order list has completed execution and thus no longer active. 47 | `REJECT` | The List Status is responding to a failed action either during order placement or order canceled. 48 | 49 | ## ContingencyType 50 | 51 | * `OCO` 52 | * `OTO` 53 | 54 | 55 | 56 | ## AllocationType 57 | 58 | * `SOR` 59 | 60 | 61 | 62 | ## Order types (orderTypes, type) 63 | 64 | * `LIMIT` 65 | * `MARKET` 66 | * `STOP_LOSS` 67 | * `STOP_LOSS_LIMIT` 68 | * `TAKE_PROFIT` 69 | * `TAKE_PROFIT_LIMIT` 70 | * `LIMIT_MAKER` 71 | 72 | 73 | 74 | ## Order Response Type (newOrderRespType) 75 | 76 | * `ACK` 77 | * `RESULT` 78 | * `FULL` 79 | 80 | ## Working Floor 81 | 82 | * `EXCHANGE` 83 | * `SOR` 84 | 85 | 86 | 87 | ## Order side (side) 88 | 89 | * `BUY` 90 | * `SELL` 91 | 92 | 93 | 94 | ## Time in force (timeInForce) 95 | 96 | This sets how long an order will be active before expiration. 97 | 98 | Status | Description 99 | -----------| -------------- 100 | `GTC` | Good Til Canceled
An order will be on the book unless the order is canceled. 101 | `IOC` | Immediate Or Cancel
An order will try to fill the order as much as it can before the order expires. 102 | `FOK`| Fill or Kill
An order will expire if the full order cannot be filled upon execution. 103 | 104 | 105 | ## Rate limiters (rateLimitType) 106 | 107 | * REQUEST_WEIGHT 108 | 109 | ```json 110 | { 111 | "rateLimitType": "REQUEST_WEIGHT", 112 | "interval": "MINUTE", 113 | "intervalNum": 1, 114 | "limit": 6000 115 | } 116 | ``` 117 | 118 | * ORDERS 119 | 120 | ```json 121 | { 122 | "rateLimitType": "ORDERS", 123 | "interval": "SECOND", 124 | "intervalNum": 1, 125 | "limit": 10 126 | } 127 | ``` 128 | * RAW_REQUESTS 129 | 130 | ```json 131 | { 132 | "rateLimitType": "RAW_REQUESTS", 133 | "interval": "MINUTE", 134 | "intervalNum": 5, 135 | "limit": 61000 136 | } 137 | ``` 138 | 139 | ## Rate limit intervals (interval) 140 | 141 | * SECOND 142 | * MINUTE 143 | * DAY 144 | 145 | 146 | 147 | ## STP Modes 148 | 149 | Read [Self Trade Prevention (STP) FAQ](../faqs/stp_faq.md) to learn more. 150 | 151 | * `NONE` 152 | * `EXPIRE_MAKER` 153 | * `EXPIRE_TAKER` 154 | * `EXPIRE_BOTH` 155 | * `DECREMENT` 156 | -------------------------------------------------------------------------------- /testnet/sbe-market-data-streams.md: -------------------------------------------------------------------------------- 1 | # SBE Market Data Streams 2 | 3 | ## General Information 4 | 5 | * The base endpoint is **stream-sbe.testnet.binance.vision** or **stream-sbe.testnet.binance.vision:9443**. 6 | * To retrieve market data in JSON format, please refer to [this page](web-socket-streams.md). 7 | * SBE schema used for decoding the streams can be found [here](https://github.com/binance/binance-spot-api-docs/blob/master/sbe/schemas/stream_1_0.xml). 8 | * All symbols in stream names are **lowercase**. 9 | * You can subscribe to a single stream at **/ws/\**. 10 | * You can subscribe to multiple streams at **/stream?streams=\/\/\**. 11 | * A single connection to **stream-sbe.testnet.binance.vision** is **only valid for 24 hours**; expect to be disconnected at the 24 hour mark. 12 | * All time and timestamp fields are in **microseconds**. 13 | * **An API Key is necessary for access**. 14 | * Only Ed25519 keys are allowed. 15 | * Please put your API Key in the `X-MBX-APIKEY` header when opening the connection. Timestamp and signature are not necessary. 16 | * No extra API key permissions are necessary to access public market data. Symbol whitelist also does not affect access to SBE Market Data Streams. 17 | * However, if you use an IP whitelist for the API key, only specified IP addresses are allowed to use the API key. 18 | * The server sends a `ping frame` every 20 seconds. 19 | * If the server does not receive a `pong frame` back from you within a minute, the connection will be closed. 20 | * When you receive a ping, you must send a pong with a copy of ping's payload as soon as possible. 21 | * Unsolicited `pong frames` are allowed, but will not prevent disconnection. **It is recommended that the payload for these pong frames are empty.** 22 | * [Live Subscribing and Unsubscribing](web-socket-streams.md#live-subscribingunsubscribing-to-streams) is also supported. 23 | * You must send the subscription requests in JSON, and will receive the subscription response also in JSON. 24 | * You can differentiate subscription responses from market data events by looking at the WebSocket frame type: subscription responses are always sent in text frames (containing JSON), and events are always sent in binary frames (containing SBE). 25 | 26 | ## WebSocket Limits 27 | 28 | * WebSocket connections have a rate limit of **5 requests per second**. 29 | * Only messages from your client are considered: 30 | * `PING frame` 31 | * `PONG frame` 32 | * `Text frame` with JSON control request 33 | * Events pushed by the server are not rate-limited. 34 | * Connections that go beyond the limit will be closed. Repeatedly disconnected IP addresses may be banned. 35 | * A single connection can listen to a maximum of 1024 streams. 36 | * There is a limit of **300 connection attempts every 5 minutes per IP address**. 37 | 38 | ## Available Streams 39 | 40 | ### Trades Streams 41 | 42 | Raw trade information, pushed in real-time. 43 | 44 | **SBE Message Name:** `TradesStreamEvent` 45 | 46 | **Stream Name**: \@trade 47 | 48 | **Update Speed**: Real time 49 | 50 | ### Best Bid/Ask Streams 51 | 52 | The best bid and ask price and quantity, pushed in real-time when the order book changes. 53 | 54 | > [!NOTE] 55 | > Best bid/ask streams in SBE are the equivalent of bookTicker streams in JSON, except they support auto-culling, and also include the `eventTime` field. 56 | 57 | **SBE Message Name:** `BestBidAskStreamEvent` 58 | 59 | **Stream Name**: \@bestBidAsk 60 | 61 | **Update Speed**: Real time 62 | 63 | 64 | SBE best bid/ask streams use **auto-culling**: when our system is under high load, we may drop outdated events instead of queuing all events and delivering them with a delay. 65 | 66 | For example, if a best bid/ask event is generated at time T2 when we still have an undelivered event queued at time T1 (where T1 < T2), the event for T1 is dropped, and we will deliver only the event for T2. This is done on a per-symbol basis. 67 | 68 | ### Diff. Depth Streams 69 | 70 | Incremental updates to the order book, pushed at regular intervals. Use this stream to maintain a local order book. 71 | 72 | [How to manage a local order book.](web-socket-streams.md#how-to-manage-a-local-order-book-correctly) 73 | 74 | **SBE Message Name:** `DepthDiffStreamEvent` 75 | 76 | **Stream Name**: \@depth 77 | 78 | **Update Speed:** 100 ms 79 | 80 | ### Partial Book Depth Streams 81 | 82 | Snapshots of the top 20 levels of the order book, pushed at regular intervals. 83 | 84 | **SBE Message Name:** `DepthSnapshotStreamEvent` 85 | 86 | **Stream Name**: \@depth20 87 | 88 | **Update Speed:** 100ms 89 | -------------------------------------------------------------------------------- /testnet/user-data-stream.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* 4 | 5 | - [General WSS information](#general-wss-information) 6 | - [User Data Stream Events](#user-data-stream-events) 7 | - [Account Update](#account-update) 8 | - [Balance Update](#balance-update) 9 | - [Order Update](#order-update) 10 | - [Conditional Fields in Execution Report](#conditional-fields-in-execution-report) 11 | - [Order Reject Reason](#order-reject-reason) 12 | - [Execution types](#execution-types) 13 | - [Listen Key Expired](#listen-key-expired) 14 | - [Event Stream Terminated](#event-stream-terminated) 15 | - [External Lock Update](#external-lock-update) 16 | 17 | 18 | 19 | # User Data Streams for Binance Spot TESTNET 20 | 21 | **Last Updated: 2025-04-08** 22 | 23 | # General WSS information 24 | 25 | * There are currently two ways to subscribe to the User Data Stream: 26 | * **[Preferred]** Subscribing directly through the [WebSocket API](web-socket-api.md#user-data-stream-subscribe) using an API Key. 27 | * **[Deprecated]** Generating a **listen key** using [the REST API](rest-api.md#user-data-stream-requests) or [the WebSocket API](web-socket-api.md#user-data-stream-requests) and using it to listen on **stream.binance.com** 28 | * Both sources will push all events related to your account **in real-time**. 29 | * How to use a listen key on **stream.testnet.binance.vision**: 30 | * The base endpoint is: **wss://stream.testnet.binance.vision:9443** or **wss://stream.testnet.binance.vision:443**. 31 | * A single connection to **stream.binance.com** is only valid for 24 hours; expect to be disconnected at the 24 hour mark. 32 | * User Data Streams are accessed at **/ws/\** or **/stream?streams=\** 33 | * All time and timestamp related fields in the JSON payload are **milliseconds by default**. To receive the information in microseconds, please add the parameter `timeUnit=MICROSECOND` or `timeUnit=microsecond` in the connection URL. 34 | * For example `/ws/?timeUnit=MICROSECOND` 35 | 36 | ## User Data Stream Events 37 | ### Account Update 38 | 39 | `outboundAccountPosition` is sent any time an account balance has changed and contains the assets that were possibly changed by the event that generated the balance change. 40 | 41 | ```javascript 42 | { 43 | "e": "outboundAccountPosition", // Event type 44 | "E": 1564034571105, // Event Time 45 | "u": 1564034571073, // Time of last account update 46 | "B": [ // Balances Array 47 | { 48 | "a": "ETH", // Asset 49 | "f": "10000.000000", // Free 50 | "l": "0.000000" // Locked 51 | } 52 | ] 53 | } 54 | ``` 55 | 56 | ### Balance Update 57 | 58 | Balance Update occurs during the following: 59 | * Deposits or withdrawals from the account 60 | * Transfer of funds between accounts (e.g. Spot to Margin) 61 | 62 | **Payload** 63 | ```javascript 64 | { 65 | "e": "balanceUpdate", // Event Type 66 | "E": 1573200697110, // Event Time 67 | "a": "BTC", // Asset 68 | "d": "100.00000000", // Balance Delta 69 | "T": 1573200697068 // Clear Time 70 | } 71 | ``` 72 | 73 | ### Order Update 74 | Orders are updated with the `executionReport` event. 75 | 76 | **Payload:** 77 | ```javascript 78 | { 79 | "e": "executionReport", // Event type 80 | "E": 1499405658658, // Event time 81 | "s": "ETHBTC", // Symbol 82 | "c": "mUvoqJxFIILMdfAW5iGSOW", // Client order ID 83 | "S": "BUY", // Side 84 | "o": "LIMIT", // Order type 85 | "f": "GTC", // Time in force 86 | "q": "1.00000000", // Order quantity 87 | "p": "0.10264410", // Order price 88 | "P": "0.00000000", // Stop price 89 | "F": "0.00000000", // Iceberg quantity 90 | "g": -1, // OrderListId 91 | "C": "", // Original client order ID; This is the ID of the order being canceled 92 | "x": "NEW", // Current execution type 93 | "X": "NEW", // Current order status 94 | "r": "NONE", // Order reject reason; Please see Order Reject Reason (below) for more information. 95 | "i": 4293153, // Order ID 96 | "l": "0.00000000", // Last executed quantity 97 | "z": "0.00000000", // Cumulative filled quantity 98 | "L": "0.00000000", // Last executed price 99 | "n": "0", // Commission amount 100 | "N": null, // Commission asset 101 | "T": 1499405658657, // Transaction time 102 | "t": -1, // Trade ID 103 | "v": 3, // Prevented Match Id; This is only visible if the order expired due to STP 104 | "I": 8641984, // Execution Id 105 | "w": true, // Is the order on the book? 106 | "m": false, // Is this trade the maker side? 107 | "M": false, // Ignore 108 | "O": 1499405658657, // Order creation time 109 | "Z": "0.00000000", // Cumulative quote asset transacted quantity 110 | "Y": "0.00000000", // Last quote asset transacted quantity (i.e. lastPrice * lastQty) 111 | "Q": "0.00000000", // Quote Order Quantity 112 | "W": 1499405658657, // Working Time; This is only visible if the order has been placed on the book. 113 | "V": "NONE" // SelfTradePreventionMode 114 | } 115 | ``` 116 | 117 | **Note:** Average price can be found by doing `Z` divided by `z`. 118 | 119 | #### Conditional Fields in Execution Report 120 | 121 | These are fields that appear in the payload only if certain conditions are met. 122 | 123 | For additional information on these parameters, please refer to the [Spot Glossary](./faqs/spot_glossary.md). 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 |
FieldNameDescriptionExamples
dTrailing DeltaAppears only for trailing stop orders."d": 4
DTrailing Time"D": 1668680518494
jStrategy IdAppears only if the strategyId parameter was provided upon order placement."j": 1
JStrategy TypeAppears only if the strategyType parameter was provided upon order placement."J": 1000000
vPrevented Match IdAppears only for orders that expired due to STP."v": 3
A 163 | Prevented Quantity"A":"3.000000"
BLast Prevented Quantity"B":"3.000000"
uTrade Group Id"u":1
UCounter Order Id"U":37
CsCounter Symbol"Cs": "BTCUSDT"
plPrevented Execution Quantity"pl":"2.123456"
pLPrevented Execution Price"pL":"0.10000001"
pYPrevented Execution Quote Qty"pY":"0.21234562"
WWorking TimeAppears when the order is working on the book"W": 1668683798379
bMatch TypeAppears for orders that have allocations"b":"ONE_PARTY_TRADE_REPORT"
aAllocation ID"a":1234
kWorking FloorAppears for orders that potentially have allocations"k":"SOR"
uSUsedSorAppears for orders that used SOR"uS":true
231 | 232 | #### Order Reject Reason 233 | 234 | For additional details, look up the Error Message in the [Errors](errors.md#other-errors) documentation. 235 | 236 | |Rejection Reason (`r`)| Error Message| 237 | |--- | --- | 238 | |`NONE` | N/A (i.e. The order was not rejected.)| 239 | |`INSUFFICIENT_BALANCES`|"Account has insufficient balance for requested action."| 240 | |`STOP_PRICE_WOULD_TRIGGER_IMMEDIATELY`|"Order would trigger immediately."| 241 | |`WOULD_MATCH_IMMEDIATELY`|"Order would immediately match and take."| 242 | |`OCO_BAD_PRICES`|"The relationship of the prices for the orders is not correct."| 243 | 244 | If the order is an order list, an event named `ListStatus` will be sent in addition to the `executionReport` event. 245 | 246 | **Payload** 247 | ```javascript 248 | { 249 | "e": "listStatus", // Event Type 250 | "E": 1564035303637, // Event Time 251 | "s": "ETHBTC", // Symbol 252 | "g": 2, // OrderListId 253 | "c": "OCO", // Contingency Type 254 | "l": "EXEC_STARTED", // List Status Type 255 | "L": "EXECUTING", // List Order Status 256 | "r": "NONE", // List Reject Reason 257 | "C": "F4QN4G8DlFATFlIUQ0cjdD", // List Client Order ID 258 | "T": 1564035303625, // Transaction Time 259 | "O": [ // An array of objects 260 | { 261 | "s": "ETHBTC", // Symbol 262 | "i": 17, // OrderId 263 | "c": "AJYsMjErWJesZvqlJCTUgL" // ClientOrderId 264 | }, 265 | { 266 | "s": "ETHBTC", 267 | "i": 18, 268 | "c": "bfYPSQdLoqAJeNrOr9adzq" 269 | } 270 | ] 271 | } 272 | ``` 273 | 274 | #### Execution types 275 | 276 | * `NEW` - The order has been accepted into the engine. 277 | * `CANCELED` - The order has been canceled by the user. 278 | * `REPLACED` - The order has been amended. 279 | * `REJECTED` - The order has been rejected and was not processed. (e.g. Cancel Replace orders where the new order placement was rejected even if the cancel request succeeded.) 280 | * `TRADE` - Part of the order or all of the order's quantity has filled. 281 | * `EXPIRED` - The order was canceled according to the order type's rules (e.g. LIMIT FOK orders with no fill, LIMIT IOC or MARKET orders that partially fill) or by the exchange, (e.g. orders canceled during liquidation, orders canceled during maintenance). 282 | * `TRADE_PREVENTION` - The order has expired due to STP. 283 | 284 | Check the [Enums Documentation](enums.md) for more relevant enum definitions. 285 | 286 | ### Listen Key Expired 287 | 288 | This event is sent when the listen key expires. 289 | 290 | No more events will be sent after this until a new `listenKey` is created. 291 | 292 | This event will not be pushed when the stream is closed normally. 293 | 294 | **Payload:** 295 | 296 | ```javascript 297 | { 298 | "e": "listenKeyExpired", // Event type 299 | "E": "1699596037418", // Event time 300 | "listenKey": "OfYGbUzi3PraNagEkdKuFwUHn48brFsItTdsuiIXrucEvD0rhRXZ7I6URWfE8YE8" 301 | } 302 | ``` 303 | 304 | ### Event Stream Terminated 305 | 306 | This event appears only for WebSocket API. 307 | 308 | `eventStreamTerminated` is sent when the User Data Stream is stopped. For example, after you send a `userDataStream.unsubscribe` request, or a `session.logout` request. 309 | 310 | **Payload:** 311 | 312 | ```javascript 313 | { 314 | "event": { 315 | "e": "eventStreamTerminated", // Event Type 316 | "E": 1728973001334 // Event Time 317 | } 318 | } 319 | ``` 320 | 321 | ### External Lock Update 322 | 323 | `externalLockUpdate` is sent when part of your spot wallet balance is locked/unlocked by an external system, for example when used as margin collateral. 324 | 325 | **Payload:** 326 | 327 | ```javascript 328 | { 329 | "e": "externalLockUpdate", // Event Type 330 | "E": 1581557507324, // Event Time 331 | "a": "NEO", // Asset 332 | "d": "10.00000000", // Delta 333 | "T": 1581557507268 // Transaction Time 334 | }``` 335 | -------------------------------------------------------------------------------- /user-data-stream.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* 4 | 5 | - [User Data Stream Events](#user-data-stream-events) 6 | - [Account Update](#account-update) 7 | - [Balance Update](#balance-update) 8 | - [Order Update](#order-update) 9 | - [Conditional Fields in Execution Report](#conditional-fields-in-execution-report) 10 | - [Order Reject Reason](#order-reject-reason) 11 | - [Listen Key Expired](#listen-key-expired) 12 | - [Event Stream Terminated](#event-stream-terminated) 13 | - [External Lock Update](#external-lock-update) 14 | 15 | 16 | 17 | # User Data Streams for Binance 18 | 19 | **Last Updated: 2025-04-08** 20 | 21 | * There are currently two ways to subscribe to the User Data Stream: 22 | * **[Preferred]** Subscribing directly through the [WebSocket API](web-socket-api.md#user_data_stream_subscribe) using an API Key. 23 | * **[Deprecated]** Generating a **listen key** using [the REST API](rest-api.md#user-data-stream-requests) or [the WebSocket API](web-socket-api.md#user-data-stream-requests) and using it to listen on **stream.binance.com** 24 | * Both sources will push all events related to your account **in real-time**. 25 | * How to use a listen key on **stream.binance.com**: 26 | * The base endpoint is: **wss://stream.binance.com:9443** or **wss://stream.binance.com:443**. 27 | * A single connection to **stream.binance.com** is only valid for 24 hours; expect to be disconnected at the 24 hour mark. 28 | * User Data Streams are accessed at **/ws/\** or **/stream?streams=\** 29 | * All time and timestamp related fields in the JSON payload are **milliseconds by default**. To receive the information in microseconds, please add the parameter `timeUnit=MICROSECOND` or `timeUnit=microsecond` in the connection URL. 30 | * For example `/ws/?timeUnit=MICROSECOND` 31 | 32 | 33 | ## User Data Stream Events 34 | ### Account Update 35 | 36 | `outboundAccountPosition` is sent any time an account balance has changed and contains the assets that were possibly changed by the event that generated the balance change. 37 | 38 | ```javascript 39 | { 40 | "e": "outboundAccountPosition", // Event type 41 | "E": 1564034571105, // Event Time 42 | "u": 1564034571073, // Time of last account update 43 | "B": [ // Balances Array 44 | { 45 | "a": "ETH", // Asset 46 | "f": "10000.000000", // Free 47 | "l": "0.000000" // Locked 48 | } 49 | ] 50 | } 51 | ``` 52 | 53 | ### Balance Update 54 | 55 | Balance Update occurs during the following: 56 | * Deposits or withdrawals from the account 57 | * Transfer of funds between accounts (e.g. Spot to Margin) 58 | 59 | **Payload** 60 | 61 | ```javascript 62 | { 63 | "e": "balanceUpdate", // Event Type 64 | "E": 1573200697110, // Event Time 65 | "a": "BTC", // Asset 66 | "d": "100.00000000", // Balance Delta 67 | "T": 1573200697068 // Clear Time 68 | } 69 | ``` 70 | 71 | ### Order Update 72 | Orders are updated with the `executionReport` event. 73 | 74 | We recommend using the [FIX API](fix-api.md) for better performance compared to using the User Data Streams. 75 | 76 | **Payload:** 77 | 78 | ```javascript 79 | { 80 | "e": "executionReport", // Event type 81 | "E": 1499405658658, // Event time 82 | "s": "ETHBTC", // Symbol 83 | "c": "mUvoqJxFIILMdfAW5iGSOW", // Client order ID 84 | "S": "BUY", // Side 85 | "o": "LIMIT", // Order type 86 | "f": "GTC", // Time in force 87 | "q": "1.00000000", // Order quantity 88 | "p": "0.10264410", // Order price 89 | "P": "0.00000000", // Stop price 90 | "F": "0.00000000", // Iceberg quantity 91 | "g": -1, // OrderListId 92 | "C": "", // Original client order ID; This is the ID of the order being canceled 93 | "x": "NEW", // Current execution type 94 | "X": "NEW", // Current order status 95 | "r": "NONE", // Order reject reason; Please see Order Reject Reason (below) for more information. 96 | "i": 4293153, // Order ID 97 | "l": "0.00000000", // Last executed quantity 98 | "z": "0.00000000", // Cumulative filled quantity 99 | "L": "0.00000000", // Last executed price 100 | "n": "0", // Commission amount 101 | "N": null, // Commission asset 102 | "T": 1499405658657, // Transaction time 103 | "t": -1, // Trade ID 104 | "v": 3, // Prevented Match Id; This is only visible if the order expired due to STP 105 | "I": 8641984, // Execution Id 106 | "w": true, // Is the order on the book? 107 | "m": false, // Is this trade the maker side? 108 | "M": false, // Ignore 109 | "O": 1499405658657, // Order creation time 110 | "Z": "0.00000000", // Cumulative quote asset transacted quantity 111 | "Y": "0.00000000", // Last quote asset transacted quantity (i.e. lastPrice * lastQty) 112 | "Q": "0.00000000", // Quote Order Quantity 113 | "W": 1499405658657, // Working Time; This is only visible if the order has been placed on the book. 114 | "V": "NONE" // SelfTradePreventionMode 115 | } 116 | ``` 117 | 118 | **Note:** Average price can be found by doing `Z` divided by `z`. 119 | 120 | #### Conditional Fields in Execution Report 121 | 122 | These are fields that appear in the payload only if certain conditions are met. 123 | 124 | For additional information on these parameters, please refer to the [Spot Glossary](./faqs/spot_glossary.md). 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 |
FieldNameDescriptionExamples
dTrailing DeltaAppears only for trailing stop orders."d": 4
DTrailing Time"D": 1668680518494
jStrategy IdAppears only if the strategyId parameter was provided upon order placement."j": 1
JStrategy TypeAppears only if the strategyType parameter was provided upon order placement."J": 1000000
vPrevented Match IdAppears only for orders that expired due to STP."v": 3
A 164 | Prevented Quantity"A":"3.000000"
BLast Prevented Quantity"B":"3.000000"
uTrade Group Id"u":1
UCounter Order Id"U":37
CsCounter Symbol"Cs": "BTCUSDT"
plPrevented Execution Quantity"pl":"2.123456"
pLPrevented Execution Price"pL":"0.10000001"
pYPrevented Execution Quote Qty"pY":"0.21234562"
WWorking TimeAppears when the order is working on the book"W": 1668683798379
bMatch TypeAppears for orders that have allocations"b":"ONE_PARTY_TRADE_REPORT"
aAllocation ID"a":1234
kWorking FloorAppears for orders that potentially have allocations"k":"SOR"
uSUsedSorAppears for orders that used SOR"uS":true
232 | 233 | #### Order Reject Reason 234 | 235 | For additional details, look up the Error Message in the [Errors](errors.md#other-errors) documentation. 236 | 237 | |Rejection Reason (`r`)| Error Message| 238 | |--- | --- | 239 | |`NONE` | N/A (i.e. The order was not rejected.)| 240 | |`INSUFFICIENT_BALANCES`|"Account has insufficient balance for requested action."| 241 | |`STOP_PRICE_WOULD_TRIGGER_IMMEDIATELY`|"Order would trigger immediately."| 242 | |`WOULD_MATCH_IMMEDIATELY`|"Order would immediately match and take."| 243 | |`OCO_BAD_PRICES`|"The relationship of the prices for the orders is not correct."| 244 | 245 | If the order is an order list, an event named `ListStatus` will be sent in addition to the `executionReport` event. 246 | 247 | **Payload** 248 | 249 | ```javascript 250 | { 251 | "e": "listStatus", // Event Type 252 | "E": 1564035303637, // Event Time 253 | "s": "ETHBTC", // Symbol 254 | "g": 2, // OrderListId 255 | "c": "OCO", // Contingency Type 256 | "l": "EXEC_STARTED", // List Status Type 257 | "L": "EXECUTING", // List Order Status 258 | "r": "NONE", // List Reject Reason 259 | "C": "F4QN4G8DlFATFlIUQ0cjdD", // List Client Order ID 260 | "T": 1564035303625, // Transaction Time 261 | "O": [ // An array of objects 262 | { 263 | "s": "ETHBTC", // Symbol 264 | "i": 17, // OrderId 265 | "c": "AJYsMjErWJesZvqlJCTUgL" // ClientOrderId 266 | }, 267 | { 268 | "s": "ETHBTC", 269 | "i": 18, 270 | "c": "bfYPSQdLoqAJeNrOr9adzq" 271 | } 272 | ] 273 | } 274 | ``` 275 | 276 | **Execution types:** 277 | 278 | * `NEW` - The order has been accepted into the engine. 279 | * `CANCELED` - The order has been canceled by the user. 280 | * `REPLACED` - The order has been amended. 281 | * `REJECTED` - The order has been rejected and was not processed (e.g. Cancel Replace Orders wherein the new order placement is rejected but the request to cancel request succeeds.) 282 | * `TRADE` - Part of the order or all of the order's quantity has filled. 283 | * `EXPIRED` - The order was canceled according to the order type's rules (e.g. LIMIT FOK orders with no fill, LIMIT IOC or MARKET orders that partially fill) or by the exchange, (e.g. orders canceled during liquidation, orders canceled during maintenance). 284 | * `TRADE_PREVENTION` - The order has expired due to STP. 285 | 286 | Check the [Enums page](./enums.md) for more relevant enum definitions. 287 | 288 | ### Listen Key Expired 289 | 290 | This event is sent when the listen key expires. 291 | 292 | No more events will be sent after this until a new `listenKey` is created. 293 | 294 | This event will not be pushed when the stream is closed normally. 295 | 296 | **Payload:** 297 | 298 | ```javascript 299 | { 300 | "e": "listenKeyExpired", // Event type 301 | "E": 1699596037418, // Event time 302 | "listenKey": "OfYGbUzi3PraNagEkdKuFwUHn48brFsItTdsuiIXrucEvD0rhRXZ7I6URWfE8YE8" 303 | } 304 | ``` 305 | 306 | ## Event Stream Terminated 307 | 308 | This event appears only when subscribed on the WebSocket API. 309 | 310 | `eventStreamTerminated` is sent when the User Data Stream is stopped. For example, after you send a `userDataStream.unsubscribe` request, or a `session.logout` request. 311 | 312 | **Payload:** 313 | 314 | ```javascript 315 | { 316 | "event": { 317 | "e": "eventStreamTerminated", // Event Type 318 | "E": 1728973001334 // Event Time 319 | } 320 | } 321 | ``` 322 | 323 | ## External Lock Update 324 | 325 | `externalLockUpdate` is sent when part of your spot wallet balance is locked/unlocked by an external system, for example when used as margin collateral. 326 | 327 | **Payload:** 328 | 329 | ```javascript 330 | { 331 | "e": "externalLockUpdate", // Event Type 332 | "E": 1581557507324, // Event Time 333 | "a": "NEO", // Asset 334 | "d": "10.00000000", // Delta 335 | "T": 1581557507268 // Transaction Time 336 | } 337 | ``` 338 | -------------------------------------------------------------------------------- /user-data-stream_CN.md: -------------------------------------------------------------------------------- 1 | # WebSocket 账户接口 2 | 3 | **最近更新: 2025-04-09** 4 | 5 | ## 基本信息 6 | * 目前有两种方法可以订阅 User Data Stream: 7 | * **[首选]** 直接通过 [WebSocket API](web-socket-api_CN.md#user_data_stream_susbcribe) 使用 API 密钥. 8 | * **[已弃用]** 通过使用 [REST API](rest-api_CN.md#user-data-stream-requests)或 [WebSocket API](web-socket-api_CN.md#user-data-stream-requests)生成一个 **listen key** 并使用它来监听 **stream.binance.com**。 9 | * 两个源都将**实时** 推送与您的帐户相关的所有事件. 10 | * 如何在 **stream.binance.com** 使用 `listen key`: 11 | * 基本端点是**wss://stream.binance.com:9443** 或 **wss://stream.binance.com:443**。 12 | * 连接到 **stream.binance.com** 的连接仅在 24 小时内有效;将会在到达 24 小时时断开连接。 13 | * 用户数据流可通过 **/WS/\** 或 **/stream?streams=\** 访问。 14 | * JSON payload 中所有与时间和时间戳相关的字段默认为 **毫秒**。以微秒为单位接收信息,请在连接 URL 中添加参数 `timeUnit=MICROSECOND` 或 `timeUnit=microsecond`。 15 | * 例如 `/WS/?timeUnit=MICROSECOND` 16 | 17 | ## 用户数据流事件 18 | 19 | ### 账户更新 20 | 21 | 每当帐户余额发生更改时,都会发送一个事件`outboundAccountPosition`,其中包含可能由生成余额变动的事件而变动的资产。 22 | 23 | **Payload** 24 | 25 | ```javascript 26 | { 27 | "e": "outboundAccountPosition", // 事件类型 28 | "E": 1564034571105, // 事件时间 29 | "u": 1564034571073, // 账户末次更新时间戳 30 | "B": [ // 余额 31 | { 32 | "a": "ETH", // 资产名称 33 | "f": "10000.000000", // 可用余额 34 | "l": "0.000000" // 冻结余额 35 | } 36 | ] 37 | } 38 | ``` 39 | 40 | ### 余额更新 41 | 42 | 当下列情形发生时更新: 43 | 44 | * 账户发生充值或提取 45 | * 交易账户之间发生划转(例如 现货向杠杆账户划转) 46 | 47 | **Payload** 48 | 49 | ```javascript 50 | { 51 | "e": "balanceUpdate", // Event Type 52 | "E": 1573200697110, // Event Time 53 | "a": "ABC", // Asset 54 | "d": "100.00000000", // Balance Delta 55 | "T": 1573200697068 // Clear Time 56 | } 57 | ``` 58 | 59 | 60 | ### 订单更新 61 | 订单通过`executionReport`事件进行更新。 62 | 63 | 与使用用户数据流相比,我们建议使用 [FIX API](fix-api_CN.md) 以获得更好的性能。 64 | 65 | 66 | **Payload:** 67 | 68 | ```javascript 69 | { 70 | "e": "executionReport", // 事件类型 71 | "E": 1499405658658, // 事件时间 72 | "s": "ETHBTC", // 交易对 73 | "c": "mUvoqJxFIILMdfAW5iGSOW", // clientOrderId 74 | "S": "BUY", // 订单方向 75 | "o": "LIMIT", // 订单类型 76 | "f": "GTC", // 有效方式 77 | "q": "1.00000000", // 订单原始数量 78 | "p": "0.10264410", // 订单原始价格 79 | "P": "0.00000000", // 止盈止损单触发价格 80 | "F": "0.00000000", // 冰山订单数量 81 | "g": -1, // OCO订单 OrderListId 82 | "C": "", // 原始订单自定义ID(原始订单,指撤单操作的对象。撤单本身被视为另一个订单) 83 | "x": "NEW", // 本次事件的具体执行类型 84 | "X": "NEW", // 订单的当前状态 85 | "r": "NONE", // 订单被拒绝的原因;请参阅订单被拒绝的原因(下文)了解更多信息 86 | "i": 4293153, // orderId 87 | "l": "0.00000000", // 订单末次成交量 88 | "z": "0.00000000", // 订单累计已成交量 89 | "L": "0.00000000", // 订单末次成交价格 90 | "n": "0", // 手续费数量 91 | "N": null, // 手续费资产类别 92 | "T": 1499405658657, // 成交时间 93 | "I": 8641984, // Execution ID 94 | "w": true, // 订单是否在订单簿上? 95 | "m": false, // 该成交是作为挂单成交吗? 96 | "M": false, // 请忽略 97 | "O": 1499405658657, // 订单创建时间 98 | "Z": "0.00000000", // 订单累计已成交金额 99 | "Y": "0.00000000", // 订单末次成交金额 100 | "Q": "0.00000000", // Quote Order Quantity 101 | "D": 1668680518494, // 追踪时间; 这仅在追踪止损订单已被激活时可见 102 | "W": 1499405658657, // Working Time; 订单被添加到 order book 的时间 103 | "V": "NONE" // SelfTradePreventionMode 104 | } 105 | ``` 106 | 107 | **备注:** 通过将`Z`除以`z`可以找到平均价格。 108 | 109 | #### `executionReport` 中的特定条件时才会出现的字段 110 | 111 | 这些字段仅在满足特定条件时才会出现。有关这些参数的更多信息,请参阅 [现货交易API术语表](./faqs/spot_glossary_CN.md)。 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 |
字段名称描述示例
dTrailing Delta出现在追踪止损订单中。"d": 4
DTrailing Time"D": 1668680518494
jStrategy Id如果在请求中添加了strategyId参数,则会出现。"j": 1
JStrategy Type如果在请求中添加了strategyType参数,则会出现。"J": 1000000
vPrevented Match Id只有在因为 STP 导致订单失效时可见。"v": 3
A 151 | Prevented Quantity"A":"3.000000"
BLast Prevented Quantity"B":"3.000000"
uTrade Group Id"u":1
UCounter Order Id"U":37
CsCounter Symbol"Cs": "BTCUSDT"
plPrevented Execution Quantity"pl":"2.123456"
pLPrevented Execution Price"pL":"0.10000001"
pYPrevented Execution Quote Qty"pY":"0.21234562"
WWorking Time只有在订单在订单簿上时可见"W": 1668683798379
bMatch Type只有在订单有分配时可见"b":"ONE_PARTY_TRADE_REPORT"
aAllocation ID"a":1234
kWorking Floor只有在订单可能有分配时可见"k":"SOR"
uSUsedSor只有在订单使用 SOR 时可见"uS":true
219 | 220 | #### 订单拒绝原因 221 | 222 | 有关更多详细信息,请查阅 [错误代码汇总](errors_CN.md#other-errors) 文档中的错误消息。 223 | 224 | |拒绝原因 (`r`)| 错误信息| 225 | |--- | --- | 226 | |`NONE` | N/A (i.e. The order was not rejected.)| 227 | |`INSUFFICIENT_BALANCES`|"Account has insufficient balance for requested action."| 228 | |`STOP_PRICE_WOULD_TRIGGER_IMMEDIATELY`|"Order would trigger immediately."| 229 | |`WOULD_MATCH_IMMEDIATELY`|"Order would immediately match and take."| 230 | |`OCO_BAD_PRICES`|"The relationship of the prices for the orders is not correct."| 231 | 232 | 如果是一个订单组,则除了显示 `executionReport` 事件外,还将显示一个名为 `ListStatus` 的事件。 233 | 234 | **Payload** 235 | 236 | ```javascript 237 | { 238 | "e": "listStatus", // 事件类型 239 | "E": 1564035303637, // 事件时间 240 | "s": "ETHBTC", // 交易对 241 | "g": 2, // OrderListId 242 | "c": "OCO", // Contingency Type 243 | "l": "EXEC_STARTED", // List Status Type 244 | "L": "EXECUTING", // List Order Status 245 | "r": "NONE", // List 被拒绝的原因 246 | "C": "F4QN4G8DlFATFlIUQ0cjdD", // List Client Order ID 247 | "T": 1564035303625, // 成交时间 248 | "O": [ 249 | { 250 | "s": "ETHBTC", // 交易对 251 | "i": 17, // orderId 252 | "c": "AJYsMjErWJesZvqlJCTUgL" // clientOrderId 253 | }, 254 | { 255 | "s": "ETHBTC", 256 | "i": 18, 257 | "c": "bfYPSQdLoqAJeNrOr9adzq" 258 | } 259 | ] 260 | } 261 | ``` 262 | 263 | **可能的执行类型:** 264 | 265 | * `NEW` - 新订单已被引擎接受。 266 | * `CANCELED` - 订单被用户取消。 267 | * `REPLACED` - 订单已被修改。 268 | * `REJECTED` - 新订单被拒绝 (e.g. 在撤消挂单再下单时,其中新订单被拒绝但撤消挂单请求成功)。 269 | * `TRADE` - 订单有新成交。 270 | * `EXPIRED` - 订单已根据 Time In Force 参数的规则取消(e.g. 没有成交的 LIMIT FOK 订单或部分成交的 LIMIT IOC 订单)或者被交易所取消(e.g. 强平或维护期间取消的订单)。 271 | * `TRADE_PREVENTION` - 订单因 STP 触发而过期。 272 | 273 | 请查阅 [枚举定义](./enums_CN.md) 文档获取更多枚举定义。 274 | 275 | ### Listen Key 已过期 276 | 277 | 当监听 listen key 过期时会发送此事件。此后不会再发送任何事件,直到创建新的 `listenKey`。 278 | 279 | 正常关闭流时不会推送该事件。 280 | 281 | **Payload:** 282 | 283 | ```javascript 284 | { 285 | "e": "listenKeyExpired", // 事件类型 286 | "E": 1699596037418, // 事件时间 287 | "listenKey": "OfYGbUzi3PraNagEkdKuFwUHn48brFsItTdsuiIXrucEvD0rhRXZ7I6URWfE8YE8" 288 | } 289 | ``` 290 | 291 | 292 | ## 事件流已终止 293 | 294 | 此事件仅在订阅 WebSocket API 时显示。 295 | 296 | 当账户数据流被终止时,`eventStreamTerminated` 会被发送。例如,在您发送 `userDataStream.unsubscribe` 请求或 `session.logout` 请求之后。 297 | 298 | **Payload:** 299 | 300 | ```javascript 301 | { 302 | "event": { 303 | "e": "eventStreamTerminated", // Event Type 304 | "E": 1728973001334 // Event Time 305 | } 306 | } 307 | ``` 308 | 309 | ## 外部锁定更新 310 | 311 | 当您的现货钱包余额被外部系统锁定/解锁时 (例如,当用作保证金抵押品时),新事件 `externalLockUpdate` 将会被发送。 312 | 313 | **Payload:** 314 | 315 | ```javascript 316 | { 317 | "e": "externalLockUpdate", // Event Type 318 | "E": 1581557507324, // Event Time 319 | "a": "NEO", // Asset 320 | "d": "10.00000000", // Delta 321 | "T": 1581557507268 // Transaction Time 322 | } 323 | ``` 324 | --------------------------------------------------------------------------------