deribit-api 2.0.1 → 2.0.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 +4 -4
- data/.ruby-version +1 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +14 -9
- data/TODOs.org +4 -3
- data/lib/deribit/client.rb +12 -10
- data/lib/deribit/naming.rb +25 -29
- data/lib/deribit/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9190274b8e9a8685d94a7795e36e5d02824acdfe97417923dcf12e0c2685caf2
|
|
4
|
+
data.tar.gz: a7dcd9a94ce0f80627f100b27f79e6f03cd0e4d07655c16837f3c444c6d516dc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cbb94007ede87a6c332ff98e0628084598a0c9ae06aa23482ab8a49ac309e2c87fce4f82b664bf390765d6bb0fc62be90f1fec0ae51ff59111be3674c6dcb089
|
|
7
|
+
data.tar.gz: 375beeb4e635832e442074b6f97a79d1abb7af72cfb81be16b5fb699039ae9df5c2d0a4768772f3975bbb298d7de7bf042772428949899daa127930116e56502
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.7.1
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.0.2] - 2020-06-10
|
|
9
|
+
### Changed
|
|
10
|
+
- update all gems
|
|
11
|
+
- update Ruby to 2.7.1
|
|
12
|
+
- refactor Naming module
|
|
13
|
+
|
|
8
14
|
## [2.0.1] - 2020-05-13
|
|
9
15
|
### Added
|
|
10
16
|
- client#orders supports filtering by both currency and instrument name
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
deribit-api (2.0.
|
|
4
|
+
deribit-api (2.0.2)
|
|
5
5
|
faraday
|
|
6
6
|
faraday-detailed_logger
|
|
7
7
|
faraday_middleware
|
|
@@ -15,7 +15,7 @@ GEM
|
|
|
15
15
|
backport (1.1.2)
|
|
16
16
|
benchmark (0.1.0)
|
|
17
17
|
bump (0.9.0)
|
|
18
|
-
coderay (1.1.
|
|
18
|
+
coderay (1.1.3)
|
|
19
19
|
docile (1.3.2)
|
|
20
20
|
dotenv (2.7.5)
|
|
21
21
|
e2mmap (0.1.0)
|
|
@@ -35,12 +35,12 @@ GEM
|
|
|
35
35
|
maruku (0.7.3)
|
|
36
36
|
method_source (1.0.0)
|
|
37
37
|
mini_portile2 (2.4.0)
|
|
38
|
-
minitest (5.14.
|
|
38
|
+
minitest (5.14.1)
|
|
39
39
|
multipart-post (2.1.1)
|
|
40
40
|
nokogiri (1.10.9)
|
|
41
41
|
mini_portile2 (~> 2.4.0)
|
|
42
42
|
parallel (1.19.1)
|
|
43
|
-
parser (2.7.1.
|
|
43
|
+
parser (2.7.1.3)
|
|
44
44
|
ast (~> 2.4.0)
|
|
45
45
|
pry (0.13.1)
|
|
46
46
|
coderay (~> 1.1)
|
|
@@ -51,29 +51,34 @@ GEM
|
|
|
51
51
|
psych (3.1.0)
|
|
52
52
|
rainbow (3.0.0)
|
|
53
53
|
rake (13.0.1)
|
|
54
|
-
reek (6.0.
|
|
54
|
+
reek (6.0.1)
|
|
55
55
|
kwalify (~> 0.7.0)
|
|
56
56
|
parser (>= 2.5.0.0, < 2.8, != 2.5.1.1)
|
|
57
57
|
psych (~> 3.1.0)
|
|
58
58
|
rainbow (>= 2.0, < 4.0)
|
|
59
|
+
regexp_parser (1.7.1)
|
|
59
60
|
reline (0.1.4)
|
|
60
61
|
io-console (~> 0.5)
|
|
61
|
-
reverse_markdown (
|
|
62
|
+
reverse_markdown (2.0.0)
|
|
62
63
|
nokogiri
|
|
63
64
|
rexml (3.2.4)
|
|
64
|
-
rubocop (0.
|
|
65
|
+
rubocop (0.85.1)
|
|
65
66
|
parallel (~> 1.10)
|
|
66
67
|
parser (>= 2.7.0.1)
|
|
67
68
|
rainbow (>= 2.2.2, < 4.0)
|
|
69
|
+
regexp_parser (>= 1.7)
|
|
68
70
|
rexml
|
|
71
|
+
rubocop-ast (>= 0.0.3)
|
|
69
72
|
ruby-progressbar (~> 1.7)
|
|
70
73
|
unicode-display_width (>= 1.4.0, < 2.0)
|
|
74
|
+
rubocop-ast (0.0.3)
|
|
75
|
+
parser (>= 2.7.0.1)
|
|
71
76
|
ruby-progressbar (1.10.1)
|
|
72
77
|
simplecov (0.18.5)
|
|
73
78
|
docile (~> 1.1)
|
|
74
79
|
simplecov-html (~> 0.11)
|
|
75
80
|
simplecov-html (0.12.2)
|
|
76
|
-
solargraph (0.39.
|
|
81
|
+
solargraph (0.39.8)
|
|
77
82
|
backport (~> 1.1)
|
|
78
83
|
benchmark
|
|
79
84
|
bundler (>= 1.17.2)
|
|
@@ -82,7 +87,7 @@ GEM
|
|
|
82
87
|
maruku (~> 0.7, >= 0.7.3)
|
|
83
88
|
nokogiri (~> 1.9, >= 1.9.1)
|
|
84
89
|
parser (~> 2.3)
|
|
85
|
-
reverse_markdown (
|
|
90
|
+
reverse_markdown (>= 1.0.5, < 3)
|
|
86
91
|
rubocop (~> 0.52)
|
|
87
92
|
thor (~> 1.0)
|
|
88
93
|
tilt (~> 2.0)
|
data/TODOs.org
CHANGED
|
@@ -37,12 +37,13 @@
|
|
|
37
37
|
** cleanup 'params' for both http and websocket
|
|
38
38
|
** DONE update buy/sell endpoints with new params
|
|
39
39
|
** DONE initial 2.0 API implementaion
|
|
40
|
-
** refactor Naming module
|
|
40
|
+
** DONE refactor Naming module
|
|
41
41
|
** TODO deribit-api-ruby maintenance
|
|
42
|
-
SCHEDULED: <2020-
|
|
42
|
+
SCHEDULED: <2020-12-09 Wed +6m>
|
|
43
43
|
:PROPERTIES:
|
|
44
|
-
:LAST_REPEAT: [2020-
|
|
44
|
+
:LAST_REPEAT: [2020-06-10 Wed 07:36]
|
|
45
45
|
:END:
|
|
46
|
+
- State "DONE" from "TODO" [2020-06-10 Wed 07:36]
|
|
46
47
|
- State "DONE" from "TODO" [2020-05-13 Wed 14:14]
|
|
47
48
|
- State "DONE" from "TODO" [2020-04-23 Thu 13:25]
|
|
48
49
|
- State "DONE" from "TODO" [2020-01-09 Thu 18:00]
|
data/lib/deribit/client.rb
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
require 'deribit/naming'
|
|
2
3
|
|
|
3
4
|
module Deribit
|
|
4
|
-
TESTNET_HOST = 'test.deribit.com'
|
|
5
|
-
MAINNET_HOST = 'www.deribit.com'
|
|
5
|
+
TESTNET_HOST = 'test.deribit.com'
|
|
6
|
+
MAINNET_HOST = 'www.deribit.com'
|
|
6
7
|
|
|
7
8
|
# Deribit API 2.0 client implementation
|
|
8
9
|
# @author Iulian Costan (deribit-api@iuliancostan.com)
|
|
9
10
|
class Client
|
|
11
|
+
include Naming
|
|
10
12
|
attr_reader :http, :websocket
|
|
11
13
|
|
|
12
14
|
# Create new instance
|
|
@@ -71,7 +73,7 @@ module Deribit
|
|
|
71
73
|
end
|
|
72
74
|
|
|
73
75
|
if block_given?
|
|
74
|
-
channel =
|
|
76
|
+
channel = book_channel options
|
|
75
77
|
websocket.subscribe channel, params: {}, &blk
|
|
76
78
|
else
|
|
77
79
|
http.get '/public/get_order_book', options
|
|
@@ -116,10 +118,10 @@ module Deribit
|
|
|
116
118
|
end
|
|
117
119
|
|
|
118
120
|
if block_given?
|
|
119
|
-
channel =
|
|
121
|
+
channel = trades_channel filters
|
|
120
122
|
websocket.subscribe channel, params: {}, &blk
|
|
121
123
|
else
|
|
122
|
-
uri =
|
|
124
|
+
uri = trades_uri filters
|
|
123
125
|
response = http.get uri, filters
|
|
124
126
|
response.trades
|
|
125
127
|
end
|
|
@@ -261,7 +263,7 @@ module Deribit
|
|
|
261
263
|
# @see https://docs.deribit.com/#private-cancel_all_by_currency
|
|
262
264
|
# @see https://docs.deribit.com/#private-cancel_all_by_instrument
|
|
263
265
|
def cancel_all(options = {})
|
|
264
|
-
uri =
|
|
266
|
+
uri = cancel_uri options
|
|
265
267
|
http.get uri, options
|
|
266
268
|
end
|
|
267
269
|
|
|
@@ -274,7 +276,7 @@ module Deribit
|
|
|
274
276
|
raise 'block is missing, HTTP-RPC not supported for this endpoint'
|
|
275
277
|
end
|
|
276
278
|
|
|
277
|
-
channel =
|
|
279
|
+
channel = channel_for_instrument 'quote', options
|
|
278
280
|
websocket.subscribe channel, params: options, &blk
|
|
279
281
|
end
|
|
280
282
|
|
|
@@ -285,7 +287,7 @@ module Deribit
|
|
|
285
287
|
# @see https://docs.deribit.com/#ticker-instrument_name-interval
|
|
286
288
|
def ticker(options = { instrument_name: 'BTC-PERPETUAL' }, &blk)
|
|
287
289
|
if block_given?
|
|
288
|
-
channel =
|
|
290
|
+
channel = channel 'ticker', options
|
|
289
291
|
websocket.subscribe channel, params: options, &blk
|
|
290
292
|
else
|
|
291
293
|
http.get '/public/ticker', options
|
|
@@ -307,10 +309,10 @@ module Deribit
|
|
|
307
309
|
raise ArgumentError, 'either :instrument_name or :currency is required' unless options[:instrument_name] || options[:currency]
|
|
308
310
|
|
|
309
311
|
if block_given?
|
|
310
|
-
channel =
|
|
312
|
+
channel = channel 'user.orders', options
|
|
311
313
|
websocket.subscribe channel, params: options, &blk
|
|
312
314
|
else
|
|
313
|
-
uri =
|
|
315
|
+
uri = orders_uri options
|
|
314
316
|
http.get uri, options
|
|
315
317
|
end
|
|
316
318
|
end
|
data/lib/deribit/naming.rb
CHANGED
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
module Deribit
|
|
4
4
|
# @author Iulian Costan (deribit-api@iuliancostan.com)
|
|
5
|
-
# TODO: refactor and clean this up
|
|
6
5
|
module Naming
|
|
7
|
-
def
|
|
6
|
+
def trades_channel(options)
|
|
8
7
|
private = options.delete :private
|
|
9
8
|
trades = private ? 'user.trades' : 'trades'
|
|
10
9
|
channel trades, options
|
|
11
10
|
end
|
|
12
11
|
|
|
13
|
-
def
|
|
12
|
+
def trades_uri(options)
|
|
14
13
|
private = options.delete :private
|
|
15
14
|
uri = private ? 'private/get_user_trades' : 'public/get_last_trades'
|
|
16
15
|
uri += by_instrument(options) + by_currency(options)
|
|
@@ -18,50 +17,61 @@ module Deribit
|
|
|
18
17
|
uri
|
|
19
18
|
end
|
|
20
19
|
|
|
21
|
-
def
|
|
20
|
+
def book_channel(options)
|
|
22
21
|
'book' + for_instrument(options) + with_group_and_depth(options) + with_interval(options)
|
|
23
22
|
end
|
|
24
23
|
|
|
25
|
-
def
|
|
26
|
-
|
|
24
|
+
def channel(prefix, options)
|
|
25
|
+
channel = prefix
|
|
26
|
+
channel += for_instrument(options) if options[:instrument_name]
|
|
27
|
+
channel += for_currency(options) if options[:currency]
|
|
28
|
+
channel += with_interval(options)
|
|
29
|
+
channel
|
|
27
30
|
end
|
|
28
31
|
|
|
29
|
-
def
|
|
32
|
+
def channel_for_instrument(prefix, options)
|
|
30
33
|
prefix + for_instrument(options)
|
|
31
34
|
end
|
|
32
35
|
|
|
33
|
-
def
|
|
36
|
+
def instrument_with_interval(prefix, options)
|
|
34
37
|
prefix + for_instrument(options) + with_interval(options)
|
|
35
38
|
end
|
|
36
39
|
|
|
37
|
-
def
|
|
40
|
+
def cancel_uri(options)
|
|
38
41
|
'/private/cancel_all' + by_instrument(options) + by_currency(options)
|
|
39
42
|
end
|
|
40
43
|
|
|
41
|
-
def
|
|
44
|
+
def orders_uri(options)
|
|
42
45
|
'/private/get_open_orders' + by_instrument(options) + by_currency(options)
|
|
43
46
|
end
|
|
44
47
|
|
|
45
|
-
def
|
|
48
|
+
def by_instrument(options)
|
|
46
49
|
options[:instrument_name] ? '_by_instrument' : ''
|
|
47
50
|
end
|
|
48
51
|
|
|
49
|
-
def
|
|
52
|
+
def by_currency(options)
|
|
50
53
|
options[:currency] ? '_by_currency' : ''
|
|
51
54
|
end
|
|
52
55
|
|
|
53
|
-
def
|
|
56
|
+
def for_instrument(options)
|
|
54
57
|
raise 'instrument_name param is required' unless options[:instrument_name]
|
|
55
58
|
|
|
56
59
|
".#{options[:instrument_name]}"
|
|
57
60
|
end
|
|
58
61
|
|
|
59
|
-
def
|
|
62
|
+
def for_currency(options)
|
|
63
|
+
raise 'currency param is required' unless options[:currency]
|
|
64
|
+
|
|
65
|
+
kind = options[:kind] || 'any'
|
|
66
|
+
".#{kind}.#{options[:currency]}"
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def with_interval(options)
|
|
60
70
|
interval = options[:interval] || '100ms'
|
|
61
71
|
".#{interval}"
|
|
62
72
|
end
|
|
63
73
|
|
|
64
|
-
def
|
|
74
|
+
def with_group_and_depth(options)
|
|
65
75
|
if options[:group] || options[:depth]
|
|
66
76
|
group = options[:group] || '5'
|
|
67
77
|
depth = options[:depth] || '10'
|
|
@@ -70,19 +80,5 @@ module Deribit
|
|
|
70
80
|
''
|
|
71
81
|
end
|
|
72
82
|
end
|
|
73
|
-
|
|
74
|
-
def self.channel_suffix(options)
|
|
75
|
-
currency = options[:currency]
|
|
76
|
-
instrument_name = options[:instrument_name]
|
|
77
|
-
kind = options[:kind] || 'any'
|
|
78
|
-
interval = options[:interval] || 'raw'
|
|
79
|
-
if instrument_name
|
|
80
|
-
".#{instrument_name}.#{interval}"
|
|
81
|
-
elsif currency
|
|
82
|
-
".#{kind}.#{currency}.#{interval}"
|
|
83
|
-
else
|
|
84
|
-
raise 'invalid args'
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
83
|
end
|
|
88
84
|
end
|
data/lib/deribit/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: deribit-api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Iulian Costan
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-06-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -256,6 +256,7 @@ extensions: []
|
|
|
256
256
|
extra_rdoc_files: []
|
|
257
257
|
files:
|
|
258
258
|
- ".gitignore"
|
|
259
|
+
- ".ruby-version"
|
|
259
260
|
- ".travis.yml"
|
|
260
261
|
- CHANGELOG.md
|
|
261
262
|
- CODE_OF_CONDUCT.md
|
|
@@ -287,7 +288,7 @@ metadata:
|
|
|
287
288
|
homepage_uri: https://github.com/icostan/deribit-api-ruby
|
|
288
289
|
source_code_uri: https://github.com/icostan/deribit-api-ruby.git
|
|
289
290
|
changelog_uri: https://github.com/icostan/deribit-api-ruby/blob/master/CHANGELOG.md
|
|
290
|
-
post_install_message:
|
|
291
|
+
post_install_message:
|
|
291
292
|
rdoc_options: []
|
|
292
293
|
require_paths:
|
|
293
294
|
- lib
|
|
@@ -303,7 +304,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
303
304
|
version: '0'
|
|
304
305
|
requirements: []
|
|
305
306
|
rubygems_version: 3.1.2
|
|
306
|
-
signing_key:
|
|
307
|
+
signing_key:
|
|
307
308
|
specification_version: 4
|
|
308
309
|
summary: Idiomatic Ruby library for Deribit API 2.0
|
|
309
310
|
test_files: []
|