deribit 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 01033c2b53f215d35bbfe632dfa2c36b1892ebe305943d2d126aafe3a026c231
4
+ data.tar.gz: 82540961814471f3c11dcdd0be67b7bfd7d4a5c8fc57a17d43ed22be3d281509
5
+ SHA512:
6
+ metadata.gz: 5f8fd1d0aa6c42a4c9f0e0fa4ac89fff4387774e29f4e5e451542a284e9ec8a1c217177cf203f3cab9e0504bbc1ce80f01fad7488a082fa0716d401dff6c448a
7
+ data.tar.gz: '097fb448d4addd3c5ca370f788dca646d7a2a8ff57509fefb84023b60e7a4547cd90daf973aad73e18b46cf089d6aa56353df5ad6119799459a087758b2705dc'
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ *.gem
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install: gem install bundler -v 1.16.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at alexanderdmv@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ group :test do
6
+ gem 'webmock'
7
+ gem 'vcr'
8
+ end
9
+
10
+ # Specify your gem's dependencies in deribit.gemspec
11
+ gemspec
12
+
data/Gemfile.lock ADDED
@@ -0,0 +1,55 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ deribit (1.3.0)
5
+ websocket-client-simple (~> 0.3.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.5.2)
11
+ public_suffix (>= 2.0.2, < 4.0)
12
+ crack (0.4.3)
13
+ safe_yaml (~> 1.0.0)
14
+ diff-lcs (1.3)
15
+ event_emitter (0.2.6)
16
+ hashdiff (0.3.7)
17
+ public_suffix (3.0.3)
18
+ rake (10.5.0)
19
+ rspec (3.8.0)
20
+ rspec-core (~> 3.8.0)
21
+ rspec-expectations (~> 3.8.0)
22
+ rspec-mocks (~> 3.8.0)
23
+ rspec-core (3.8.0)
24
+ rspec-support (~> 3.8.0)
25
+ rspec-expectations (3.8.2)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.8.0)
28
+ rspec-mocks (3.8.0)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.8.0)
31
+ rspec-support (3.8.0)
32
+ safe_yaml (1.0.4)
33
+ vcr (4.0.0)
34
+ webmock (3.4.2)
35
+ addressable (>= 2.3.6)
36
+ crack (>= 0.3.2)
37
+ hashdiff
38
+ websocket (1.2.8)
39
+ websocket-client-simple (0.3.0)
40
+ event_emitter
41
+ websocket
42
+
43
+ PLATFORMS
44
+ ruby
45
+
46
+ DEPENDENCIES
47
+ bundler (~> 1.16)
48
+ deribit!
49
+ rake (~> 10.0)
50
+ rspec (~> 3.0)
51
+ vcr
52
+ webmock
53
+
54
+ BUNDLED WITH
55
+ 1.17.2
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2010-2019 Google, Inc. http://angularjs.org
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,261 @@
1
+ # Deribit
2
+
3
+ # API Client for v1 [Deribit API](https://www.deribit.com/docs/api/)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'deribit'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install deribit
20
+
21
+ ## Usage
22
+
23
+
24
+ ### Example
25
+
26
+ ```
27
+ require 'deribit'
28
+
29
+ api = Deribit::API.new("KEY", "SECRET")
30
+
31
+ api.index
32
+ api.account_info
33
+ ```
34
+
35
+ ENV['DOMAIN'] is changing the default domain https://deribit.com/
36
+
37
+ ```
38
+ DOMAIN=https://test.deribit.com/ bin/console
39
+ ```
40
+
41
+ ## API
42
+
43
+ `Deribit::API.new(key, secret)`
44
+
45
+ Constructor creates new API client.
46
+
47
+ **Parameters**
48
+
49
+ | Name | Type | Decription |
50
+ |----------|----------|-----------------------------------------------------------|
51
+ | `key` | `string` | Optional, Access Key needed to access Private functions |
52
+ | `secret` | `string` | Optional, Access Secret needed to access Private functions|
53
+
54
+
55
+ ### Methods
56
+
57
+ * `getinstruments(expired: false, only_active: true)` - [Doc](https://www.deribit.com/docs/api/#getinstruments), public
58
+
59
+ Returns active instruments
60
+ **Parameters**
61
+
62
+ | Name | Type | Decription |
63
+ |--------------|------------|------------------------------------------------------------|
64
+ | `expired` | `boolean` | Optional, for returning all expired instruments. |
65
+ | `only_active`| `boolean` | Optional, returns only isActive true instruments |
66
+
67
+ * `getorderbook(instrument)` - [Doc](https://www.deribit.com/docs/api/#getinstruments), public
68
+
69
+ Retrieve the orderbook for a given instrument.
70
+
71
+ **Parameters**
72
+
73
+ | Name | Type | Decription |
74
+ |--------------|------------|------------------------------------------------------------|
75
+ | `instrument` | `string` | Required, instrument name |
76
+
77
+
78
+ * `index()` - [Doc](https://www.deribit.com/docs/api/#index), public
79
+
80
+ Get price index, BTC-USD rates.
81
+
82
+ * `getcurrencies()` - [Doc](https://www.deribit.com/docs/api/#getcurrencies), public
83
+
84
+ Get all supported currencies.
85
+
86
+ * `getlasttrades(instrument, count: count, since: since)` - [Doc](https://www.deribit.com/docs/api/#getlasttrades), public
87
+
88
+ Retrieve the latest trades that have occured for a specific instrument.
89
+
90
+ **Parameters**
91
+
92
+ | Name | Type | Decription |
93
+ |--------------|------------|-------------------------------------------------------------------------------|
94
+ | `instrument` | `string` | Required, instrument name |
95
+ | `count` | `integer` | Optional, count of trades returned (limitation: max. count is 100) |
96
+ | `since` | `integer` | Optional, “since” trade id, the server returns trades newer than that “since” |
97
+
98
+
99
+ * `getsummary(instrument)` - [Doc](https://www.deribit.com/docs/api/#getsummary), public
100
+
101
+ Retrieve the summary info such as Open Interest, 24H Volume etc for a specific instrument.
102
+
103
+ **Parameters**
104
+
105
+ | Name | Type | Decription |
106
+ |--------------|------------|------------------------------------------------------------|
107
+ | `instrument` | `string` | Required, instrument name |
108
+
109
+
110
+ * `account()` - [Doc](https://www.deribit.com/docs/api/#account), Private
111
+
112
+ Get user account summary.
113
+
114
+ * `buy(instrument, quantity, price, type: "limit", stopPx: stopPx, post_only: post_only, label: label, max_show: max_show, adv: adv)` - [Doc](https://www.deribit.com/docs/api/#buy), private
115
+
116
+ Place a buy order in an instrument.
117
+
118
+ **Parameters**
119
+
120
+ | Name | Type | Decription |
121
+ |--------------|------------|-----------------------------------------------------------------------------------|
122
+ | `instrument` | `string` | Required, instrument name |
123
+ | `quantity` | `integer` | Required, quantity, in contracts ($10 per contract for futures, ฿1 — for options) |
124
+ | `price` | `float` | Required, USD for futures, BTC for options |
125
+ | `post_only` | `boolean` | Optional, if true then the order will be POST ONLY |
126
+ | `label` | `string` | Optional, user defined maximum 32-char label for the order |
127
+ | `type` | `string` | Required, "limit", "market" or for futures only: "stop_limit" |
128
+ | `stopPx` | `string` | Required, needed for stop_limit order, defines stop price |
129
+ | `max_show` | `string` | Optional, optional parameter, if "0" then the order will be hidden |
130
+ | `adv` | `string` | Optional, can be "implv", "usd", or absent (advanced order type) |
131
+
132
+
133
+ * `sell(instrument, quantity, price, post_only: post_only, label: label, max_show: max_show, adv: adv)` - [Doc](https://www.deribit.com/docs/api/#sell), private
134
+
135
+ Place a sell order in an instrument.
136
+
137
+ **Parameters**
138
+
139
+ | Name | Type | Decription |
140
+ |--------------|------------|-----------------------------------------------------------------------------------|
141
+ | `instrument` | `string` | Required, instrument name |
142
+ | `quantity` | `integer` | Required, quantity, in contracts ($10 per contract for futures, ฿1 — for options) |
143
+ | `price` | `float` | Required, USD for futures, BTC for options |
144
+ | `post_only` | `boolean` | Optional, if true then the order will be POST ONLY |
145
+ | `label` | `string` | Optional, user defined maximum 32-char label for the order |
146
+ | `max_show` | `string` | Optional, optional parameter, if "0" then the order will be hidden |
147
+ | `adv` | `string` | Optional, can be "implv", "usd", or absent (advanced order type) |
148
+
149
+
150
+ * `edit(order_id, quantity, price, post_only: post_only, adv: adv)` - [Doc](https://www.deribit.com/docs/api/#edit)
151
+
152
+ Edit price and/or quantity of the own order. (Authorization is required).
153
+
154
+ **Parameters**
155
+
156
+ | Name | Type | Decription |
157
+ |--------------|------------|-----------------------------------------------------------------------------------|
158
+ | `order_id` | `integer` | Required, ID of the order returned by "sell" or "buy" request |
159
+ | `quantity` | `integer` | Required, quantity, in contracts ($10 per contract for futures, ฿1 — for options) |
160
+ | `price` | `float` | Required, USD for futures, BTC for options |
161
+ | `post_only` | `boolean` | Optional, if true then the order will be POST ONLY |
162
+ | `adv` | `string` | Optional, can be "implv", "usd", or absent (advanced order type) |
163
+
164
+ `cancel(order_id)` - [Doc](https://www.deribit.com/docs/api/#cancel), private
165
+
166
+ Cancell own order by id.
167
+
168
+ **Parameters**
169
+
170
+ | Name | Type | Decription |
171
+ |--------------|------------|-----------------------------------------------------------------------------------|
172
+ | `order_id` | `integer` | Required, ID of the order returned by "sell" or "buy" request
173
+
174
+ * `getopenorders(instrument)` - [Doc](https://www.deribit.com/docs/api/#getopenorders), private
175
+
176
+ Retrieve open orders.
177
+
178
+ **Parameters**
179
+
180
+ | Name | Type | Description |
181
+ |--------------|------------|-----------------------------------------------------------------------|
182
+ | `instrument` | `string` | Optional, instrument name, use if want orders for specific instrument |
183
+
184
+ * `positions()` - [Doc](https://www.deribit.com/docs/api/#positions), private
185
+
186
+ Retreive positions.
187
+
188
+ * `orderhistory(count)` - [Doc](https://www.deribit.com/docs/api/#orderhistory), private
189
+
190
+ Get history.
191
+
192
+ **Parameters**
193
+
194
+ | Name | Type | Description |
195
+ |------------|------------|------------------------------------------------------------|
196
+ | `count` | `integer` | Optional, number of requested records |
197
+
198
+ * `tradehistory(count: count, instrument: instrument, start_trade_id: start_trade_id)` - [Doc](https://www.deribit.com/docs/api/#tradehistory), private
199
+
200
+ Get private trade history of the account. (Authorization is required). The result is ordered by trade identifiers (trade id-s).
201
+
202
+ **Parameters**
203
+
204
+ | Name | Type | Description |
205
+ |------------------|------------|----------------------------------------------------------------------------------------------------|
206
+ | `count` | `integer` | Optional, number of results to fetch. Default: 20 |
207
+ | `instrument` | `string` | Optional, name of instrument, also aliases “all”, “futures”, “options” are allowed. Default: "all" |
208
+ | `start_trade_id` | `integer` | Optional, number of requested records |
209
+
210
+
211
+ ## Websocket API
212
+
213
+ ```
214
+ require 'deribit'
215
+
216
+ ws = Deribit::WS.new("KEY", "SECRET")
217
+
218
+ ws.account
219
+
220
+ #subscribe
221
+ ws.subscribe(['BTC-30NOV18-6500-P'], events: [:order_book])
222
+ ```
223
+
224
+ ### Handler
225
+
226
+ Create inheritance class for handling WS notifications
227
+
228
+ ```
229
+ class MyHandler < Deribit::WS::Handler
230
+ #event handler
231
+ def order_book_event(json)
232
+ #you actions here
233
+
234
+ #json example for order_book_event
235
+ #{"state"=>"open", "settlementPrice"=>0.2105, "instrument"=>"BTC-30NOV18-6500-P", "bids"=>[{"quantity"=>10.0, "amount"=>10.0, "price"=>0.2785, "cm"=>10.0, "cm_amount"=>10.0}, {"quantity"=>1.0, "amount"=>1.0, "price"=>0.05, "cm"=>11.0, "cm_amount"=>11.0}], "asks"=>[{"quantity"=>9.0, "amount"=>9.0, "price"=>0.2935, "cm"=>9.0, "cm_amount"=>9.0}], "tstamp"=>1542650516519, "last"=>0.285, "low"=>0.285, "high"=>0.285, "mark"=>0.286, "uPx"=>5060.54, "uIx"=>"index_price", "iR"=>0, "markIv"=>106.0, "askIv"=>110.45, "bidIv"=>0.0, "delta"=>-0.90264, "gamma"=>0.00019, "vega"=>1.48288, "theta"=>-7.42706}
236
+ end
237
+
238
+ #action handler
239
+ def getinstruments(json)
240
+ #you actions here
241
+ end
242
+ end
243
+ ```
244
+
245
+ Available events you can check in the guide https://deribit.com/main#/pages/docs/api WebSockets API section.
246
+
247
+
248
+
249
+ ## Development
250
+
251
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
252
+
253
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
254
+
255
+ ## Contributing
256
+
257
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sunchess/deribit. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
258
+
259
+ ## Code of Conduct
260
+
261
+ Everyone interacting in the Deribit project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/deribit/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "deribit"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/deribit.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "deribit/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "deribit"
7
+ spec.version = Deribit::VERSION
8
+ spec.authors = ["Alexander Dmitriev", "Ivan Tumanov"]
9
+ spec.email = ["alexanderdmv@gmail.com"]
10
+ spec.licenses = ['MIT']
11
+
12
+ spec.summary = %q{Deribit.com v1 API ruby adapter}
13
+ spec.description = %q{This gem allows you to use deribit.com exchange}
14
+ spec.homepage = "https://github.com/vizakenjack/deribit-ruby"
15
+
16
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
17
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ end
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.16"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "~> 3.0"
24
+
25
+ spec.add_dependency 'websocket-client-simple', '~> 0.3.0'
26
+ end