Self-Trade Prevention
What actually happens if your own orders would match against each other on BULK — relevant if you run more than one strategy, bot, or sub-account at once. For the formal specification, see docs.bulk.trade/bulk-exchange/Self-Trade-Prevention.
The problem this solves
If you're running multiple orders — say, a market-making bot quoting both sides of the book, or several strategies on the same account — it's possible for one of your own orders to end up matching against another one of your own resting orders. On most exchanges this either executes as a real (pointless) trade against yourself, generating fees and messing with your reported volume, or gets blocked in a way that cancels a resting order you wanted to keep live. BULK's self-trade prevention engine handles this more precisely than either of those.
How it actually works
When an incoming order would match a resting order, BULK's matching engine checks whether both orders belong to the same account. If they do, the engine skips that specific resting order — without cancelling it — and keeps searching the book for other, external liquidity to fill against instead. Your resting order stays exactly where it was, still available to fill against someone else's order later.
What you'll actually see
Depending on what liquidity is available besides your own resting order, one of three things happens:
- A normal fill — if there's other liquidity in the book, your incoming order simply fills against that instead, and you may not even notice the self-trade check happened.
- A partial fill — if only some external liquidity is available, you get filled for that portion and the rest is handled per your order's time-in-force setting.
- `cancelledSelfCrossing` — if the only liquidity available at your price is your own resting order, and no external liquidity exists to fill against, that portion of your incoming order is cancelled rather than forced through.
Sub-accounts are treated independently
If you're running separate strategies on separate sub-accounts under the same master wallet, self-trade prevention does not treat them as the same account. Orders from different sub-accounts can freely match against each other — this is deliberate, since sub-accounts exist precisely to let you run genuinely independent strategies without them interfering with each other. If you specifically want two strategies to never trade against each other, put them on separate sub-accounts rather than relying on self-trade prevention to catch it within one account.
Why this matters if you're building on the API
If you're running a bot or market-making strategy (see High-Frequency Market Making on BULK), self-trade prevention means you don't need to build your own logic to track and avoid crossing your own resting orders — but you should design your fill-handling code to expect a `cancelledSelfCrossing` result as a normal, non-error outcome, not something to treat as a bug.
See also
- Order Types on BULK
- Self-Trade Prevention glossary entry
- High-Frequency Market Making on BULK
- Official documentation
Building something that trades on BULK? Sign up with referral code YETI to test against the live book.