Deribit
CryptoExchangeAPIs.Deribit.DeribitClient
— TypeDeribitClient <: AbstractAPIsClient
Client info.
Required fields
base_url::String
: Base URL for the client.
Optional fields
public_key::String
: Public key for authentication.secret_key::String
: Secret key for authentication.interface::String
: Interface for the client.proxy::String
: Proxy information for the client.account_name::String
: Account name associated with the client.description::String
: Description of the client.
CryptoExchangeAPIs.Deribit.DeribitAPIsErrorMsg
— TypeDeribitAPIsErrorMsg <: AbstractAPIsError
Required fields
data::Dict{String,String}
: Additional data about the error.message::String
: A short description that indicates the kind of error.code::Int64
: A number that indicates the kind of error.
CryptoExchangeAPIs.Deribit.DeribitAPIError
— TypeDeribitAPIError{T} <: AbstractAPIsError
Exception thrown when an API method fails with code T
.
Required fields
jsonrpc::String
: The version of the JSON-RPC spec.error::DeribitAPIsErrorMsg
: Only present if there was an error invoking the method.
Optional fields
id::Maybe{Int64}
: This is the same id that was sent in the request.testnet::Maybe{Bool}
: Indicates whether the API in use is actually the test API.usDiff::Maybe{Int64}
: The number of microseconds that was spent handling the request.usOut::Maybe{NanoDate}
: The timestamp when the response was sent (microseconds since the Unix epoch).usIn::Maybe{NanoDate}
: The timestamp when the requests was received (microseconds since the Unix epoch).
CryptoExchangeAPIs.Deribit.Data
— TypeData{D<:Union{Vector{A},A} where {A<:AbstractAPIsData}} <: AbstractAPIsData
Required fields
jsonrpc::String
: The version of the JSON-RPC spec.result::D
: If successful, the result of the API call.
Optional fields
id::Maybe{Int64}
: This is the same id that was sent in the request.testnet::Maybe{Bool}
: Indicates whether the API in use is actually the test API.usDiff::Maybe{Int64}
: The number of microseconds that was spent handling the request.usOut::Maybe{NanoDate}
: The timestamp when the response was sent (microseconds since the Unix epoch).usIn::Maybe{NanoDate}
: The timestamp when the requests was received (microseconds since the Unix epoch).
Common
CryptoExchangeAPIs.Deribit.Common.public_client
— Constantpublic_client = DeribitClient(; base_url = "https://www.deribit.com")
CryptoExchangeAPIs.Deribit.Common.BookSummary.book_summary
— Functionbook_summary(client::DeribitClient, query::BookSummaryQuery)
book_summary(client::DeribitClient = Deribit.Common.public_client; kw...)
Retrieves the summary information such as open interest, 24h volume, etc. for all instruments for the currency (optionally filtered by kind).
GET api/v2/public/get_book_summary_by_currency
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
currency | Currency | true | BTC ETH USDC USDT |
kind | InstrumentKind | false | option spot future future_combo option_combo |
Code samples:
using Serde
using CryptoExchangeAPIs.Deribit
result = Deribit.Common.book_summary(;
currency = CryptoExchangeAPIs.Deribit.Common.BookSummary.BTC
)
to_pretty_json(result.result)
Result:
{
"id":null,
"jsonrpc":"2.0",
"testnet":false,
"usDiff":1746,
"usOut":"2024-05-17T11:57:46.222272",
"usIn":"2024-05-17T11:57:46.220526080",
"result":[
{
"instrument_name":"BTC-31MAY24-59000-P",
"base_currency":"BTC",
"quote_currency":"BTC",
"ask_price":0.0065,
"bid_price":0.006,
"mid_price":0.00625,
"mark_price":0.00616094,
"estimated_delivery_price":66227.07,
"price_change":-23.5294,
"volume":196.0,
"volume_notional":null,
"volume_usd":98503.18,
"high":0.0105,
"low":0.006,
"last":0.0065,
"current_funding":null,
"funding_8h":null,
"interest_rate":0.0,
"open_interest":569.7,
"underlying_index":"BTC-31MAY24",
"underlying_price":66481.53,
"creation_timestamp":"2024-05-17T12:00:15.647000064"
},
...
]
}
CryptoExchangeAPIs.Deribit.Common.Candle.candle
— Functioncandle(client::DeribitClient, query::CandleQuery)
candle(client::DeribitClient = Deribit.Common.public_client; kw...)
Publicly available market data used to generate a TradingView candle chart.
GET api/v2/public/get_tradingview_chart_data
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
end_timestamp | DateTime | true | |
instrument_name | String | true | |
resolution | TimeInterval | true | m1 m3 m5 m10 m15 m30 h1 h2 h3 h6 h12 d1 |
start_timestamp | DateTime | true |
Code samples:
using Serde
using CryptoExchangeAPIs.Deribit
result = Deribit.Common.candle(;
instrument_name = "BTC-PERPETUAL",
start_timestamp = now(UTC) - Minute(100),
end_timestamp = now(UTC) - Hour(1),
resolution = CryptoExchangeAPIs.Deribit.Common.Candle.m1,
)
to_pretty_json(result.result)
Result:
{
"id":null,
"jsonrpc":"2.0",
"testnet":false,
"usDiff":1746,
"usOut":"2024-05-17T11:57:46.222272",
"usIn":"2024-05-17T11:57:46.220526080",
"result":{
"close":[
66324.5,
...
],
"cost":[
101810.0,
...
],
"high":[
66324.5,
...
],
"low":[
66323.0,
...
],
"open":[
66323.0,
...
],
"status":"ok",
"ticks":[
"2024-05-17T10:17:00",
...
],
"volume":[
1.53504587,
...
]
}
}
CryptoExchangeAPIs.Deribit.Common.FundingRate.funding_rate
— Functionfunding_rate(client::DeribitClient, query::FundingRateQuery)
funding_rate(client::DeribitClient = Deribit.Common.public_client; kw...)
Retrieves hourly historical interest rate for requested PERPETUAL instrument.
GET api/v2/public/get_funding_rate_history
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
end_timestamp | DateTime | true | |
instrument_name | String | true | |
start_timestamp | DateTime | true |
Code samples:
using Serde
using CryptoExchangeAPIs.Deribit
result = Deribit.Common.funding_rate(;
instrument_name = "BTC-PERPETUAL",
start_timestamp = Dates.DateTime("2022-11-08"),
end_timestamp = Dates.DateTime("2022-11-08") + Day(2),
)
to_pretty_json(result.result)
Result:
{
"id":null,
"jsonrpc":"2.0",
"testnet":false,
"usDiff":43615,
"usOut":"2024-05-17T12:01:49.482341888",
"usIn":"2024-05-17T12:01:49.438726912",
"result":[
{
"index_price":20516.0,
"interest_1h":9.873575714940002e-7,
"interest_8h":4.479902336495525e-5,
"prev_index_price":20592.45,
"timestamp":"2022-11-08T01:00:00"
},
...
]
}
CryptoExchangeAPIs.Deribit.Common.Instrument.instrument
— Functioninstrument(client::DeribitClient, query::InstrumentQuery)
instrument(client::DeribitClient = Deribit.Common.public_client; kw...)
Retrieves available trading instruments. This method can be used to see which instruments are available for trading, or which instruments have recently expired.
GET api/v2/public/get_instruments
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
currency | Currency | true | BTC ETH USDC USDT |
expired | Bool | false | |
kind | InstrumentKind | false | option spot future future_combo option_combo |
Code samples:
using Serde
using CryptoExchangeAPIs.Deribit
result = Deribit.Common.instrument(;
currency = Deribit.Common.Instrument.BTC
)
to_pretty_json(result.result)
Result:
{
"id":null,
"jsonrpc":"2.0",
"testnet":false,
"usDiff":1746,
"usOut":"2024-05-17T11:57:46.222272",
"usIn":"2024-05-17T11:57:46.220526080",
"result":[
{
"instrument_name":"BTC-18MAY24-55000-C",
"base_currency":"BTC",
"quote_currency":"BTC",
"block_trade_commission":0.0003,
"block_trade_min_trade_amount":25.0,
"block_trade_tick_size":0.0001,
"contract_size":1.0,
"counter_currency":"USD",
"creation_timestamp":"2024-05-15T08:00:13",
"expiration_timestamp":"2024-05-18T08:00:00",
"future_type":null,
"instrument_id":326799,
"instrument_type":"reversed",
"is_active":true,
"kind":"option",
"maker_commission":0.0003,
"max_leverage":null,
"max_liquidation_commission":null,
"min_trade_amount":0.1,
"option_type":"call",
"price_index":"btc_usd",
"rfq":false,
"settlement_currency":"BTC",
"settlement_period":"day",
"strike":55000.0,
"taker_commission":0.0003,
"tick_size":0.0001
},
...
]
}
CryptoExchangeAPIs.Deribit.Common.OrderBook.order_book
— Functionorder_book(client::DeribitClient, query::OrderBookQuery)
order_book(client::DeribitClient = Deribit.Common.public_client; kw...)
Retrieves the order book, along with other market values for a given instrument.
GET api/v2/public/get_order_book
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
instrument_name | String | true | |
depth | Depth | false | ONE (1), FIVE (5), TEN (10), TWENTY (20), FIFTY (50), ONE_HUNDRED (100), THOUSAND (1000), TEN_THOUSAND (10000) |
Code samples:
using Serde
using CryptoExchangeAPIs.Deribit
result = Deribit.Common.order_book(;
instrument_name = "BTC-PERPETUAL",
depth = CryptoExchangeAPIs.Deribit.Common.OrderBook.TEN,
)
to_pretty_json(result.result)
Result:
{
"id":null,
"jsonrpc":"2.0",
"testnet":false,
"usDiff":808,
"usOut":"2024-05-17T12:09:18.775115008",
"usIn":"2024-05-17T12:09:18.774307072",
"result":{
"ask_iv":null,
"asks":[
{
"amount":66265.0,
"price":164430.0
},
...
],
"best_ask_amount":164430.0,
"best_ask_price":66265.0,
"best_bid_amount":116100.0,
"best_bid_price":66264.5,
"bid_iv":null,
"bids":[
{
"amount":66264.5,
"price":116100.0
},
...
],
"change_id":70662452234,
"current_funding":1.733e-5,
"delivery_price":null,
"estimated_delivery_price":66247.85,
"funding_8h":2.696e-5,
"greeks":null,
"index_price":66247.85,
"instrument_name":"BTC-PERPETUAL",
"interest_rate":null,
"last_price":66264.5,
"mark_iv":null,
"mark_price":66265.56,
"max_price":68254.0,
"min_price":64277.5,
"open_interest":7.0092997e8,
"settlement_price":66421.48,
"state":"open",
"stats":{
"high":66798.0,
"low":64620.5,
"price_change":0.0521,
"volume":9341.58521281,
"volume_usd":6.1459374e8
},
"timestamp":"2024-05-17T12:09:18.761999872",
"underlying_index":null,
"underlying_price":null
}
}
CryptoExchangeAPIs.Deribit.Common.Ticker.ticker
— Functionticker(client::DeribitClient, query::TickerQuery)
ticker(client::DeribitClient = Deribit.Common.public_client; kw...)
Get ticker for an instrument.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
instrument_name | String | true |
Code samples:
using Serde
using CryptoExchangeAPIs.Deribit
result = Deribit.Common.ticker(;
instrument_name = "BTC-PERPETUAL",
)
to_pretty_json(result.result)
Result:
{
"id":null,
"jsonrpc":"2.0",
"testnet":false,
"usDiff":209,
"usOut":"2024-05-17T12:10:28.639980032",
"usIn":"2024-05-17T12:10:28.639770880",
"result":{
"instrument_name":"BTC-PERPETUAL",
"ask_iv":null,
"best_ask_amount":227380.0,
"best_ask_price":66265.0,
"best_bid_amount":27200.0,
"best_bid_price":66264.5,
"bid_iv":null,
"current_funding":2.428e-5,
"delivery_price":null,
"estimated_delivery_price":66245.52,
"funding_8h":2.703e-5,
"greeks":null,
"index_price":66245.52,
"interest_rate":null,
"interest_value":0.011170326646787519,
"last_price":66265.0,
"mark_iv":null,
"mark_price":66263.69,
"max_price":68252.0,
"min_price":64275.5,
"open_interest":7.0092983e8,
"settlement_price":66421.48,
"state":"open",
"stats":{
"high":66798.0,
"low":64620.5,
"price_change":-0.0121,
"volume":9331.58638298,
"volume_usd":6.139311e8
},
"timestamp":"2024-05-17T12:10:28.576",
"underlying_index":null,
"underlying_price":null
}
}