WebsockexAdapter.Examples.DeribitAdapter (WebsockexAdapter v0.1.1)

View Source

Simplified Deribit WebSocket API adapter.

Uses DeribitRpc for all RPC operations and provides 5 essential functions for Deribit integration.

Summary

Functions

Authenticate with Deribit using client credentials.

Connect to Deribit WebSocket API.

Send a request to Deribit API using any supported method.

Subscribe to Deribit channels.

Unsubscribe from Deribit channels.

Types

t()

@type t() :: %WebsockexAdapter.Examples.DeribitAdapter{
  authenticated: boolean(),
  client: WebsockexAdapter.Client.t() | nil,
  client_id: String.t() | nil,
  client_secret: String.t() | nil,
  subscriptions: MapSet.t()
}

Functions

authenticate(adapter)

@spec authenticate(t()) :: {:ok, t()} | {:error, term()}

Authenticate with Deribit using client credentials.

connect(opts \\ [])

@spec connect(keyword()) :: {:ok, t()} | {:error, term()}

Connect to Deribit WebSocket API.

Options:

  • :client_id - Client ID for authentication
  • :client_secret - Client secret for authentication
  • :url - WebSocket URL (defaults to test.deribit.com)
  • :handler - Message handler function
  • :heartbeat_interval - Heartbeat interval in seconds (default: 30)

send_request(deribit_adapter, method, params \\ %{})

@spec send_request(t(), String.t(), map()) :: {:ok, term()} | {:error, term()}

Send a request to Deribit API using any supported method.

subscribe(adapter, channels)

@spec subscribe(t(), [String.t()]) :: {:ok, t()} | {:error, term()}

Subscribe to Deribit channels.

unsubscribe(adapter, channels)

@spec unsubscribe(t(), [String.t()]) :: {:ok, t()} | {:error, term()}

Unsubscribe from Deribit channels.