DeribitHttpClient

Struct DeribitHttpClient 

Source
pub struct DeribitHttpClient { /* private fields */ }
Expand description

HTTP client for Deribit REST API

Implementations§

Source§

impl DeribitHttpClient

Source

pub fn new() -> Self

Create a new HTTP client

Source

pub fn with_config(config: HttpConfig) -> Self

Create a new HTTP client with custom configuration

Source

pub fn config(&self) -> &HttpConfig

Get the configuration

Source

pub fn base_url(&self) -> &str

Get the base URL

Source

pub fn http_client(&self) -> &Client

Get the HTTP client

Source

pub async fn make_request(&self, url: &str) -> Result<Response, HttpError>

Make a rate-limited HTTP request

Source

pub async fn make_authenticated_request( &self, url: &str, ) -> Result<Response, HttpError>

Make an authenticated HTTP GET request for private endpoints

Source

pub async fn make_authenticated_post_request<T: Serialize>( &self, url: &str, body: &T, ) -> Result<Response, HttpError>

Make an authenticated HTTP POST request for private endpoints

Source

pub fn rate_limiter(&self) -> &RateLimiter

Get rate limiter for advanced usage

Source

pub async fn exchange_token( &self, refresh_token: &str, subject_id: u64, scope: Option<&str>, ) -> Result<AuthToken, HttpError>

Exchange refresh token for a new access token with different subject_id

Source

pub async fn fork_token( &self, refresh_token: &str, session_name: &str, scope: Option<&str>, ) -> Result<AuthToken, HttpError>

Fork a token to create a new session with the same permissions

Source§

impl DeribitHttpClient

Private endpoints implementation

Source

pub async fn get_subaccounts( &self, with_portfolio: Option<bool>, ) -> Result<Vec<Subaccount>, HttpError>

Get subaccounts

Retrieves the list of subaccounts associated with the main account.

§Arguments
  • with_portfolio - Include portfolio information (optional)
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let subaccounts = client.get_subaccounts(Some(true)).await?;
// tracing::info!("Found {} subaccounts", subaccounts.len());
Source

pub async fn get_transaction_log( &self, request: TransactionLogRequest, ) -> Result<TransactionLogResponse, HttpError>

Get transaction log

Retrieves transaction log entries for the account.

§Arguments
  • request - A TransactionLogRequest struct containing:
    • currency - Currency symbol (BTC, ETH, etc.)
    • start_timestamp - Start timestamp in milliseconds (optional)
    • end_timestamp - End timestamp in milliseconds (optional)
    • count - Number of requested items (optional, default 10)
    • continuation - Continuation token for pagination (optional)
§Examples
use deribit_http::DeribitHttpClient;
use crate::model::TransactionLogRequest;

let client = DeribitHttpClient::new();
// let request = TransactionLogRequest { currency: "BTC".into(), ..Default::default() };
// let log = client.get_transaction_log(request).await?;
Source

pub async fn get_deposits( &self, currency: &str, count: Option<u32>, offset: Option<u32>, ) -> Result<DepositsResponse, HttpError>

Get deposits

Retrieves the latest user deposits.

§Arguments
  • currency - Currency symbol (BTC, ETH, etc.)
  • count - Number of requested items (optional, default 10)
  • offset - Offset for pagination (optional, default 0)
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let deposits = client.get_deposits("BTC", Some(20), Some(0)).await?;
// tracing::info!("Found {} deposits", deposits.data.len());
Source

pub async fn get_withdrawals( &self, currency: &str, count: Option<u32>, offset: Option<u32>, ) -> Result<WithdrawalsResponse, HttpError>

Get withdrawals

Retrieves the latest user withdrawals.

§Arguments
  • currency - Currency symbol (BTC, ETH, etc.)
  • count - Number of requested items (optional, default 10)
  • offset - Offset for pagination (optional, default 0)
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let withdrawals = client.get_withdrawals("BTC", Some(20), Some(0)).await?;
// tracing::info!("Found {} withdrawals", withdrawals.data.len());
Source

pub async fn submit_transfer_to_subaccount( &self, currency: &str, amount: f64, destination: u64, ) -> Result<TransferResultResponse, HttpError>

Submit transfer to subaccount

Transfers funds to a subaccount.

§Arguments
  • currency - Currency symbol (BTC, ETH, etc.)
  • amount - Amount of funds to be transferred
  • destination - ID of destination subaccount
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let transfer = client.submit_transfer_to_subaccount("BTC", 0.001, 123).await?;
// tracing::info!("Transfer ID: {}", transfer.id);
Source

