Tirdzniecības pašam ar sevi novēršana ("Self Trade Prevention" jeb STP) ir mehānisms, ko tirdzniecības platformas izmanto, lai neļautu lietotājiem nejauši veikt tirdzniecības darījumus pašiem ar sevi. Šāda situācija, ko sauc par tirdzniecību pašam ar sevi, notiek tad, ja orderu žurnālā tiek savstarpēji saskaņoti viena un tā paša lietotāja orderi. STP ir liela nozīme godīgas un pārskatāmas tirdzniecības vides nodrošināšanā, jo tā palīdz novērst manipulācijas ar tirgus cenām un garantē, ka tirdzniecības aktivitāte precīzi atspoguļo patieso tirgus interesi.
Platformā Binance STP mehānisms novērš situāciju, kad tiktu saskaņoti viena un tā paša lietotāja orderi vai lietotāja "tradeGroupID".
Tirdzniecība pašam ar sevi var notikt divos gadījumos:
Gadījumā, ja orderis izraisa tirdzniecību pašam ar sevi, sistēma var reaģēt vienā no četriem režīmiem.
STP funkcija darbosies atkarībā no ņēmēja orderim iestatītā STP režīma. Tādējādi orderu žurnālā iekļauta ordera STP režīms vairs nebūs atbilstošs un tiks ignorēts visiem turpmāk apstrādātajiem orderiem.
STP var iestatīt, tikai izmantojot lauku "selfTradePreventionMode", izmantojot šos API galapunktus:
Dažādi konti ar vienādu "tradeGroupId" tiek uzskatīti par piederošiem vienai tirdzniecības grupai. Tirdzniecības grupas dalībnieku iesniegtajiem orderiem tiek piemērota STP procedūra saskaņā ar ņēmēja ordera STP režīmu.
Lietotājs var pārbaudīt, vai viņa kontiem ir vienāds "tradeGroupId", izmantojot API (GET fapi/v2/account (REST API)).
Ja vērtība ir -1, tas nozīmē, ka "tradeGroupId" šim kontam nav iestatīts, un STP var notikt tikai starp viena un tā paša konta orderiem.
STP atbalsta visi GET fapi/v1/exchangeInfo simboli.
STP atbalsta šādu veidu orderi, ja "laiks spēkā" ("timeInForce") ir iestatīts kā GTC/IOC/GTD:
Ņem vērā, ka STP funkcija netiks piemērota "laiks spēkā" ("timeInForce") FOK vai GTX orderiem.
Nē. Modificēšanas orderi neatbalsta STP.
Ordera statuss būs "EXPIRED_IN_MATCH". Ja orderis būs atcelts STP dēļ, lietotāja datu straumes notikuma "ORDER_TRADE_UPDATE" laukā X tiks rādīts "EXPIRED_IN_MATCH".
{ "e":"ORDER_TRADE_UPDATE", // Event Type "E":1568879465651, // Event Time "T":1568879465650, // Transaction Time "o":{ "s":"BTCUSDT", // Symbol "c":"TEST", // Client Order Id // special client order id: // starts with "autoclose-": liquidation order // "adl_autoclose": ADL auto close order // "settlement_autoclose-": settlement order for delisting or delivery "S":"SELL", // Side "o":"TRAILING_STOP_MARKET", // Order Type "f":"GTC", // Time in Force "q":"0.001", // Original Quantity "p":"0", // Original Price "ap":"0", // Average Price "sp":"7103.04", // Stop Price. Please ignore with TRAILING_STOP_MARKET order "x":"EXPIRED", // Execution Type "X":"EXPIRED_IN_MATCH", // Order Status "i":8886774, // Order Id "l":"0", // Order Last Filled Quantity "z":"0", // Order Filled Accumulated Quantity "L":"0", // Last Filled Price "N":"USDT", // Commission Asset, will not push if no commission "n":"0", // Commission, will not push if no commission "T":1568879465650, // Order Trade Time "t":0, // Trade Id "b":"0", // Bids Notional "a":"9.91", // Ask Notional "m":false, // Is this trade the maker side? "R":false, // Is this reduce only "wt":"CONTRACT_PRICE", // Stop Price Working Type "ot":"TRAILING_STOP_MARKET", // Original Order Type "ps":"LONG", // Position Side "cp":false, // If Close-All, pushed with conditional order "AP":"7476.89", // Activation Price, only pushed with TRAILING_STOP_MARKET order "cr":"5.0", // Callback Rate, only pushed with TRAILING_STOP_MARKET order "pP": false, // ignore "si": 0, // ignore "ss": 0, // ignore "rp":"0" // Realized Profit of the trade "V": "NONE". // selfTradePreventionMode "pm":"QUEUE" // price match type "gtd":1768879465650 // good till date }}
Visos šajos gadījumos pieņemsim, ka visi orderi ir veikti, izmantojot vienu un to pašu kontu.
Maker Order: symbol=BTCUSDT side=BUY type=LIMIT quantity=1 price=20000 selfTradePreventionMode=NONE Taker Order: symbol=BTCUSDT side=SELL type=LIMIT quantity=1 price=20000 selfTradePreventionMode=NONE
Rezultāts: STP funkcija netiek aktivizēta, un orderi tiek saskaņoti.
Veidotāja ordera statuss:
{ "orderId": 292864713, "symbol": "BTCUSDT", "status": "FILLED", "clientOrderId": "43N239GaUaqshfG7825184", "price": "20000", "avgPrice": "20000", "origQty": "1", "executedQty": "1", "cumQty": "1", "cumQuote": "20000", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "BUY", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "NONE", "goodTillDate": 0, "priceProtect": false, "origType": "LIMIT", "updateTime": 1692849639460}
Ņēmēja ordera statuss:
{ "orderId": 292864714, "symbol": "BTCUSDT", "status": "FILLED", "clientOrderId": "43N239GaUaqshfG7825184", "price": "20000", "avgPrice": "20000", "origQty": "1", "executedQty": "1", "cumQty": "1", "cumQuote": "20000", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "SELL", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "NONE", "goodTillDate": 0, "priceProtect": false, "origType": "LIMIT", "updateTime": 1692849639460}
Maker Order 1: symbol=BTCUSDT side=BUY type=LIMIT quantity=1 price=20002 selfTradePreventionMode=NONE Maker Order 2: symbol=BTCUSDT side=BUY type=LIMIT quantity=1 price=20001 selfTradePreventionMode=NONE Taker Order 1: symbol=BTCUSDT side=SELL type=LIMIT quantity=1 price=20000 selfTradePreventionMode=EXPIRE_MAKER
Rezultāts: STP ietekmē orderu žurnālā esošie orderi tiks atcelti un ņēmēja orderis tiks iekļauts orderu žurnālā.
1. veidotāja orderis:
{ "orderId": 292864710, "symbol": "BTCUSDT", "status": "FILLED", "clientOrderId": "testMaker1", "price": "20002", "avgPrice": "20002", "origQty": "1", "executedQty": "1", "cumQuote": "20002", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "BUY", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "NONE", "goodTillDate": 0, "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460}
2. veidotāja orderis:
{ "orderId": 292864711, "symbol": "BTCUSDT", "status": "EXPIRED_IN_MATCH", "clientOrderId": "testMaker2", "price": "20001", "avgPrice": "0.0000", "origQty": "1", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "BUY", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "NONE", "goodTillDate": 0, "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460}
Ņēmēja ordera izvades dati:
{ "orderId": 292864712, "symbol": "BTCUSDT", "status": "PARTIALLY_FILLED", "clientOrderId": "testTaker1", "price": "20000", "avgPrice": "20002", "origQty": "2", "executedQty": "1", "cumQuote": "20002", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "SELL", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRE_MAKER", "goodTillDate": 0, "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460}
Maker Order 1: symbol=BTCUSDT side=BUY type=LIMIT quantity=1 price=20002 selfTradePreventionMode=NONE Maker Order 2: symbol=BTCUSDT side=BUY type=LIMIT quantity=1 price=20001 selfTradePreventionMode=NONE Taker Order 1: symbol=BTCUSDT side=SELL type=LIMIT quantity=2 price=20000 selfTradePreventionMode=EXPIRE_TAKER
Rezultāts: orderu žurnālā jau esošie orderi paliek spēkā, bet ņēmēja orderis tiek atcelts.
1. veidotāja orderis:
{ "orderId": 292864710, "symbol": "BTCUSDT", "status": "NEW", "clientOrderId": "testMaker1", "price": "20002", "avgPrice": "0.0000", "origQty": "1", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "BUY", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "NONE", "goodTillDate": 0, "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460}
2. veidotāja orderis:
{ "orderId": 292864711, "symbol": "BTCUSDT", "status": "NEW", "clientOrderId": "testMaker2", "price": "20001", "avgPrice": "0.0000", "origQty": "1", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "BUY", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "NONE", "goodTillDate": 0, "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460}
Ņēmēja ordera izvades dati:
{ "orderId": 292864712, "symbol": "BTCUSDT", "status": "EXPIRED_IN_MATCH", "clientOrderId": "testTaker1", "price": "20000", "avgPrice": "0.0000", "origQty": "3", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "SELL", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRE_TAKER", "goodTillDate": 0, "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460}
Maker Order: symbol=BTCUSDT side=BUY type=LIMIT quantity=1 price=20002 selfTradePreventionMode=NONETaker Order: symbol=BTCUSDT side=SELL type=LIMIT quantity=3 price=20000 selfTradePreventionMode=EXPIRE_BOTH
Rezultāts: abi orderi tiek atcelti.
Veidotāja orderis:
{ "orderId": 292864710, "symbol": "BTCUSDT", "status": "EXPIRED_IN_MATCH", "clientOrderId": "testMaker1", "price": "20002", "avgPrice": "0.0000", "origQty": "1", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "BUY", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "NONE", "goodTillDate": 0, "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460}
Ņēmēja orderis:
{ "orderId": 292864712, "symbol": "BTCUSDT", "status": "EXPIRED_IN_MATCH", "clientOrderId": "testTaker1", "price": "20000", "avgPrice": "0.0000", "origQty": "3", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "SELL", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRE_BOTH", "goodTillDate": 0, "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460}
Maker Order: symbol=BTCUSDT side=BUY type=LIMIT quantity=1 price=20002 selfTradePreventionMode=EXPIRE_MAKER Taker Order: symbol=BTCUSDT side=SELL type=LIMIT quantity=1 price=20000 selfTradePreventionMode=EXPIRE_TAKER
Rezultāts: tiks aktivizēts ņēmēja ordera STP režīms, tāpēc ņēmēja orderis tiks atcelts.
Veidotāja orderis:
{ "orderId": 292864710, "symbol": "BTCUSDT", "status": "NEW", "clientOrderId": "testMaker1", "price": "20002", "avgPrice": "0.0000", "origQty": "1", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "BUY", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRE_MAKER", "goodTillDate": 0, "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460}
Ņēmēja orderis:
{ "orderId": 292864712, "symbol": "BTCUSDT", "status": "EXPIRED_IN_MATCH", "clientOrderId": "testTaker1", "price": "20000", "avgPrice": "0.0000", "origQty": "1", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "SELL", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRE_TAKER", "goodTillDate": 0, "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460}
Maker Order: symbol=BTCUSDT side=BUY type=LIMIT quantity=1 price=20002 selfTradePreventionMode=NONE Taker Order: symbol=BTCUSDT side=SELL type=MARKET quantity=3 selfTradePreventionMode=EXPIRE_MAKER
Rezultāts: STP funkcijas dēļ esošais orderis tiek atcelts ar statusu "EXPIRED_IN_MATCH". Arī jaunais orderis tiek atcelts, taču tas notiek zemās likviditātes dēļ orderu žurnālā, un tā statuss ir "EXPIRED".
Veidotāja orderis:
{ "orderId": 292864710, "symbol": "BTCUSDT", "status": "EXPIRED_IN_MATCH", "clientOrderId": "testMaker1", "price": "20002", "avgPrice": "0.0000", "origQty": "1", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "BUY", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRE_MAKER", "goodTillDate": 0, "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460}
Ņēmēja orderis:
{ "orderId": 292864712, "symbol": "BTCUSDT", "status": "EXPIRED", "clientOrderId": "testTaker1", "price": "20000", "avgPrice": "0.0000", "origQty": "3", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "MARKET", "reduceOnly": false, "closePosition": false, "side": "SELL", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRED", "goodTillDate": 0, "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460}