Please refer to API Authentication Guide for more information regarding authentication.
Overview
Block trading on Deribit enables two parties to execute large trades directly with each other, bypassing the public order book. This is particularly useful for:- Large institutional trades that might impact market prices
- Negotiated trades between known counterparties
- Complex multi-leg trades
block_trade_id field, which can be seen in endpoints such as get_last_trades_by_currency.
Prerequisites
- Both parties must have Deribit accounts
- API keys with
block_trade:readscope (for verification) orblock_trade:read_writescope (for execution) - Agreement on trade parameters (instruments, prices, amounts, direction)
- Shared timestamp and nonce between parties
Block Trade Workflow
Block trades involve a two-party process:- First party calls
private/verify_block_tradeto generate a signature - Second party calls
private/execute_block_tradewith the signature to execute the trade
Step 1: Verify Block Trade (First Party)
The initial party initiates the block trade by callingprivate/verify_block_trade to generate a block trade signature based on provided parameters.
Example Request
Parameters
timestamp(required): Timestamp in milliseconds since the UNIX epoch, shared with the other partynonce(required): A unique nonce shared with the other partyrole(required): Either"maker"or"taker"- describes which role you want to be in the tradetrades(required): Array of trade objects, each containing:instrument_name(required): The instrument namedirection(required):"buy"or"sell"- Note: direction is always from the maker’s perspectiveprice(required): The trade priceamount(required): The trade amount
Response
signature that must be shared with the second party.
Step 2: Execute Block Trade (Second Party)
After receiving the signature, the second party is required to callprivate/execute_block_trade with the same parameters as the first party in private/verify_block_trade (only the role field should be set as the opposite of the first party).
Example Request
Parameters
timestamp(required): Must match the timestamp used inverify_block_tradenonce(required): Must match the nonce used inverify_block_traderole(required): Must be the opposite role of the first party (if first party was"taker", second party must be"maker")trades(required): Must match the trades array fromverify_block_trade, but with opposite directionscounterparty_signature(required): The signature received from the first party
Simulating Block Trades
Before executing a block trade, you can simulate it to check if it can be executed usingprivate/simulate_block_trade:
Example Request
Block Trade Approval Feature
Block trade approval introduces an additional layer to the block trade verification process. When activated, it necessitates an additional approval from the user from a different API key before a block trade can be executed.Setting Up Block Trade Approval
To use the block trade approval feature, an additional API key setting feature calledenabled_feature: block_trade_approval is required. This key has to be given to the broker/registered partner who performs the trades.
Approval Workflow
When a trade is executed by a Registered Partner on behalf of any of the two clients (Client A and Client B), multiple things happen to clients with block trade approval enabled:- Timer starts: A 5-minute timer starts. If those 5 minutes pass without required approvals, the block trade will be rejected
- Email notification: An email with a link pointing to a block trade approval window is sent
- Announcement: An announcement about pending approval is displayed on top of their screen
- WebSocket event: An event is transmitted on a
block_trade_confirmationchannel informing about a new pending trade - Pop-up window: A pop-up window emerges in the user interface displaying the structure of the trade, providing options to ‘Approve’ or ‘Reject’
Monitoring Pending Approvals
Clients can use theblock_trade_confirmation channel to monitor their pending confirmations.
Approving Block Trades via API
To approve a block trade, useprivate/approve_block_trade. To reject, use private/reject_block_trade. Timestamp, nonce, and role are required to select a block trade.
Example Request - Approve Block Trade
Example Request - Reject Block Trade
Invalidating Block Trade Signatures
If needed, you can invalidate a block trade signature usingprivate/invalidate_block_trade_signature:
Restricted Block Trades Feature
The restricted block trades feature limits theblock_trade:read scope of the API key to block trades that have been made using this specific API key. This method can be employed to restrict the visibility of user private block trades with third parties to whom the user has provided their API key.
Best Practices
- Coordinate parameters: Ensure both parties agree on timestamp, nonce, and all trade parameters before starting
- Use unique nonces: Generate unique nonces for each block trade to prevent replay attacks
- Verify before executing: Use
simulate_block_tradeto verify trades can be executed before the actual execution - Monitor pending approvals: If using block trade approval, monitor the
block_trade_confirmationchannel for pending approvals - Handle timeouts: Be aware of the 5-minute timeout for block trade approvals
- Secure signature sharing: Share signatures securely between parties
- Check direction carefully: Remember that direction is always from the maker’s perspective
Common Errors
- Invalid signature: The signature doesn’t match the trade parameters
- Mismatched parameters: Timestamp, nonce, or trades don’t match between parties
- Wrong role: The role specified doesn’t match the expected role (must be opposite of counterparty)
- Insufficient balance: One party doesn’t have sufficient balance or margin
- Approval timeout: Block trade approval was not completed within 5 minutes
- Invalid nonce: The nonce has already been used or is invalid
Related Methods
private/simulate_block_trade- Check if a block trade can be executedprivate/get_block_trade- Get information about a specific block tradeprivate/get_block_trades- List block tradesprivate/approve_block_trade- Approve a pending block tradeprivate/reject_block_trade- Reject a pending block tradeprivate/invalidate_block_trade_signature- Invalidate a block trade signature