pub async fn submit_transfer_to_user( &self, currency: &str, amount: f64, destination: &str, ) -> Result<TransferResultResponse, HttpError>

Submit transfer to user

Transfers funds to another user.

§Arguments
  • currency - Currency symbol (BTC, ETH, etc.)
  • amount - Amount of funds to be transferred
  • destination - Destination wallet address from address book
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let transfer = client.submit_transfer_to_user("ETH", 0.1, "0x1234...").await?;
// tracing::info!("Transfer ID: {}", transfer.id);
Source

pub async fn buy_order( &self, request: OrderRequest, ) -> Result<OrderResponse, HttpError>

Place a buy order

Places a buy order for the specified instrument.

§Arguments
  • request - The buy order request parameters
Source

pub async fn sell_order( &self, request: OrderRequest, ) -> Result<OrderResponse, HttpError>

Place a sell order

Places a sell order for the specified instrument.

§Arguments
  • request - The sell order request parameters
Source

pub async fn cancel_order( &self, order_id: &str, ) -> Result<OrderInfoResponse, HttpError>

Cancel an order

Cancels an order by its ID.

§Arguments
  • order_id - The order ID to cancel
Source

pub async fn cancel_all(&self) -> Result<u32, HttpError>

Cancel all orders

Cancels all orders for the account.

§Returns

Returns the number of cancelled orders.

Source

pub async fn cancel_all_by_currency( &self, currency: &str, ) -> Result<u32, HttpError>

Cancel all orders by currency

Cancels all orders for the specified currency.

§Arguments
  • currency - Currency to cancel orders for (BTC, ETH, USDC, etc.)
§Returns

Returns the number of cancelled orders.

Source

pub async fn cancel_all_by_currency_pair( &self, currency_pair: &str, ) -> Result<u32, HttpError>

Cancel all orders by currency pair

Cancels all orders for the specified currency pair.

§Arguments
  • currency_pair - Currency pair to cancel orders for (e.g., “BTC_USD”)
§Returns

Returns the number of cancelled orders.

Source

pub async fn cancel_all_by_instrument( &self, instrument_name: &str, ) -> Result<u32, HttpError>

Cancel all orders by instrument

Cancels all orders for the specified instrument.

§Arguments
  • instrument_name - Instrument name to cancel orders for (e.g., “BTC-PERPETUAL”)
§Returns

Returns the number of cancelled orders.

Source

pub async fn cancel_all_by_kind_or_type( &self, kind: Option<&str>, order_type: Option<&str>, ) -> Result<u32, HttpError>

Cancel all orders by kind or type

Cancels all orders for the specified kind or type.

§Arguments
  • kind - Kind of orders to cancel (future, option, spot, etc.) - optional
  • order_type - Type of orders to cancel (limit, market, etc.) - optional
§Returns

Returns the number of cancelled orders.

Source

pub async fn cancel_by_label(&self, label: &str) -> Result<u32, HttpError>

Cancel orders by label

Cancels all orders with the specified label.

§Arguments
  • label - Label of orders to cancel
§Returns

Returns the number of cancelled orders.

Source

pub async fn get_account_summary( &self, currency: &str, extended: Option<bool>, ) -> Result<AccountSummaryResponse, HttpError>

Get account summary

Retrieves account summary information including balance, margin, and other account details.

§Arguments
  • currency - Currency to get summary for (BTC, ETH, USDC, etc.)
  • extended - Whether to include extended information
Source

pub async fn get_positions( &self, currency: Option<&str>, kind: Option<&str>, subaccount_id: Option<i32>, ) -> Result<Vec<Position>, HttpError>

Get positions

Retrieves user positions for the specified currency and kind.

§Arguments
  • currency - Currency filter (BTC, ETH, USDC, etc.) - optional
  • kind - Kind filter (future, option, spot, etc.) - optional
  • subaccount_id - Subaccount ID - optional
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let positions = client.get_positions(Some("BTC"), Some("future"), None).await?;
// println!("Found {} positions", positions.len());
Source

pub async fn get_position( &self, instrument_name: &str, ) -> Result<Vec<Position>, HttpError>

Get position for a specific instrument

Retrieves the current position for the specified instrument.

§Arguments
  • instrument_name - The name of the instrument to get position for
§Returns

