WebsockexAdapter.Examples.DeribitRpc (WebsockexAdapter v0.1.1)
View SourceShared Deribit JSON-RPC method definitions and request builders.
This module centralizes all Deribit RPC method definitions to avoid duplication across adapter examples.
Summary
Functions
Builds an authentication request for Deribit API.
Builds a JSON-RPC request for the given method and params.
Creates a buy order for the specified instrument.
Cancels an existing order by ID.
Retrieves available trading instruments for a currency.
Retrieves all open orders with optional filters.
Retrieves the order book for a specific instrument.
Creates a sell order for the specified instrument.
Sets the heartbeat interval for the WebSocket connection.
Subscribes to one or more channels for real-time data.
Builds a test request to verify the connection is alive.
Gets ticker data for a specific instrument.
Unsubscribes from one or more channels.
Functions
Builds an authentication request for Deribit API.
Parameters
client_id
- Your Deribit API client IDclient_secret
- Your Deribit API client secret
Returns
A JSON-RPC request map for authentication.
Builds a JSON-RPC request for the given method and params.
Parameters
method
- The JSON-RPC method nameparams
- Optional parameters map (defaults to empty map)
Returns
A map containing the complete JSON-RPC request structure.
Creates a buy order for the specified instrument.
Parameters
instrument
- Instrument name (e.g., "BTC-PERPETUAL")amount
- Order amount in contractsopts
- Additional order options (type, price, etc.)
Returns
A JSON-RPC request map for buy order.
Cancels an existing order by ID.
Parameters
order_id
- The order ID to cancel
Returns
A JSON-RPC request map for order cancellation.
Retrieves available trading instruments for a currency.
Parameters
currency
- Currency code (e.g., "BTC", "ETH")
Returns
A JSON-RPC request map for retrieving instruments.
Retrieves all open orders with optional filters.
Parameters
opts
- Optional filters (instrument, type, etc.)
Returns
A JSON-RPC request map for retrieving open orders.
Retrieves the order book for a specific instrument.
Parameters
instrument
- Instrument name (e.g., "BTC-PERPETUAL")depth
- Order book depth (default: 10)
Returns
A JSON-RPC request map for order book data.
Creates a sell order for the specified instrument.
Parameters
instrument
- Instrument name (e.g., "BTC-PERPETUAL")amount
- Order amount in contractsopts
- Additional order options (type, price, etc.)
Returns
A JSON-RPC request map for sell order.
Sets the heartbeat interval for the WebSocket connection.
Parameters
interval
- Heartbeat interval in seconds (default: 30)
Returns
A JSON-RPC request map for setting heartbeat.
Subscribes to one or more channels for real-time data.
Parameters
channels
- List of channel names to subscribe to
Example
subscribe(["book.BTC-PERPETUAL.raw", "ticker.ETH-PERPETUAL.raw"])
Returns
A JSON-RPC request map for subscription.
@spec test_request() :: map()
Builds a test request to verify the connection is alive.
Returns
A JSON-RPC request map for connection testing.
Gets ticker data for a specific instrument.
Parameters
instrument
- Instrument name (e.g., "BTC-PERPETUAL")
Returns
A JSON-RPC request map for ticker data.
Unsubscribes from one or more channels.
Parameters
channels
- List of channel names to unsubscribe from
Returns
A JSON-RPC request map for unsubscription.