自我交易预防 (Self Trade Prevention - STP) 常见问题
什么是 Self Trade Prevention - STP?
自我交易预防是指阻止订单与来自同一账户或者同一 tradeGroupId
账户的订单交易。
什么是自我交易(self-trade)?
在以下任一情况下都可能发生自我交易:
- 属于同一账户的订单之间交易。
- 属于相同
tradeGroupId
的账户的订单之间交易。
STP 触发时会发生什么?
如果订单会触发自我交易,系统将执行四种可能的模式:
NONE
- 此模式使订单免于自我交易预防。
EXPIRE_TAKER
- 此模式通过立即使吃单者(taker)的剩余数量过期来预防交易。
EXPIRE_MAKER
- 此模式通过立即使潜在挂单者(maker)的剩余数量过期来预防交易。
EXPIRE_BOTH
- 此模式通过立即同时使吃单和挂单者的剩余数量过期来预防交易。
STP 的发生取决于 Taker 订单 的 STP 模式。
因此,订单薄上的订单的 STP 模式不再有效果,并且将在所有未来的订单处理中被忽略。
如何在订单上设置自我交易预防 ?
自我交易预防可以通 过下单接口的参数selfTradePreventionMode
设置,相关接口如下:
- POST
/fapi/v1/order
- POST
/fapi/v1/batchOrders
什么是交易组 Id(Trade Group Id)?
属于同一 tradeGroupId
的账户被视为同一交易组。相同交易组成员提交的订单有 STP 资格。
每个账户可以从 GET fapi/v2/account
(REST API)确认账户是否属于同一个 tradeGroupId
。
tradeGroupId
也存在 GET /api/v3/preventedMatches
(Rest API)或 myPreventedMatches
(Websocket API)的响应中。
如果该值为 -1
,这表示账户未设置 tradeGroupId
,因此 STP 只能发生在同一账户的订单之间。
我们将在之后的更新提供将子账户设置为同一tradeGroupId
的功能
如何知道有那些交易对支持 STP?
所有GET fapi/v1/exchangeInfo
中的交易对都支持selfTradePreventionMode
。