Returns a vector of positions for the specified instrument

Source

pub async fn edit_order( &self, request: OrderRequest, ) -> Result<OrderResponse, HttpError>

Edit an order

Edits an existing order.

§Arguments
  • request - The edit order request parameters
Source

pub async fn mass_quote( &self, _quotes: MassQuoteRequest, ) -> Result<MassQuoteResponse, HttpError>

Mass quote

Places multiple quotes at once.

§Arguments
  • quotes - Vector of mass quote requests
Source

pub async fn get_user_trades_by_instrument( &self, instrument_name: &str, start_seq: Option<u64>, end_seq: Option<u64>, count: Option<u32>, include_old: Option<bool>, sorting: Option<&str>, ) -> Result<UserTradeWithPaginationResponse, HttpError>

Get user trades by instrument

Retrieves user trades for a specific instrument.

§Arguments
  • instrument_name - Instrument name
  • start_seq - Start sequence number (optional)
  • end_seq - End sequence number (optional)
  • count - Number of requested items (optional)
  • include_old - Include old trades (optional)
  • sorting - Direction of results sorting (optional)
Source

pub async fn cancel_quotes( &self, cancel_type: Option<&str>, ) -> Result<u32, HttpError>

Cancel quotes

Cancels all mass quotes.

§Arguments
  • cancel_type - Type of cancellation (“all”, “by_currency”, “by_instrument”, etc.)
Source

pub async fn get_open_orders( &self, kind: Option<&str>, order_type: Option<&str>, ) -> Result<Vec<OrderInfoResponse>, HttpError>

Get open orders

Retrieves list of user’s open orders across many currencies.

§Arguments
  • kind - Instrument kind filter (optional)
  • order_type - Order type filter (optional)
Source

pub async fn get_open_orders_by_label( &self, label: &str, currency: &str, ) -> Result<Vec<OrderInfoResponse>, HttpError>

Get open orders by label

Retrieves open orders filtered by a specific label.

§Arguments
  • label - The label to filter orders by
  • currency - The currency symbol (BTC, ETH, etc.)
Source

pub async fn get_order_state( &self, order_id: &str, ) -> Result<OrderInfoResponse, HttpError>

Get order state

Retrieves the state of a specific order.

§Arguments
  • order_id - The order ID
Source

pub async fn get_open_orders_by_currency( &self, currency: &str, kind: Option<&str>, order_type: Option<&str>, ) -> Result<Vec<OrderInfoResponse>, HttpError>

Get open orders by currency

Retrieves open orders for a specific currency.

§Arguments
  • currency - The currency symbol (BTC, ETH, etc.)
  • kind - Instrument kind filter (optional)
  • order_type - Order type filter (optional)
Source

pub async fn get_open_orders_by_instrument( &self, instrument_name: &str, order_type: Option<&str>, ) -> Result<Vec<OrderInfoResponse>, HttpError>

Get open orders by instrument

Retrieves open orders for a specific instrument.

§Arguments
  • instrument_name - The instrument name
  • order_type - Order type filter (optional)
Source

pub async fn get_order_history( &self, currency: &str, kind: Option<&str>, count: Option<u32>, offset: Option<u32>, ) -> Result<Vec<OrderInfoResponse>, HttpError>

Get order history

Retrieves history of orders that have been partially or fully filled.

§Arguments
  • currency - Currency symbol (BTC, ETH, etc.)
  • kind - Instrument kind filter (optional)
  • count - Number of requested items (optional, default 20)
  • offset - Offset for pagination (optional)
Source

pub async fn get_order_history_by_currency( &self, currency: &str, kind: Option<&str>, count: Option<u32>, offset: Option<u32>, ) -> Result<Vec<OrderInfoResponse>, HttpError>

Get order history by currency

Retrieves order history for a specific currency.

§Arguments
  • currency - Currency symbol (BTC, ETH, etc.)
  • kind - Instrument kind filter (optional)
  • count - Number of requested items (optional)
  • offset - Offset for pagination (optional)
Source

pub async fn get_order_history_by_instrument( &self, instrument_name: &str, count: Option<u32>, offset: Option<u32>, ) -> Result<Vec<OrderInfoResponse>, HttpError>

Get order history by instrument

Retrieves order history for a specific instrument.

§Arguments
  • instrument_name - The instrument name
  • count - Number of requested items (optional)
  • offset - Offset for pagination (optional)
Source

