Skip to content

Commit

Permalink
Modified README. v0.1.0 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdnixx committed May 29, 2019
1 parent 807a788 commit f764d44
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 177 deletions.
199 changes: 24 additions & 175 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,189 +1,38 @@
# API Client for [Deribit API](https://www.deribit.com/docs/api/)
# Deribit Simple Gui

## Description

The [Deribit API](https://www.deribit.com) is available in this package.
An experimental GUI interface, with a few useful features, for cryptocurrency trading on [Deribit.](https://www.deribit.com)

### Installation
Uses Deribit API v1. (soon to be deprecated; need to integrate v2 eventually)

```
sudo pip install deribit-api
Deribit API docs:
https://www.deribit.com/docs/api/

```
### Usage

### Example
The program is started from any of the `starter.py` files.

Modify the variables `path_to_keyfile` and `market` inside
it, to set the relative path to the .txt file containing your API keys, and your desired perpetual contract,
respectively:
```
from deribit_api import RestClient
client = RestClient("KEY", "SECRET")
client.index()
client.account()
path_to_keyfile = './deribit_keys.txt' # see ordermanger_interface.py for API key syntax
market = 'btc' # either 'btc' or 'eth'
```

## API - REST Client

`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` |


### Methods

* `getorderbook(instrument)` - [Doc](https://www.deribit.com/docs/api/#getinstruments), public

Retrieve the orderbook for a given instrument.

**Parameters**

| Name | Type | Decription |
|--------------|------------|------------------------------------------------------------|
| `instrument` | `string` | Required, instrument name |

* `index()` - [Doc](https://www.deribit.com/docs/api/#index), public

Get price index, BTC-USD rates.

* `getcurrencies()` - [Doc](https://www.deribit.com/docs/api/#getcurrencies), public

Get all supported currencies.

* `getorderbook(instrument)` - [Doc](https://www.deribit.com/docs/api/#getorderbook), public

Retrieve the orderbook for a given instrument.

**Parameters**

| Name | Type | Decription |
|--------------|------------|------------------------------------------------------------|
| `instrument` | `string` | Required, instrument name |

* `getlasttrades(instrument, count, since)` - [Doc](https://www.deribit.com/docs/api/#getlasttrades), public

Retrieve the latest trades that have occured for a specific instrument.

**Parameters**

| Name | Type | Decription |
|--------------|------------|-------------------------------------------------------------------------------|
| `instrument` | `string` | Required, instrument name |
| `count` | `integer` | Optional, count of trades returned (limitation: max. count is 100) |
| `since` | `integer` | Optional, “since” trade id, the server returns trades newer than that “since” |

* `getsummary(instrument)` - [Doc](https://www.deribit.com/docs/api/#getsummary), public

Retrieve the summary info such as Open Interest, 24H Volume etc for a specific instrument.

**Parameters**

| Name | Type | Decription |
|--------------|------------|------------------------------------------------------------|
| `instrument` | `string` | Required, instrument name |

* `account()` - [Doc](https://www.deribit.com/docs/api/#account), Private

Get user account summary.

* `buy(instrument, quantity, price, postOnly, label)` - [Doc](https://www.deribit.com/docs/api/#buy), private

Place a buy order in an instrument.
The example above starts the program for the BTC-PERPETUAL swap instrument, using API keys in `deribit_keys.txt`,
located in the same (root) directory.

**Parameters**
### Keyfile

| Name | Type | Decription |
|--------------|------------|-----------------------------------------------------------------------------------|
| `instrument` | `string` | Required, instrument name |
| `quantity` | `integer` | Required, quantity, in contracts ($10 per contract for futures, ฿1 — for options) |
| `price` | `float` | Required, USD for futures, BTC for options |
| `postOnly` | `boolean` | Optional, if true then the order will be POST ONLY |
| `label` | `string` | Optional, user defined maximum 4-char label for the order |

* `sell(instrument, quantity, price, postOnly, label)` - [Doc](https://www.deribit.com/docs/api/#sell), private

Place a sell order in an instrument.

**Parameters**

| Name | Type | Decription |
|--------------|------------|-----------------------------------------------------------------------------------|
| `instrument` | `string` | Required, instrument name |
| `quantity` | `integer` | Required, quantity, in contracts ($10 per contract for futures, ฿1 — for options) |
| `price` | `float` | Required, USD for futures, BTC for options |
| `postOnly` | `boolean` | Optional, if true then the order will be POST ONLY |
| `label` | `string` | Optional, user defined maximum 4-char label for the order |

* `edit(orderId, quantity, price)` - [Doc](https://www.deribit.com/docs/api/#edit)

Edit price and/or quantity of the own order. (Authorization is required).

**Parameters**

| Name | Type | Decription |
|--------------|------------|-----------------------------------------------------------------------------------|
| `orderId` | `integer` | Required, ID of the order returned by "sell" or "buy" request |
| `quantity` | `integer` | Required, quantity, in contracts ($10 per contract for futures, ฿1 — for options) |
| `price` | `float` | Required, USD for futures, BTC for options |

* `cancel(orderId)` - [Doc](https://www.deribit.com/docs/api/#cancel), private

Cancell own order by id.

**Parameters**

| Name | Type | Decription |
|--------------|------------|-----------------------------------------------------------------------------------|
| `orderId` | `integer` | Required, ID of the order returned by "sell" or "buy" request |

* `cancelall(type)` - [Doc](https://www.deribit.com/docs/api/#cancelall)

Cancel all own futures, or all options, or all.

**Parameters**

| Name | Type | Decription |
|--------------|------------|-----------------------------------------------------------------------------------------------|
| `type` | `string` | Optional, type of instruments to cancel, allowed: "all", "futures", "options", default: "all" |

* `getopenorders(instrument, orderId)` - [Doc](https://www.deribit.com/docs/api/#getopenorders), private

Retrieve open orders.

**Parameters**

| Name | Type | Description |
|--------------|------------|-----------------------------------------------------------------------|
| `instrument` | `string` | Optional, instrument name, use if want orders for specific instrument |
| `orderId` | `integer` | Optional, order id |

* `positions()` - [Doc](https://www.deribit.com/docs/api/#positions), private

Retreive positions.

* `orderhistory(count)` - [Doc](https://www.deribit.com/docs/api/#orderhistory), private

Get history.

**Parameters**

| Name | Type | Description |
|------------|------------|------------------------------------------------------------|
| `count` | `integer` | Optional, number of requested records |

* `tradehistory(count, instrument, startTradeId)` - [Doc](https://www.deribit.com/docs/api/#tradehistory), private

Get private trade history of the account. (Authorization is required). The result is ordered by trade identifiers (trade id-s).

**Parameters**
The contents of your keyfile should be 2 separate lines. On the first is your API key, and the second, your API secret.
```
ABzGtz9QGVeN
URT2ZLHGG6WTK6XZWKTVZSJLQCXZES46
test
```
For use on the [testnet](https://www.test.deribit.com), add a third line containing only the text `test` (as in
above example).

| Name | Type | Description |
|----------------|------------|----------------------------------------------------------------------------------------------------|
| `count` | `integer` | Optional, number of results to fetch. Default: 20 |
| `instrument` | `string` | Optional, name of instrument, also aliases “all”, “futures”, “options” are allowed. Default: "all" |
| `startTradeId` | `integer` | Optional, number of requested records |
For live usage, leave the third line off completely.
3 changes: 3 additions & 0 deletions pyqt_ui/first.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ def setupUi(self, Form):
self.retranslateUi(Form)
self.btn_addMktBuy.clicked.connect(Form.add_mktbuy_btn)
self.lineEdit.textChanged['QString'].connect(Form.lineEdit_amt_edited)
self.btn_addMktSell.clicked.connect(Form.add_mktsell_btn)
self.btn_addLCBuy.clicked.connect(Form.add_limitchasebuy_btn)
self.btn_addLCSell.clicked.connect(Form.add_limitchasesell_btn)
QtCore.QMetaObject.connectSlotsByName(Form)
Form.setTabOrder(self.lineEdit, self.spinBox)
Form.setTabOrder(self.spinBox, self.btn_addMktBuy)
Expand Down
55 changes: 53 additions & 2 deletions pyqt_ui/first.ui
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@
<y>53</y>
</hint>
<hint type="destinationlabel">
<x>145</x>
<y>191</y>
<x>87</x>
<y>182</y>
</hint>
</hints>
</connection>
Expand All @@ -211,10 +211,61 @@
</hint>
</hints>
</connection>
<connection>
<sender>btn_addMktSell</sender>
<signal>clicked()</signal>
<receiver>Form</receiver>
<slot>add_mktsell_btn()</slot>
<hints>
<hint type="sourcelabel">
<x>66</x>
<y>87</y>
</hint>
<hint type="destinationlabel">
<x>88</x>
<y>159</y>
</hint>
</hints>
</connection>
<connection>
<sender>btn_addLCBuy</sender>
<signal>clicked()</signal>
<receiver>Form</receiver>
<slot>add_limitchasebuy_btn()</slot>
<hints>
<hint type="sourcelabel">
<x>177</x>
<y>58</y>
</hint>
<hint type="destinationlabel">
<x>256</x>
<y>156</y>
</hint>
</hints>
</connection>
<connection>
<sender>btn_addLCSell</sender>
<signal>clicked()</signal>
<receiver>Form</receiver>
<slot>add_limitchasesell_btn()</slot>
<hints>
<hint type="sourcelabel">
<x>192</x>
<y>90</y>
</hint>
<hint type="destinationlabel">
<x>259</x>
<y>181</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<signal>mktbuy_signal()</signal>
<slot>add_mktbuy_btn()</slot>
<slot>lineEdit_amt_edited(QString)</slot>
<slot>add_mktsell_btn()</slot>
<slot>add_limitchasebuy_btn()</slot>
<slot>add_limitchasesell_btn()</slot>
</slots>
</ui>

0 comments on commit f764d44

Please sign in to comment.