From f764d4400e036e76f49471eda40bb0d14186e475 Mon Sep 17 00:00:00 2001 From: jDally987 Date: Wed, 29 May 2019 01:02:22 -0400 Subject: [PATCH] Modified README. v0.1.0 release. --- README.md | 199 ++++++----------------------------------------- pyqt_ui/first.py | 3 + pyqt_ui/first.ui | 55 ++++++++++++- 3 files changed, 80 insertions(+), 177 deletions(-) diff --git a/README.md b/README.md index 0f998c0..437f9ec 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file diff --git a/pyqt_ui/first.py b/pyqt_ui/first.py index 125582a..ff6185e 100644 --- a/pyqt_ui/first.py +++ b/pyqt_ui/first.py @@ -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) diff --git a/pyqt_ui/first.ui b/pyqt_ui/first.ui index 800ca2b..cc7cc0b 100644 --- a/pyqt_ui/first.ui +++ b/pyqt_ui/first.ui @@ -190,8 +190,8 @@ 53 - 145 - 191 + 87 + 182 @@ -211,10 +211,61 @@ + + btn_addMktSell + clicked() + Form + add_mktsell_btn() + + + 66 + 87 + + + 88 + 159 + + + + + btn_addLCBuy + clicked() + Form + add_limitchasebuy_btn() + + + 177 + 58 + + + 256 + 156 + + + + + btn_addLCSell + clicked() + Form + add_limitchasesell_btn() + + + 192 + 90 + + + 259 + 181 + + + mktbuy_signal() add_mktbuy_btn() lineEdit_amt_edited(QString) + add_mktsell_btn() + add_limitchasebuy_btn() + add_limitchasesell_btn()