pub async fn get_user_trades_by_currency( &self, request: TradesRequest, ) -> Result<UserTradeWithPaginationResponse, HttpError>

Get user trades by currency

Retrieves user trades filtered by currency.

§Arguments
  • request - A TradesRequest struct containing:
    • currency - Currency symbol (BTC, ETH, etc.)
    • kind - Instrument kind filter (optional)
    • start_id - The ID of the first trade to be returned (optional)
    • end_id - The ID of the last trade to be returned (optional)
    • count - Number of requested items (optional, default 10, max 1000)
    • start_timestamp - The earliest timestamp to return results from (optional)
    • end_timestamp - The most recent timestamp to return results from (optional)
    • sorting - Direction of results sorting (optional)
    • historical - If true, retrieves historical records that persist indefinitely. If false (default), retrieves recent records available for 24 hours.
    • subaccount_id - The user id for the subaccount (optional)
Source

pub async fn get_user_trades_by_currency_and_time( &self, request: TradesRequest, ) -> Result<UserTradeWithPaginationResponse, HttpError>

Get user trades by currency and time

Retrieves user trades filtered by currency within a time range.

§Arguments
  • request - A TradesRequest struct containing:
    • currency - Currency symbol (BTC, ETH, etc.)
    • kind - Instrument kind filter (optional)
    • start_id - The ID of the first trade to be returned (optional)
    • end_id - The ID of the last trade to be returned (optional)
    • count - Number of requested items (optional, default 10, max 1000)
    • start_timestamp - The earliest timestamp to return results from (optional)
    • end_timestamp - The most recent timestamp to return results from (optional)
    • sorting - Direction of results sorting (optional)
    • historical - If true, retrieves historical records that persist indefinitely. If false (default), retrieves recent records available for 24 hours.
    • subaccount_id - The user id for the subaccount (optional)
Source

pub async fn get_user_trades_by_instrument_and_time( &self, instrument_name: &str, start_timestamp: u64, end_timestamp: u64, count: Option<u32>, include_old: Option<bool>, sorting: Option<&str>, ) -> Result<UserTradeWithPaginationResponse, HttpError>

Get user trades by instrument and time

Retrieves user trades for a specific instrument within a time range.

§Arguments
  • instrument_name - Instrument name
  • start_timestamp - Start timestamp in milliseconds
  • end_timestamp - End timestamp in milliseconds
  • count - Number of requested items (optional, default 10)
  • include_old - Include trades older than 7 days (optional)
  • sorting - Direction of results sorting (optional)
Source

pub async fn get_user_trades_by_order( &self, order_id: &str, sorting: Option<&str>, historical: bool, ) -> Result<Vec<UserTradeResponseByOrder>, HttpError>

Get user trades by order

Retrieves user trades for a specific order.

§Arguments
  • order_id - Order ID
  • sorting - Direction of results sorting (optional)
Source§

impl DeribitHttpClient

Market data endpoints

Source

pub async fn get_currencies(&self) -> Result<Vec<CurrencyStruct>, HttpError>

Get all supported currencies

Retrieves all cryptocurrencies supported by the API. This is a public endpoint that doesn’t require authentication.

§Examples
let client = DeribitHttpClient::new(); // testnet
let currencies = client.get_currencies().await?;
for currency in currencies {
    println!("Currency: {} ({})", currency.currency, currency.currency_long);
}
Source

pub async fn get_index(&self, currency: &str) -> Result<IndexData, HttpError>

Get current index price for a currency

Retrieves the current index price for the instruments, for the selected currency. This is a public endpoint that doesn’t require authentication.

§Arguments
  • currency - The currency symbol (BTC, ETH, USDC, USDT, EURR)
Source

pub async fn get_index_price( &self, index_name: &str, ) -> Result<IndexPriceData, HttpError>

Get index price by name

Retrieves the current index price value for given index name. This is a public endpoint that doesn’t require authentication.

§Arguments
  • index_name - The index identifier (e.g., “btc_usd”, “eth_usd”)
§Examples
let client = DeribitHttpClient::new(); // testnet
let index_price = client.get_index_price("btc_usd").await?;
println!("Index price: {}", index_price.index_price);
Source

pub async fn get_index_price_names(&self) -> Result<Vec<String>, HttpError>

Get all supported index price names

Retrieves the identifiers of all supported Price Indexes. This is a public endpoint that doesn’t require authentication.

