API Client for Deribit API
The Deribit API is available in this package.
sudo pip install deribit-api
from deribit_api import RestClient
client = RestClient("KEY", "SECRET")
client.index()
client.account()
new RestClient(key, secret, url)
Constructor creates new REST client.
Parameters
| Name | Type | Decription |
|---|---|---|
key |
string |
Optional, Access Key needed to access Private functions |
secret |
string |
Optional, Access Secret needed to access Private functions |
url |
string |
Optional, server URL, default: https://www.deribit.com |
-
getorderbook(instrument)- Doc, publicRetrieve the orderbook for a given instrument.
Parameters
Name Type Decription instrumentstringRequired, instrument name -
index()- Doc, publicGet price index, BTC-USD rates.
-
getcurrencies()- Doc, publicGet all supported currencies.
-
getorderbook(instrument)- Doc, publicRetrieve the orderbook for a given instrument.
Parameters
Name Type Decription instrumentstringRequired, instrument name -
getlasttrades(instrument, count, since)- Doc, publicRetrieve the latest trades that have occured for a specific instrument.
Parameters
Name Type Decription instrumentstringRequired, instrument name countintegerOptional, count of trades returned (limitation: max. count is 100) sinceintegerOptional, “since” trade id, the server returns trades newer than that “since” -
getsummary(instrument)- Doc, publicRetrieve the summary info such as Open Interest, 24H Volume etc for a specific instrument.
Parameters
Name Type Decription instrumentstringRequired, instrument name -
account()- Doc, PrivateGet user account summary.
-
buy(instrument, quantity, price, postOnly, label)- Doc, privatePlace a buy order in an instrument.
Parameters
Name Type Decription instrumentstringRequired, instrument name quantityintegerRequired, quantity, in contracts ($10 per contract for futures, ฿1 — for options) pricefloatRequired, USD for futures, BTC for options postOnlybooleanOptional, if true then the order will be POST ONLY labelstringOptional, user defined maximum 4-char label for the order -
sell(instrument, quantity, price, postOnly, label)- Doc, privatePlace a sell order in an instrument.
Parameters
Name Type Decription instrumentstringRequired, instrument name quantityintegerRequired, quantity, in contracts ($10 per contract for futures, ฿1 — for options) pricefloatRequired, USD for futures, BTC for options postOnlybooleanOptional, if true then the order will be POST ONLY labelstringOptional, user defined maximum 4-char label for the order -
edit(orderId, quantity, price)- DocEdit price and/or quantity of the own order. (Authorization is required).
Parameters
Name Type Decription orderIdintegerRequired, ID of the order returned by "sell" or "buy" request quantityintegerRequired, quantity, in contracts ($10 per contract for futures, ฿1 — for options) pricefloatRequired, USD for futures, BTC for options -
cancel(orderId)- Doc, privateCancell own order by id.
Parameters
Name Type Decription orderIdintegerRequired, ID of the order returned by "sell" or "buy" request -
cancelall(type)- DocCancel all own futures, or all options, or all.
Parameters
Name Type Decription typestringOptional, type of instruments to cancel, allowed: "all", "futures", "options", default: "all" -
getopenorders(instrument, orderId)- Doc, privateRetrieve open orders.
Parameters
Name Type Description instrumentstringOptional, instrument name, use if want orders for specific instrument orderIdintegerOptional, order id -
positions()- Doc, privateRetreive positions.
-
orderhistory(count)- Doc, privateGet history.
Parameters
Name Type Description countintegerOptional, number of requested records -
tradehistory(count, instrument, startTradeId)- Doc, privateGet private trade history of the account. (Authorization is required). The result is ordered by trade identifiers (trade id-s).
Parameters
Name Type Description countintegerOptional, number of results to fetch. Default: 20 instrumentstringOptional, name of instrument, also aliases “all”, “futures”, “options” are allowed. Default: "all" startTradeIdintegerOptional, number of requested records