Эта статья еще не переведена на ваш язык.

STP for Binance Alpha 2.0 Limit Order

Опубликовано 2025-12-03 06:07

What Is Self Trade Prevention (STP)?

Self Trade Prevention (STP) is a mechanism employed by trading platforms to prevent users from inadvertently trading against themselves. In auction matching, there is theoretically no direct counterparty. All matched buy orders collectively serve as the counterparty to the matched sell orders. 

To prevent self-trading, if a user submits orders with a price that is better than or equal to the execution price from both the buy and sell side, only one side of their orders is allowed to enter the matching phase. To achieve this, we introduce a pre-netting phase to calculate the net trading volume for that user. This net volume then proceeds to the matching phases, while any unmatched volume (the net-off volume, or self trading volume) is carried over to the next auction window (RETAIN).


The pre-netting volume is calculated using the following formula: 

netted_quantity_for_user_at_certain_price_level = abs(quantity_eligible_bids - quantity_eligible_asks) 

Here, quantity_eligible_bids and quantity_eligible_asks refer to the bid and ask orders that satisfy the given price level. The side of net order will be determined by whichever bid side or ask side has the greater order quantity.

For the net-off volume, or self trading volume, the following scenario is possible:

1. RETAIN

The net quantity of the order will be matched first and the net-off volume will not be matched. Net-off orders will stay in the orderbook and are carried over to the next auction window until the user cancels or an order is filled with a counterparty.

API changes

All orders placed (whether it is limit order or any other order) will be using STP mode RETAIN by default. This means no changes are required to the order placement from the user side and STP will be effective for all orders.

Example:

Setup - Execution price P* = 50
User A placed orders with a price which is better than or equal to the execution price P* on both   

bids and asks.

 

Bid Quantity

Total Bid Quantity

 

Ask Quantity

Total Ask Quantity

BID Price 52

200

300

ASK Price 49

80

180

BID Price 50

100

ASK Price 50

100

User A’s net quantity of this auction round = |300 qty -180 qty | = 120 qty 
Netted side = Bid (because 300 qty > 180 qty) = 120 Bid qty

User A’s net-off volume into the next round = 180 Ask qty and 180 Bid qty

At the same time, User B joined this auction round with asks at P*: 

 

Ask Quantity

Total Ask Quantity

ASK Price 49

50

150

ASK Price 50

100

User B’s net quantity of this auction round = 150 Ask qty

User B’s net-off volume = 0

Matching and carry-over phase

Match result: User A’s net 120 bid qty with P* = 50 will be matched with User B’s 120 ask qty with P* = 50

Carry-over results: In RETAIN mode, this overlap does not cancel; it is retained and carried over to the next auction window on both sides:

User A will carry-over 180 bid qty and 180 ask qty with P* = 50

User B will carry-over 30 ask qty with P* = 50, following the standard auction carry-over rules.

User A’s Result

Net 120 bid qty filled with User B’s 120 ask qty, other net-off qty will be carried over to the next auction


 

Bid Side 

Order 1

Order 2

200 bid qty @ Price 52

(status: PARTIALLY_FILLED - 120 qty)

100 bid qty @ Price 50

 (status: NEW)


 

Ask Side 

80 ask qty @ Price 49

(status: NEW) 

100 ask qty @ Price 50 

(status: NEW)

User B’s Result 

120 ask qty filled with User A’s net 120 bid qty, leaving 30 ask qty to carry-over to the next auction


 

Ask Side 

50 qty @ Price 49 

(status: FILLED - 50 qty)

100 qty @ Price 50 

(status: PARTIALLY_FILLED - 70 qty)

Зарегистрируйтесь сейчас — получите скидку до 100 USDT на торговую комиссию (для верифицированных пользователей)