§Examples
let client = DeribitHttpClient::new(); // testnet
let index_names = client.get_index_price_names().await?;
for name in index_names {
    println!("Index: {}", name);
}
Source

pub async fn get_book_summary_by_currency( &self, currency: &str, kind: Option<&str>, ) -> Result<Vec<BookSummary>, HttpError>

Get book summary by currency

Retrieves the summary information such as open interest, 24h volume, etc. for all instruments for the currency (optionally filtered by kind). This is a public endpoint that doesn’t require authentication.

§Arguments
  • currency - The currency symbol (BTC, ETH, USDC, USDT, EURR)
  • kind - Optional instrument kind filter (future, option, spot, future_combo, option_combo)
§Examples
let client = DeribitHttpClient::new(); // testnet
let summaries = client.get_book_summary_by_currency("BTC", Some("future")).await?;
for summary in summaries {
    println!("Instrument: {} - Volume: {}", summary.instrument_name, summary.volume);
}
Source

pub async fn get_instrument( &self, instrument_name: &str, ) -> Result<Instrument, HttpError>

Get single instrument information

Retrieves detailed information about a specific instrument. This is a public endpoint that doesn’t require authentication.

§Arguments
  • instrument_name - The instrument identifier (e.g., “BTC-PERPETUAL”)
§Examples
let client = DeribitHttpClient::new(); // testnet
let instrument = client.get_instrument("BTC-PERPETUAL").await?;
println!("Contract size: {:?}", instrument.contract_size);
Source

pub async fn get_book_summary_by_instrument( &self, instrument_name: &str, ) -> Result<BookSummary, HttpError>

Get book summary by instrument

Retrieves the summary information such as open interest, 24h volume, etc. for a specific instrument. This is a public endpoint that doesn’t require authentication.

§Arguments
  • instrument_name - The instrument identifier (e.g., “BTC-PERPETUAL”)
Source

pub async fn get_contract_size( &self, instrument_name: &str, ) -> Result<f64, HttpError>

Get contract size for an instrument

Retrieves contract size for specified instrument. This is a public endpoint that doesn’t require authentication.

§Arguments
  • instrument_name - The instrument identifier (e.g., “BTC-PERPETUAL”)
§Examples
let client = DeribitHttpClient::new(); // testnet
let contract_size = client.get_contract_size("BTC-PERPETUAL").await?;
println!("Contract size: {}", contract_size);
Source

pub async fn get_server_time(&self) -> Result<u64, HttpError>

Get server time

Returns the current server time in milliseconds since Unix epoch. This is a public endpoint that doesn’t require authentication.

§Examples
let client = DeribitHttpClient::new(); // testnet
let server_time = client.get_server_time().await?;
println!("Server time: {}", server_time);
Source

pub async fn test_connection(&self) -> Result<String, HttpError>

Test connectivity to the API

Returns the API version to test connectivity. This is a public endpoint that doesn’t require authentication.

Source

pub async fn get_status(&self) -> Result<StatusResponse, HttpError>

Get platform status and locked currency indices

Returns information about the platform status and any locked currency indices. This is a public endpoint that doesn’t require authentication.

Source

pub async fn get_apr_history( &self, currency: &str, limit: Option<u32>, before: Option<i32>, ) -> Result<AprHistoryResponse, HttpError>

Get APR history for yield tokens

Retrieves historical APR data for specified currency. Only applicable to yield-generating tokens (USDE, STETH). This is a public endpoint that doesn’t require authentication.

§Arguments
  • currency - Currency for which to retrieve APR history (usde or steth)
  • limit - Optional number of days to retrieve (default 365, maximum 365)
  • before - Optional parameter to receive APR history before given epoch day
Source

pub async fn get_ticker( &self, instrument_name: &str, ) -> Result<TickerData, HttpError>

Get ticker information for an instrument

Returns ticker data including last price, bid/ask, volume, etc.

§Arguments
  • instrument_name - The instrument identifier (e.g., “BTC-PERPETUAL”)
§Examples
let client = DeribitHttpClient::new();
let ticker = client.get_ticker("BTC-PERPETUAL").await?;
println!("Last price: {:?}", ticker.last_price);
Source

pub async fn get_order_book( &self, instrument_name: &str, depth: Option<u32>, ) -> Result<OrderBook, HttpError>

Get order book for an instrument

Returns the current order book with bids and asks.

§Arguments
  • instrument_name - The instrument identifier
  • depth - Optional depth of the order book (default: 5)
Source

