WebsockexNova.Examples.ClientDeribit (WebsockexNova v0.1.1)

View Source

Deribit-specific client API, wrapping WebsockexNova.Client with the Deribit adapter.

Provides a user-friendly, domain-specific interface for connecting, authenticating, and subscribing to Deribit WebSocket channels.

Summary

Functions

Authenticate using client credentials (from opts or environment).

Connect to Deribit WebSocket API with sensible defaults. User-supplied opts override defaults.

Disconnects from the Deribit WebSocket server.

Send a custom JSON-RPC payload to Deribit.

Sets the heartbeat interval for the Deribit connection. The server will send a heartbeat message every interval seconds.

Subscribe to a Deribit ticker channel for a given instrument (e.g., "BTC-PERPETUAL").

Subscribe to a Deribit trades channel for a given instrument (e.g., "BTC-PERPETUAL").

Functions

authenticate(conn, credentials \\ %{}, opts \\ nil)

Authenticate using client credentials (from opts or environment).

connect(opts \\ %{})

Connect to Deribit WebSocket API with sensible defaults. User-supplied opts override defaults.

disconnect(conn)

Disconnects from the Deribit WebSocket server.

send_json(conn, payload, opts \\ nil)

Send a custom JSON-RPC payload to Deribit.

set_heartbeat(conn, interval, opts \\ nil)

Sets the heartbeat interval for the Deribit connection. The server will send a heartbeat message every interval seconds.

When the heartbeat is set, the server will send:

  1. Regular "heartbeat" messages
  2. Periodic "test_request" messages that require a response

The value must be between 10 and 60 seconds for the Deribit API. Setting to 0 disables the heartbeat.

subscribe_to_ticker(conn, instrument, opts \\ nil)

Subscribe to a Deribit ticker channel for a given instrument (e.g., "BTC-PERPETUAL").

subscribe_to_trades(conn, instrument, opts \\ nil)

Subscribe to a Deribit trades channel for a given instrument (e.g., "BTC-PERPETUAL").