WebsockexNova.Examples.ClientDeribitMacro (WebsockexNova v0.1.0)
View SourceDeribit-specific client API using the ClientMacro.
This demonstrates how to build a Deribit WebSocket API client with minimal code, leveraging the WebsockexNova.ClientMacro.
Summary
Functions
Authenticate using credentials.
Close the connection.
Connect to WebSocket API with sensible defaults from the adapter. User-supplied opts override defaults.
Get account summary
Get information about locked currencies on the platform.
Retrieves the current time from Deribit (in milliseconds).
Introduce the client software to Deribit over WebSocket.
Send a ping and wait for pong response.
Place a market order (buy/sell at market price)
Send a JSON message.
Send a text message.
Get connection status.
Subscribe to a channel.
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").
Tests the connection to the API server and returns its version.
Unsubscribe from a channel.
Functions
Authenticate using credentials.
Close the connection.
Connect to WebSocket API with sensible defaults from the adapter. User-supplied opts override defaults.
Get account summary
Get information about locked currencies on the platform.
Example
{:ok, status} = DeribitClient.get_platform_status(conn)
# status will include information on locked currencies
Retrieves the current time from Deribit (in milliseconds).
This is useful for checking clock skew between your software and Deribit's systems.
Example
{:ok, timestamp} = DeribitClient.get_time(conn)
# timestamp will be something like 1550147385946
Introduce the client software to Deribit over WebSocket.
Deribit will also introduce itself in the response.
Parameters
client_name
- Client software nameclient_version
- Client software version
Example
{:ok, response} = DeribitClient.hello(conn, "MyTradingApp", "1.0.0")
# response will include Deribit's version information
Send a ping and wait for pong response.
Place a market order (buy/sell at market price)
Send a JSON message.
Send a text message.
Get connection status.
Subscribe to a channel.
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").
Tests the connection to the API server and returns its version.
Use to verify API reachability and version.
Parameters
expected_result
- (Optional) If set to "exception", triggers error
Example
{:ok, version_info} = DeribitClient.test(conn)
# version_info will include Deribit's API version
Unsubscribe from a channel.