Overview
Self Match Prevention (SMP) is a mechanism that prevents orders from matching with each other when they originate from the same member AND share the same SMP token. SMP helps prevent accidental self-trading and allows for more granular control over order matching behavior. SMP uses three components to control order matching:| Component | Description | Required | Scope |
|---|---|---|---|
| SMP Mode | Determines which order is cancelled when a self-match is detected | Per order (default configured in Thunder account settings or via private/set_self_trading_config) | Order-level |
| SMP Token | Prevents matching between orders with the same token | Mandatory (can be set to null/0) | Order-level |
| Member ID | Scopes SMP to a specific member | SMP cannot trigger between Members | Member-level |
- SMP Mode
- SMP Token
- Member
SMP mode determines which order is cancelled when a self-match is detected:
The SMP mode should be specified for each order. A default SMP mode can be configured in Thunder through account settings or via the
| Mode | Behavior |
|---|---|
| CANCEL_MAKER | The resting (maker) order is cancelled |
| CANCEL_TAKER | The incoming (taker) order is cancelled |
private/set_self_trading_config method, and users can change their default setting.SMP Mode Selection: When a self-match is detected, the SMP mode from the aggressing order (the incoming order) will be used to determine which order is cancelled.
Order from different systems
Orders originating from the Websocket API, User Interface or other non-Starbase origin will have the SMP Token set based on the table below. To avoid matching with these orders when utilizing Starbase APIs, the same SMP Tokens should be used.| Setting | SMP Token Value |
|---|---|
| Self-match prevention restricted to subaccount | sub-account id (equal to Deribit’s User ID) |
| Self-match prevention enabled across all subaccounts | main-account id (equal to Deribit’s User ID) |
| Self-matching allowed | null (empty) |
API Usage
Order Entry Messages
SMP fields are mandatory and must be specified in the following order entry messages:| Message | SMP Token Field | Field Number | Description |
|---|---|---|---|
NewOrderRequest | SMPToken | 7 | This order cannot match with any other orders within the same portfolio with the same token. Set to null to allow self-matching. |
MassQuoteRequest | SMPToken | 4 | This order cannot match with any other orders within the same portfolio with the same token. Set to null to allow self-matching. |
SMP Cancellation Indicators
When an order is cancelled due to self-match prevention, it will be indicated in the response messages:| Message | Field | Value | Description |
|---|---|---|---|
NewOrderResponse | cancelReason (field 11) | 1 | selfMatchPrevention |
AmendOrderResponse | cancelReason (field 12) | 1 | selfMatchPrevention |
MassQuoteResponse | buyQuoteStatus (field 18) | 7 | CanceledBySelfMatch |
MassQuoteResponse | sellQuoteStatus (field 19) | 7 | CanceledBySelfMatch |