|
| 1 | +# API Client for [Deribit API](https://www.deribit.com/docs/api/) |
| 2 | + |
| 3 | +## Description |
| 4 | + |
| 5 | +The [Deribit API](https://www.deribit.com) is available in this package. |
| 6 | + |
| 7 | +### Installation |
| 8 | + |
| 9 | +``` |
| 10 | +sudo pip install deribit-api |
| 11 | +
|
| 12 | +``` |
| 13 | + |
| 14 | +### Example |
| 15 | + |
| 16 | +``` |
| 17 | +from deribit_api import RestClient |
| 18 | +client = RestClient("KEY", "SECRET") |
| 19 | +client.index() |
| 20 | +client.account() |
| 21 | +``` |
| 22 | + |
| 23 | +## API - REST Client |
| 24 | + |
| 25 | +`new RestClient(key, secret, url)` |
| 26 | + |
| 27 | +Constructor creates new REST client. |
| 28 | + |
| 29 | +**Parameters** |
| 30 | + |
| 31 | +| Name | Type | Decription | |
| 32 | +|----------|----------|-----------------------------------------------------------| |
| 33 | +| `key` | `string` | Optional, Access Key needed to access Private functions | |
| 34 | +| `secret` | `string` | Optional, Access Secret needed to access Private functions| |
| 35 | +| `url` | `string` | Optional, server URL, default: `https://www.deribit.com` | |
| 36 | + |
| 37 | + |
| 38 | +### Methods |
| 39 | + |
| 40 | +* `getorderbook(instrument)` - [Doc](https://www.deribit.com/docs/api/#getinstruments), public |
| 41 | + |
| 42 | + Retrieve the orderbook for a given instrument. |
| 43 | + |
| 44 | + **Parameters** |
| 45 | + |
| 46 | + | Name | Type | Decription | |
| 47 | + |--------------|------------|------------------------------------------------------------| |
| 48 | + | `instrument` | `string` | Required, instrument name | |
| 49 | + |
| 50 | +* `index()` - [Doc](https://www.deribit.com/docs/api/#index), public |
| 51 | + |
| 52 | + Get price index, BTC-USD rates. |
| 53 | + |
| 54 | +* `getcurrencies()` - [Doc](https://www.deribit.com/docs/api/#getcurrencies), public |
| 55 | + |
| 56 | + Get all supported currencies. |
| 57 | + |
| 58 | +* `getorderbook(instrument)` - [Doc](https://www.deribit.com/docs/api/#getorderbook), public |
| 59 | + |
| 60 | + Retrieve the orderbook for a given instrument. |
| 61 | + |
| 62 | + **Parameters** |
| 63 | + |
| 64 | + | Name | Type | Decription | |
| 65 | + |--------------|------------|------------------------------------------------------------| |
| 66 | + | `instrument` | `string` | Required, instrument name | |
| 67 | + |
| 68 | +* `getlasttrades(instrument, count, since)` - [Doc](https://www.deribit.com/docs/api/#getlasttrades), public |
| 69 | + |
| 70 | + Retrieve the latest trades that have occured for a specific instrument. |
| 71 | + |
| 72 | + **Parameters** |
| 73 | + |
| 74 | + | Name | Type | Decription | |
| 75 | + |--------------|------------|-------------------------------------------------------------------------------| |
| 76 | + | `instrument` | `string` | Required, instrument name | |
| 77 | + | `count` | `integer` | Optional, count of trades returned (limitation: max. count is 100) | |
| 78 | + | `since` | `integer` | Optional, “since” trade id, the server returns trades newer than that “since” | |
| 79 | + |
| 80 | +* `getsummary(instrument)` - [Doc](https://www.deribit.com/docs/api/#getsummary), public |
| 81 | + |
| 82 | + Retrieve the summary info such as Open Interest, 24H Volume etc for a specific instrument. |
| 83 | + |
| 84 | + **Parameters** |
| 85 | + |
| 86 | + | Name | Type | Decription | |
| 87 | + |--------------|------------|------------------------------------------------------------| |
| 88 | + | `instrument` | `string` | Required, instrument name | |
| 89 | + |
| 90 | +* `account()` - [Doc](https://www.deribit.com/docs/api/#account), Private |
| 91 | + |
| 92 | + Get user account summary. |
| 93 | + |
| 94 | +* `buy(instrument, quantity, price, postOnly, label)` - [Doc](https://www.deribit.com/docs/api/#buy), private |
| 95 | + |
| 96 | + Place a buy order in an instrument. |
| 97 | + |
| 98 | + **Parameters** |
| 99 | + |
| 100 | + | Name | Type | Decription | |
| 101 | + |--------------|------------|-----------------------------------------------------------------------------------| |
| 102 | + | `instrument` | `string` | Required, instrument name | |
| 103 | + | `quantity` | `integer` | Required, quantity, in contracts ($10 per contract for futures, ฿1 — for options) | |
| 104 | + | `price` | `float` | Required, USD for futures, BTC for options | |
| 105 | + | `postOnly` | `boolean` | Optional, if true then the order will be POST ONLY | |
| 106 | + | `label` | `string` | Optional, user defined maximum 4-char label for the order | |
| 107 | + |
| 108 | +* `sell(instrument, quantity, price, postOnly, label)` - [Doc](https://www.deribit.com/docs/api/#sell), private |
| 109 | + |
| 110 | + Place a sell order in an instrument. |
| 111 | + |
| 112 | + **Parameters** |
| 113 | + |
| 114 | + | Name | Type | Decription | |
| 115 | + |--------------|------------|-----------------------------------------------------------------------------------| |
| 116 | + | `instrument` | `string` | Required, instrument name | |
| 117 | + | `quantity` | `integer` | Required, quantity, in contracts ($10 per contract for futures, ฿1 — for options) | |
| 118 | + | `price` | `float` | Required, USD for futures, BTC for options | |
| 119 | + | `postOnly` | `boolean` | Optional, if true then the order will be POST ONLY | |
| 120 | + | `label` | `string` | Optional, user defined maximum 4-char label for the order | |
| 121 | + |
| 122 | +* `edit(orderId, quantity, price)` - [Doc](https://www.deribit.com/docs/api/#edit) |
| 123 | + |
| 124 | + Edit price and/or quantity of the own order. (Authorization is required). |
| 125 | + |
| 126 | + **Parameters** |
| 127 | + |
| 128 | + | Name | Type | Decription | |
| 129 | + |--------------|------------|-----------------------------------------------------------------------------------| |
| 130 | + | `orderId` | `integer` | Required, ID of the order returned by "sell" or "buy" request | |
| 131 | + | `quantity` | `integer` | Required, quantity, in contracts ($10 per contract for futures, ฿1 — for options) | |
| 132 | + | `price` | `float` | Required, USD for futures, BTC for options | |
| 133 | + |
| 134 | +* `cancel(orderId)` - [Doc](https://www.deribit.com/docs/api/#cancel), private |
| 135 | + |
| 136 | + Cancell own order by id. |
| 137 | + |
| 138 | + **Parameters** |
| 139 | + |
| 140 | + | Name | Type | Decription | |
| 141 | + |--------------|------------|-----------------------------------------------------------------------------------| |
| 142 | + | `orderId` | `integer` | Required, ID of the order returned by "sell" or "buy" request | |
| 143 | + |
| 144 | +* `cancelall(type)` - [Doc](https://www.deribit.com/docs/api/#cancelall) |
| 145 | + |
| 146 | + Cancel all own futures, or all options, or all. |
| 147 | + |
| 148 | + **Parameters** |
| 149 | + |
| 150 | + | Name | Type | Decription | |
| 151 | + |--------------|------------|-----------------------------------------------------------------------------------------------| |
| 152 | + | `type` | `string` | Optional, type of instruments to cancel, allowed: "all", "futures", "options", default: "all" | |
| 153 | + |
| 154 | +* `getopenorders(instrument, orderId)` - [Doc](https://www.deribit.com/docs/api/#getopenorders), private |
| 155 | + |
| 156 | + Retrieve open orders. |
| 157 | + |
| 158 | + **Parameters** |
| 159 | + |
| 160 | + | Name | Type | Description | |
| 161 | + |--------------|------------|-----------------------------------------------------------------------| |
| 162 | + | `instrument` | `string` | Optional, instrument name, use if want orders for specific instrument | |
| 163 | + | `orderId` | `integer` | Optional, order id | |
| 164 | + |
| 165 | +* `positions()` - [Doc](https://www.deribit.com/docs/api/#positions), private |
| 166 | + |
| 167 | + Retreive positions. |
| 168 | + |
| 169 | +* `orderhistory(count)` - [Doc](https://www.deribit.com/docs/api/#orderhistory), private |
| 170 | + |
| 171 | + Get history. |
| 172 | + |
| 173 | + **Parameters** |
| 174 | + |
| 175 | + | Name | Type | Description | |
| 176 | + |------------|------------|------------------------------------------------------------| |
| 177 | + | `count` | `integer` | Optional, number of requested records | |
| 178 | + |
| 179 | +* `tradehistory(count, instrument, startTradeId)` - [Doc](https://www.deribit.com/docs/api/#tradehistory), private |
| 180 | + |
| 181 | + Get private trade history of the account. (Authorization is required). The result is ordered by trade identifiers (trade id-s). |
| 182 | + |
| 183 | + **Parameters** |
| 184 | + |
| 185 | + | Name | Type | Description | |
| 186 | + |----------------|------------|----------------------------------------------------------------------------------------------------| |
| 187 | + | `count` | `integer` | Optional, number of results to fetch. Default: 20 | |
| 188 | + | `instrument` | `string` | Optional, name of instrument, also aliases “all”, “futures”, “options” are allowed. Default: "all" | |
| 189 | + | `startTradeId` | `integer` | Optional, number of requested records | |
0 commit comments