pub async fn get_options( &self, currency: &str, expiry: &str, ) -> Result<Vec<OptionInstrument>, HttpError>

Retrieves a list of option instruments for a given currency and expiry date.

This asynchronous function fetches option instruments for the specified currency and expiry date and returns a filtered list of options along with their associated ticker information.

§Arguments
  • currency - A string slice that represents the name of the currency (e.g., “BTC”, “ETH”).
  • expiry - A string slice representing the expiry date for the options (e.g., “20231027”).
§Returns

Returns a Result containing a vector of OptionInstrument on success, or an HttpError on failure.

  • On success, it returns a Vec<OptionInstrument>, where each option contains the instrument details and ticker information.
  • On failure, it returns an HttpError, such as in cases where the instrument data could not be retrieved or tickers are inaccessible.
§Errors

This function may return an HttpError in the following scenarios:

  • If fetching the instrument data fails.
  • If retrieving ticker information for an instrument fails.
§Implementation Details
  1. Fetches instruments for the specified currency filtered by type option.
  2. Filters the instruments to ensure they match the currency-expiry base name.
  3. Constructs an OptionInstrument for each filtered instrument, including the instrument details and ticker information.
Source

pub async fn get_options_pair( &self, currency: &str, expiry: &str, ) -> Result<HashMap<u64, OptionInstrumentPair>, HttpError>

Fetches option instruments for a given currency and expiry date, grouped by strike price.

This method retrieves all option instruments for the specified currency and expiry, then groups them into pairs (call and put) by strike price. Each strike price maps to an OptionInstrumentPair containing the call and put options if available.

§Arguments
  • currency - The currency symbol (e.g., “BTC”, “ETH”)
  • expiry - The expiry date in format “DDMMMYY” (e.g., “10SEP25”)
§Returns

Returns a HashMap where:

  • Key: Strike price as u64
  • Value: OptionInstrumentPair containing call and put options for that strike
§Errors

Returns HttpError if:

  • The API request fails
  • An option instrument has no option type
  • Network or authentication errors occur
§Example
let client = DeribitHttpClient::new();
let pairs = client.get_options_pair("BTC", "10SEP25").await?;

for (strike, pair) in pairs {
    println!("Strike {}: Call={:?}, Put={:?}",
             strike, pair.call.is_some(), pair.put.is_some());
}
Source

pub async fn get_instruments( &self, currency: &str, kind: Option<&str>, expired: Option<bool>, ) -> Result<Vec<Instrument>, HttpError>

Get available instruments

Returns a list of available trading instruments.

§Arguments
  • currency - The currency (e.g., “BTC”, “ETH”)
  • kind - Optional instrument kind (“future”, “option”, “spot”)
  • expired - Whether to include expired instruments
Source

pub async fn get_last_trades( &self, instrument_name: &str, count: Option<u32>, include_old: Option<bool>, ) -> Result<Vec<Trade>, HttpError>

Get recent trades for an instrument

Returns recent trade history for the specified instrument.

§Arguments
  • instrument_name - The instrument identifier
  • count - Optional number of trades to return (default: 10, max: 1000)
  • include_old - Whether to include old trades
Source

pub async fn get_historical_volatility( &self, currency: &str, ) -> Result<Vec<[f64; 2]>, HttpError>

Get historical volatility

Provides information about historical volatility for given cryptocurrency.

§Arguments
  • currency - Currency symbol (BTC, ETH, etc.)
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let volatility = client.get_historical_volatility("BTC").await?;
// tracing::info!("Found {} volatility data points", volatility.len());
Source

pub async fn get_funding_chart_data( &self, instrument_name: &str, length: &str, ) -> Result<FundingChartData, HttpError>

Get funding chart data

Retrieves the list of the latest PERPETUAL funding chart points within a given time period.

§Arguments
  • instrument_name - Instrument name
  • length - Time period (8h, 24h, 1m)
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let funding_data = client.get_funding_chart_data("BTC-PERPETUAL", "8h").await?;
// tracing::info!("Current interest: {}", funding_data.current_interest);
Source

pub async fn get_tradingview_chart_data( &self, instrument_name: &str, start_timestamp: u64, end_timestamp: u64, resolution: &str, ) -> Result<TradingViewChartData, HttpError>

Get TradingView chart data

Publicly available market data used to generate a TradingView candle chart.

