Deribit API V2 Client for Rust Language
![Build Status] ![Latest Version] ![Rustc Version nightly] ![license] ![keybase logo] ![btc]
Use this library for trading at your own risk.
The current plan is to only implement the websocket communication, which includes call api through websocket
and websocket subscription. I will first implement these APIs used for my own trading purpose, however, if you want some APIs
to be prioritly implemented please open an issue or just throw me a PR (this is more welcome :P).
Basic usage
```rust
// This will give you a Deribit instance, which the only purpose is to create connection.
let drb = deribit::DeribitBuilder::default().build().expect("Cannot create deribit client");
// "Deribit::connect" will connect to the deribit server with websocket as well as
// spin up a task in the backgroud polling message and dispatch them to subscription channel or RPC channel respectively.
// "Deribit::connect" returns a "(DeribitAPIClient, DeribitSubscriptionClient)" tuple, where
// the former is used for sending out RPC requests, and the later is used for receiving notifications.
let (mut client, mut subscription) = drb.connect().await?;
// All the request models reside in "deribit::models" module, with the
// naming convention of "camelCase(method)+Request", e.g. "/public/test" would be
// "TestRequest" in deribit-rs.
let req = deribit::models::TestRequest::default();
// Calls to deribit server is made by giving "DeribitAPIClient::call" the request object.
// The return type of "DeribitAPIClient::call" is "impl Future
// Subscription is made by calling with "PublicSubscribeRequest" or "PrivateSubscribeRequest".
let req = PublicSubscribeRequest::new(&["book.BTC-PERPETUAL.raw".into()]);
// You can avoid the second ".await" to save some time - no worries, the request will still be received by the deribit server.
let _ = client.call(req).await?;
// In order to get your subscriptions, just poll the subscription stream. The "DeribitSubscriptionClient" implements the "futures::Stream" trait.
while let Some(message) = subscription.next().await {
println!("Subscription message received {:?}", message);
}
```
Implementation Status
- Authentication
- [x] /public/auth
- [x] /public/exchangetoken
- [x] /public/forktoken
- [x] /private/logout
- Session Management
- [x] /public/setheartbeat
- [x] /public/disableheartbeat
- [x] /private/enablecancelondisconnect
- [x] /private/disablecancelondisconnect
- [x] /private/getcancelon_disconnect
- Supporting
- [x] /public/get_time
- [x] /public/hello
- [x] /public/test
- Subscription Management
- [x] /public/subscribe
- [x] /public/unsubscribe
- [x] /private/subscribe
- [x] /private/unsubscribe
- Account Management
- [ ] /public/getannouncements
- [ ] /private/changeapikeyname
- [ ] /private/changescopeinapikey
- [ ] /private/changesubaccountname
- [ ] /private/createapikey
- [ ] /private/createsubaccount
- [ ] /private/disableapikey
- [ ] /private/disabletfaforsubaccount
- [ ] /private/enableapikey
- [x] /private/getaccountsummary
- [ ] /private/getemaillanguage
- [ ] /private/getnewannouncements
- [ ] /private/getposition
- [x] /private/getpositions
- [x] /private/getsubaccounts
- [ ] /private/listapikeys
- [ ] /private/removeapikey
- [ ] /private/resetapikey
- [ ] /private/setannouncementasread
- [ ] /private/setapikeyasdefault
- [ ] /private/setemailforsubaccount
- [ ] /private/setemaillanguage
- [ ] /private/setpasswordforsubaccount
- [ ] /private/togglenotificationsfrom_subaccount
- [ ] /private/togglesubaccountlogin
- Block Trading
- [ ] /private/executeblocktrade
- [ ] /private/getblocktrade
- [ ] /private/getlastblocktradesbycurrency
- [ ] /private/invalidateblocktradesignature
- [ ] /private/verifyblocktrade
- Trading
- [x] /private/buy
- [x] /private/sell
- [x] /private/edit
- [x] /private/cancel
- [x] /private/cancelall
- [x] /private/cancelallbycurrency
- [x] /private/cancelallbyinstrument
- [ ] /private/cancelbylabel
- [ ] /private/closeposition
- [ ] /private/getmargins
- [x] /private/getopenordersbycurrency
- [x] /private/getopenordersbyinstrument
- [ ] /private/getorderhistorybycurrency
- [ ] /private/getorderhistorybyinstrument
- [ ] /private/getordermarginbyids
- [x] /private/getorderstate
- [ ] /private/getstoporderhistory
- [ ] /private/getusertradesbycurrency
- [ ] /private/getusertradesbycurrencyandtime
- [ ] /private/getusertradesbyinstrument
- [ ] /private/getusertradesbyinstrumentandtime
- [ ] /private/getusertradesbyorder
- [ ] /private/getsettlementhistorybyinstrument
- [ ] /private/getsettlementhistorybycurrency
- Market Data
- [x] /public/getbooksummarybycurrency
- [ ] /public/getbooksummarybyinstrument
- [ ] /public/getcontractsize
- [ ] /public/getcurrencies
- [ ] /public/getfundingchartdata
- [ ] /public/getfundingratehistory
- [ ] /public/getfundingratevalue
- [ ] /public/gethistoricalvolatility
- [x] /public/getindex
- [x] /public/getinstruments
- [ ] /public/getlastsettlementsbycurrency
- [ ] /public/getlastsettlementsbyinstrument
- [ ] /public/getlasttradesbycurrency
- [ ] /public/getlasttradesbycurrencyandtime
- [ ] /public/getlasttradesbyinstrument
- [ ] /public/getlasttradesbyinstrumentandtime
- [ ] /public/getorderbook
- [ ] /public/gettradevolumes
- [ ] /public/gettradingviewchart_data
- [ ] /public/ticker
- Wallet
- [ ] /private/canceltransferbyid
- [ ] /private/cancelwithdrawal
- [ ] /private/createdepositaddress
- [ ] /private/getcurrentdepositaddress
- [ ] /private/getdeposits
- [x] /private/gettransfers
- [ ] /private/getwithdrawals
- [x] /private/submittransfertosubaccount
- [x] /private/submittransfertouser
- [x] /private/withdraw
- Subscriptions
- [x] announcements
- [x] book.{instrumentname}.{group}.{depth}.{interval}
- [x] book.{instrumentname}.{interval}
- [ ] chart.trades.{instrumentname}.{resolution}
- [x] deribitpriceindex.{indexname}
- [x] deribitpriceranking.{indexname}
- [x] estimatedexpirationprice.{indexname}
- [x] markprice.options.{indexname}
- [x] perpetual.{instrumentname}.{interval}
- [ ] platformstate
- [x] quote.{instrumentname}
- [x] ticker.{instrumentname}.{interval}
- [x] trades.{instrumentname}.{interval}
- [ ] trades.{kind}.{currency}.{interval}
- [ ] user.changes.{instrumentname}.{interval}
- [ ] user.changes.{kind}.{currency}.{interval}
- [x] user.orders.{instrumentname}.{interval}
- [x] user.orders.{kind}.{currency}.{interval}
- [x] user.portfolio.{currency}
- [x] user.trades.{instrument_name}.{interval}
- [x] user.trades.{kind}.{currency}.{interval}
Donate

16PeVqncfWoQ94M4pxnitkYnnW8agQBBZB