§Arguments
  • instrument_name - Instrument name
  • start_timestamp - Start timestamp in milliseconds
  • end_timestamp - End timestamp in milliseconds
  • resolution - Chart resolution (1, 3, 5, 10, 15, 30, 60, 120, 180, 360)
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let chart_data = client.get_tradingview_chart_data("BTC-PERPETUAL", 1554373800000, 1554376800000, "30").await?;
// tracing::info!("Chart status: {}", chart_data.status);
Source

pub async fn get_delivery_prices( &self, index_name: &str, count: Option<u32>, offset: Option<u32>, ) -> Result<DeliveryPricesResponse, HttpError>

Get delivery prices

Retrieves delivery prices for the given index. This is a public endpoint that doesn’t require authentication.

§Arguments
  • index_name - Index identifier (e.g., “btc_usd”, “eth_usd”)
  • count - Number of requested items (optional, default 20)
  • offset - Offset for pagination (optional, default 0)
§Examples
let client = DeribitHttpClient::new(); // testnet
let delivery_prices = client.get_delivery_prices("btc_usd", Some(5), Some(0)).await?;
for price in delivery_prices.data {
    println!("Date: {} - Price: {}", price.date, price.delivery_price);
}
Source

pub async fn get_expirations( &self, currency: &str, kind: &str, currency_pair: Option<&str>, ) -> Result<ExpirationsResponse, HttpError>

Get expirations

Retrieves expirations for instruments. This method can be used to see instrument expirations. This is a public endpoint that doesn’t require authentication.

§Arguments
  • currency - The currency symbol (BTC, ETH, USDC, USDT, any, grouped)
  • kind - Instrument kind (future, option, any)
  • currency_pair - Currency pair identifier (optional)
Source

pub async fn get_funding_rate_history( &self, instrument_name: &str, start_timestamp: u64, end_timestamp: u64, ) -> Result<Vec<FundingRateData>, HttpError>

Get funding rate history

Retrieves hourly historical interest rate for requested PERPETUAL instrument. This is a public endpoint that doesn’t require authentication.

§Arguments
  • instrument_name - Instrument name
  • start_timestamp - The earliest timestamp to return result from (milliseconds since UNIX epoch)
  • end_timestamp - The most recent timestamp to return result from (milliseconds since UNIX epoch)
Source

pub async fn get_funding_rate_value( &self, instrument_name: &str, start_timestamp: u64, end_timestamp: u64, ) -> Result<f64, HttpError>

Get funding rate value

Retrieves interest rate value for requested period. Applicable only for PERPETUAL instruments. This is a public endpoint that doesn’t require authentication.

§Arguments
  • instrument_name - Instrument name
  • start_timestamp - The earliest timestamp to return result from (milliseconds since UNIX epoch)
  • end_timestamp - The most recent timestamp to return result from (milliseconds since UNIX epoch)
§Examples
let client = DeribitHttpClient::new(); // testnet
let funding_rate = client.get_funding_rate_value("BTC-PERPETUAL", 1569888000000, 1569974400000).await?;
println!("Funding rate for period: {}", funding_rate);
Source

pub async fn get_last_settlements_by_currency( &self, currency: &str, settlement_type: Option<&str>, count: Option<u32>, continuation: Option<&str>, search_start_timestamp: Option<u64>, ) -> Result<SettlementsResponse, HttpError>

Get last settlements by currency

Retrieves historical settlement, delivery and bankruptcy events coming from all instruments within a given currency. This is a public endpoint that doesn’t require authentication.

§Arguments
  • currency - The currency symbol (BTC, ETH, USDC, USDT, EURR)
  • settlement_type - Settlement type (settlement, delivery, bankruptcy) - optional
  • count - Number of requested items (optional, default 20)
  • continuation - Continuation token for pagination (optional)
  • search_start_timestamp - The latest timestamp to return result from (optional)
Source

pub async fn get_last_settlements_by_instrument( &self, instrument_name: &str, settlement_type: Option<&str>, count: Option<u32>, continuation: Option<&str>, search_start_timestamp: Option<u64>, ) -> Result<SettlementsResponse, HttpError>

Get last settlements by instrument

Retrieves historical public settlement, delivery and bankruptcy events filtered by instrument name. This is a public endpoint that doesn’t require authentication.

§Arguments
  • instrument_name - Instrument name
  • settlement_type - Settlement type (settlement, delivery, bankruptcy) - optional
  • count - Number of requested items (optional, default 20)
  • continuation - Continuation token for pagination (optional)
  • search_start_timestamp - The latest timestamp to return result from (optional)
Source

pub async fn get_last_trades_by_currency( &self, currency: &str, kind: Option<&str>, count: Option<u32>, include_old: Option<bool>, sorting: Option<&str>, ) -> Result<LastTradesResponse, HttpError>

Get last trades by currency

Retrieves the latest trades that have occurred for instruments in a specific currency. This is a public endpoint that doesn’t require authentication.

§Arguments
  • currency - The currency symbol (BTC, ETH, USDC, USDT, EURR)
  • kind - Instrument kind (future, option, spot, etc.) - optional
  • count - Number of requested items (optional, default 10)
  • include_old - Include trades older than 7 days (optional)
  • sorting - Direction of results sorting (optional)
§Examples
let client = DeribitHttpClient::new(); // testnet
let trades = client.get_last_trades_by_currency("BTC", Some("future"), Some(10), Some(false), Some("desc")).await?;
for trade in trades.trades {
    println!("Trade: {} {} at {}", trade.amount, trade.instrument_name, trade.price);
}
Source

pub async fn get_last_trades_by_currency_and_time( &self, currency: &str, start_timestamp: u64, end_timestamp: u64, kind: Option<&str>, count: Option<u32>, include_old: Option<bool>, sorting: Option<&str>, ) -> Result<LastTradesResponse, HttpError>

Get last trades by currency and time

Retrieves the latest trades that have occurred for instruments in a specific currency within a time range. This is a public endpoint that doesn’t require authentication.

§Arguments
  • currency - The currency symbol (BTC, ETH, USDC, USDT, EURR)
  • start_timestamp - The earliest timestamp to return result from (milliseconds since UNIX epoch)
  • end_timestamp - The most recent timestamp to return result from (milliseconds since UNIX epoch)
  • kind - Instrument kind (future, option, spot, etc.) - optional
  • count - Number of requested items (optional, default 10)
  • include_old - Include trades older than 7 days (optional)
  • sorting - Direction of results sorting (optional)
§Examples
let client = DeribitHttpClient::new(); // testnet
let trades = client.get_last_trades_by_currency_and_time("BTC", 1569888000000, 1569974400000, Some("future"), Some(10), Some(false), Some("desc")).await?;
for trade in trades.trades {
    println!("Trade: {} {} at {}", trade.amount, trade.instrument_name, trade.price);
}
Source

pub async fn get_last_trades_by_instrument_and_time( &self, instrument_name: &str, start_timestamp: u64, end_timestamp: u64, count: Option<u32>, include_old: Option<bool>, sorting: Option<&str>, ) -> Result<LastTradesResponse, HttpError>

Get last trades by instrument and time

Retrieves the latest trades that have occurred for a specific instrument within a time range. This is a public endpoint that doesn’t require authentication.

§Arguments
  • instrument_name - Instrument name
  • start_timestamp - The earliest timestamp to return result from (milliseconds since UNIX epoch)
  • end_timestamp - The most recent timestamp to return result from (milliseconds since UNIX epoch)
  • count - Number of requested items (optional, default 10)
  • include_old - Include trades older than 7 days (optional)
  • sorting - Direction of results sorting (optional)
§Examples
let client = DeribitHttpClient::new(); // testnet
let trades = client.get_last_trades_by_instrument_and_time("BTC-PERPETUAL", 1569888000000, 1569974400000, Some(10), Some(false), Some("desc")).await?;
for trade in trades.trades {
    println!("Trade: {} at {} ({})", trade.amount, trade.price, trade.direction);
}
Source

pub async fn get_order_book_by_instrument_id( &self, instrument_id: u32, depth: Option<u32>, ) -> Result<OrderBook, HttpError>

Get order book by instrument ID

Retrieves the order book for the specified instrument by its ID. This is a public endpoint that doesn’t require authentication.

§Arguments
  • instrument_id - Instrument ID
  • depth - The number of entries to return for bid and ask order book entries (optional)
§Examples
let client = DeribitHttpClient::new(); // testnet
let order_book = client.get_order_book_by_instrument_id(42, Some(5)).await?;
println!("Order book for {}: {} bids, {} asks",
         order_book.instrument_name,
         order_book.bids.len(),
         order_book.asks.len());

Trait Implementations§

Source§

impl Clone for DeribitHttpClient

Source§

fn clone(&self) -> DeribitHttpClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DeribitHttpClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DeribitHttpClient

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,