deribit-api 2.0.0 → 2.0.1
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/CHANGELOG.md +9 -0
- data/Gemfile.lock +8 -9
- data/README.md +3 -3
- data/TODOs.org +8 -5
- data/lib/deribit/authentication.rb +2 -1
- data/lib/deribit/client.rb +22 -30
- data/lib/deribit/http.rb +3 -3
- data/lib/deribit/naming.rb +68 -62
- data/lib/deribit/version.rb +1 -1
- data/lib/deribit/websocket.rb +10 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11f76e8a99154e3e620008c524704c74cf01c0cf3303352ed22981f403cd0912
|
4
|
+
data.tar.gz: 149ef6954294ee435ce56097b4e79fbdcd162df1f05b3efa3a698e87c5094c47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c373baa7adac07baeb5b820cadbebb83b72d7c15d962e17b4b83d736df9cfcb03235379400858a6f3aeae118c40648010f2d5a03396b793614c0aa1e8a9c6e23
|
7
|
+
data.tar.gz: c981a53a4f1a28196f5a8fbd1bbee2448509c6d9e6fb74f9ffc7eda47371c76c9da8fdf8d40d16ba9546949ef688fb2bd9befe9025f3973c911f8c0bd7190cd3
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,15 @@
|
|
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.1] - 2020-05-13
|
9
|
+
### Added
|
10
|
+
- client#orders supports filtering by both currency and instrument name
|
11
|
+
- customisable *raise_error* param
|
12
|
+
### Changed
|
13
|
+
- update all gems
|
14
|
+
- rdocs for all client#* methods
|
15
|
+
- fix namespace for Naming module
|
16
|
+
|
8
17
|
## [2.0.0] - 2020-04-23
|
9
18
|
### Added
|
10
19
|
- implementation for API 2.0
|
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.1)
|
5
5
|
faraday
|
6
6
|
faraday-detailed_logger
|
7
7
|
faraday_middleware
|
@@ -28,7 +28,7 @@ GEM
|
|
28
28
|
faraday (~> 1.0)
|
29
29
|
hashie (4.1.0)
|
30
30
|
io-console (0.5.6)
|
31
|
-
irb (1.2.
|
31
|
+
irb (1.2.4)
|
32
32
|
reline (>= 0.0.1)
|
33
33
|
jaro_winkler (1.5.4)
|
34
34
|
kwalify (0.7.2)
|
@@ -40,7 +40,7 @@ GEM
|
|
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.2)
|
44
44
|
ast (~> 2.4.0)
|
45
45
|
pry (0.13.1)
|
46
46
|
coderay (~> 1.1)
|
@@ -56,13 +56,12 @@ GEM
|
|
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
|
-
reline (0.1.
|
59
|
+
reline (0.1.4)
|
60
60
|
io-console (~> 0.5)
|
61
61
|
reverse_markdown (1.4.0)
|
62
62
|
nokogiri
|
63
63
|
rexml (3.2.4)
|
64
|
-
rubocop (0.
|
65
|
-
jaro_winkler (~> 1.5.1)
|
64
|
+
rubocop (0.83.0)
|
66
65
|
parallel (~> 1.10)
|
67
66
|
parser (>= 2.7.0.1)
|
68
67
|
rainbow (>= 2.2.2, < 4.0)
|
@@ -74,7 +73,7 @@ GEM
|
|
74
73
|
docile (~> 1.1)
|
75
74
|
simplecov-html (~> 0.11)
|
76
75
|
simplecov-html (0.12.2)
|
77
|
-
solargraph (0.
|
76
|
+
solargraph (0.39.7)
|
78
77
|
backport (~> 1.1)
|
79
78
|
benchmark
|
80
79
|
bundler (>= 1.17.2)
|
@@ -87,7 +86,7 @@ GEM
|
|
87
86
|
rubocop (~> 0.52)
|
88
87
|
thor (~> 1.0)
|
89
88
|
tilt (~> 2.0)
|
90
|
-
yard (~> 0.9)
|
89
|
+
yard (~> 0.9, >= 0.9.24)
|
91
90
|
thor (1.0.1)
|
92
91
|
tilt (2.0.10)
|
93
92
|
unicode-display_width (1.7.0)
|
@@ -95,7 +94,7 @@ GEM
|
|
95
94
|
websocket-client-simple (0.3.0)
|
96
95
|
event_emitter
|
97
96
|
websocket
|
98
|
-
yard (0.9.
|
97
|
+
yard (0.9.25)
|
99
98
|
|
100
99
|
PLATFORMS
|
101
100
|
ruby
|
data/README.md
CHANGED
@@ -34,7 +34,7 @@ Or install it yourself as:
|
|
34
34
|
require 'deribit-api'
|
35
35
|
|
36
36
|
# for public data
|
37
|
-
client = Deribit::Client.new testnet: true, debug: true
|
37
|
+
client = Deribit::Client.new testnet: true, debug: true, raise_error: true
|
38
38
|
|
39
39
|
# pass KEY and SECRET to access private data
|
40
40
|
client = Deribit::Client.new key: 'KEY', secret: 'SECRET'
|
@@ -66,14 +66,14 @@ result = client.buy 'BTC-PERPETUAL', 10, price: 2500
|
|
66
66
|
=> #<Hashie::Mash order=#<Hashie::Mash amount=10 api=true average_price=0.0 commission=0.0 creation_timestamp=1587644442494 direction="buy" filled_amount=0 instrument_name="BTC-PERPETUAL" is_liquidation=false label="" last_update_timestamp=1587644442494 max_show=10 order_id="3887469320" order_state="open" order_type="limit" post_only=false price=2500.0 profit_loss=0.0 reduce_only=false replaced=false time_in_force="good_til_cancelled" web=false> trades=#<Hashie::Array []>>
|
67
67
|
```
|
68
68
|
|
69
|
-
|
69
|
+
Direct access to any HTTP API endpoints: <https://docs.deribit.com/#market-data>
|
70
70
|
|
71
71
|
```ruby
|
72
72
|
result = client.http.get '/public/ping'
|
73
73
|
=> "pong"
|
74
74
|
```
|
75
75
|
|
76
|
-
|
76
|
+
Direct access to any Websocket API channels: <https://docs.deribit.com/#subscriptions>
|
77
77
|
|
78
78
|
```ruby
|
79
79
|
client.websocket.subscribe 'user.portofolio.BTC' do |data|
|
data/TODOs.org
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
#+TODO: TODO | DONE FAIL N/A
|
1
2
|
* Tasks :DERIBIT:
|
2
3
|
:PROPERTIES:
|
3
4
|
:CATEGORY: deribit
|
@@ -28,19 +29,21 @@
|
|
28
29
|
CLOCK: [2019-04-17 Wed 17:55]--[2019-04-17 Wed 18:26] => 0:31
|
29
30
|
CLOCK: [2019-04-16 Tue 12:23]--[2019-04-16 Tue 18:16] => 5:53
|
30
31
|
:END:
|
31
|
-
** response middleware
|
32
|
+
** N/A response middleware
|
32
33
|
** check key/secret present for private endpoints
|
33
34
|
** DONE fix trade history
|
34
35
|
CLOSED: [2019-04-23 Tue 15:17]
|
35
|
-
** research async websocket implementation
|
36
|
+
** DONE research async websocket implementation
|
36
37
|
** cleanup 'params' for both http and websocket
|
37
|
-
** update buy/sell endpoints with new params
|
38
|
+
** DONE update buy/sell endpoints with new params
|
38
39
|
** DONE initial 2.0 API implementaion
|
40
|
+
** refactor Naming module
|
39
41
|
** TODO deribit-api-ruby maintenance
|
40
|
-
SCHEDULED: <2020-
|
42
|
+
SCHEDULED: <2020-06-09 Tue +3m>
|
41
43
|
:PROPERTIES:
|
42
|
-
:LAST_REPEAT: [2020-
|
44
|
+
:LAST_REPEAT: [2020-05-13 Wed 14:14]
|
43
45
|
:END:
|
46
|
+
- State "DONE" from "TODO" [2020-05-13 Wed 14:14]
|
44
47
|
- State "DONE" from "TODO" [2020-04-23 Thu 13:25]
|
45
48
|
- State "DONE" from "TODO" [2020-01-09 Thu 18:00]
|
46
49
|
- State "DONE" from "TODO" [2019-10-21 Mon 14:43]
|
@@ -3,6 +3,7 @@ require 'digest'
|
|
3
3
|
|
4
4
|
module Deribit
|
5
5
|
# Deribit authentication implemented as Faraday middleware
|
6
|
+
# @author Iulian Costan (deribit-api@iuliancostan.com)
|
6
7
|
# @see https://docs.deribit.com/#authentication
|
7
8
|
class Authentication < Faraday::Middleware
|
8
9
|
def initialize(app, key, secret)
|
@@ -22,7 +23,7 @@ module Deribit
|
|
22
23
|
@app.call env
|
23
24
|
end
|
24
25
|
|
25
|
-
# Authorization: deri-hmac-sha256 id=ClientId,ts=Timestamp,sig=Signature,nonce=Nonce
|
26
|
+
# @return the HTTP header: "Authorization: deri-hmac-sha256 id=ClientId,ts=Timestamp,sig=Signature,nonce=Nonce"
|
26
27
|
def header(env, timestamp, nonce)
|
27
28
|
signature = Deribit.http_signature env, timestamp, nonce, @secret
|
28
29
|
"deri-hmac-sha256 id=#{@key},ts=#{timestamp},sig=#{signature},nonce=#{nonce}"
|
data/lib/deribit/client.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Deribit
|
4
|
-
TESTNET_HOST = 'test.deribit.com'
|
5
|
-
MAINNET_HOST = 'www.deribit.com'
|
4
|
+
TESTNET_HOST = 'test.deribit.com'.freeze
|
5
|
+
MAINNET_HOST = 'www.deribit.com'.freeze
|
6
6
|
|
7
|
+
# Deribit API 2.0 client implementation
|
7
8
|
# @author Iulian Costan (deribit-api@iuliancostan.com)
|
8
9
|
class Client
|
9
10
|
attr_reader :http, :websocket
|
@@ -35,7 +36,7 @@ module Deribit
|
|
35
36
|
|
36
37
|
# Retrieves all cryptocurrencies supported by the API.
|
37
38
|
# @return [Array] the list of cryptocurrencies
|
38
|
-
# @see https://docs.deribit.com
|
39
|
+
# @see https://docs.deribit.com/#public-get_currencies
|
39
40
|
def currencies
|
40
41
|
http.get '/public/get_currencies'
|
41
42
|
end
|
@@ -44,7 +45,7 @@ module Deribit
|
|
44
45
|
# @param options [Hash]
|
45
46
|
# @option options [String] :currency the currency to get instruments for
|
46
47
|
# @return [Hashie::Mash] index price for BTC-USD instrument
|
47
|
-
# @see https://docs.deribit.com
|
48
|
+
# @see https://docs.deribit.com/#public-get_index
|
48
49
|
def index(options = { currency: 'BTC' })
|
49
50
|
unless options[:currency]
|
50
51
|
raise ArgumentError, 'currency argument is required'
|
@@ -167,7 +168,7 @@ module Deribit
|
|
167
168
|
# @param ext [Boolean] Requests additional fields
|
168
169
|
# @return [Hashie::Mash] the account details
|
169
170
|
# @yield [Hashie::Mash] the account details
|
170
|
-
# @see https://docs.deribit.com
|
171
|
+
# @see https://docs.deribit.com/#private-get_account_summary
|
171
172
|
def account(currency: 'BTC', ext: false)
|
172
173
|
if block_given?
|
173
174
|
raise Deribit::NotImplementedError, 'not implemented'
|
@@ -179,7 +180,7 @@ module Deribit
|
|
179
180
|
# Places a buy order for an instrument.
|
180
181
|
# @param instrument_name [String] Name of the instrument to buy
|
181
182
|
# @param amount [Integer] The number of contracts to buy
|
182
|
-
# @!macro deribit.
|
183
|
+
# @!macro deribit.buy_sell_options
|
183
184
|
# @param options [Hash] more options for the order
|
184
185
|
# @option options [String] :type (limit) The order type, possible types: "limit", "stop_limit", "market", "stop_market"
|
185
186
|
# @option options [String] :label user defined label for the order (maximum 32 characters)
|
@@ -203,7 +204,7 @@ module Deribit
|
|
203
204
|
# Places a sell order for an instrument.
|
204
205
|
# @param instrument_name [String] Name of the instrument to sell
|
205
206
|
# @param amount [Integer] The number of contracts to buy
|
206
|
-
# @!macro deribit.
|
207
|
+
# @!macro deribit.buy_sell_options
|
207
208
|
# @return [Hashie::Mash] the details of new order
|
208
209
|
# @see https://docs.deribit.com/#private-sell
|
209
210
|
def sell(instrument_name, amount, options = {})
|
@@ -267,7 +268,7 @@ module Deribit
|
|
267
268
|
# Best bid/ask price and size.
|
268
269
|
# @param options [Hash]
|
269
270
|
# @option options [String] :instrument_name (BTC-PERPETUAL) Instrument to return open orders for
|
270
|
-
# @see https://docs.deribit.com
|
271
|
+
# @see https://docs.deribit.com/#quote-instrument_name
|
271
272
|
def quote(options = { instrument_name: 'BTC-PERPETUAL' }, &blk)
|
272
273
|
unless block_given?
|
273
274
|
raise 'block is missing, HTTP-RPC not supported for this endpoint'
|
@@ -281,7 +282,7 @@ module Deribit
|
|
281
282
|
# @param options [Hash]
|
282
283
|
# @option options [String] :instrument_name (BTC-PERPETUAL) Instrument to return open orders for
|
283
284
|
# @option options [String] :interval (raw) Frequency of notifications: raw, 100ms
|
284
|
-
# @see https://docs.deribit.com
|
285
|
+
# @see https://docs.deribit.com/#ticker-instrument_name-interval
|
285
286
|
def ticker(options = { instrument_name: 'BTC-PERPETUAL' }, &blk)
|
286
287
|
if block_given?
|
287
288
|
channel = Naming.channel 'ticker', options
|
@@ -293,19 +294,24 @@ module Deribit
|
|
293
294
|
|
294
295
|
# Retrieves open orders.
|
295
296
|
# @param options [Hash]
|
296
|
-
# @option options [String] :instrument_name
|
297
|
-
# @option options [
|
298
|
-
# @option options [
|
297
|
+
# @option options [String] :instrument_name Instrument to return open orders for
|
298
|
+
# @option options [String] :currency The currency symbol, BTC, ETH, any
|
299
|
+
# @option options [string] :kind (any) Instrument kind, future, option or any
|
300
|
+
# @option options [string] :type (all) Order type: all, limit, stop_all, stop_limit, stop_market
|
299
301
|
# @option options [String] :interval (raw) Frequency of notifications: raw, 100ms
|
300
302
|
# @return [Array] the list of open orders
|
301
303
|
# @yield [Hashie::Mash] the order
|
302
|
-
# @see https://docs.deribit.com
|
303
|
-
|
304
|
+
# @see https://docs.deribit.com/#private-get_open_orders_by_currency
|
305
|
+
# @see https://docs.deribit.com/#private-get_open_orders_by_instrument
|
306
|
+
def orders(options, &blk)
|
307
|
+
raise ArgumentError, 'either :instrument_name or :currency is required' unless options[:instrument_name] || options[:currency]
|
308
|
+
|
304
309
|
if block_given?
|
305
310
|
channel = Naming.channel 'user.orders', options
|
306
311
|
websocket.subscribe channel, params: options, &blk
|
307
312
|
else
|
308
|
-
|
313
|
+
uri = Naming.orders_uri options
|
314
|
+
http.get uri, options
|
309
315
|
end
|
310
316
|
end
|
311
317
|
|
@@ -314,23 +320,9 @@ module Deribit
|
|
314
320
|
# @option options [String] :currency (any) The currency symbol, BTC, ETH
|
315
321
|
# @option options [string] :kind (any) Instrument kind, future, option
|
316
322
|
# @return [Array] the list of positions
|
317
|
-
# @see https://docs.deribit.com
|
323
|
+
# @see https://docs.deribit.com/#private-get_positions
|
318
324
|
def positions(options = { currency: 'BTC' })
|
319
325
|
http.get '/private/get_positions', options
|
320
326
|
end
|
321
|
-
|
322
|
-
# Retrieve order details state by order id.
|
323
|
-
# @param order_id [String] the ID of the order to be retrieved
|
324
|
-
# @return [Hashie::Mash] the details of the order
|
325
|
-
# @yield [Hashie::Mash] the details of the order
|
326
|
-
# see https://docs.deribit.com/rpc-endpoints.html#orderstate
|
327
|
-
# def order(order_id, &blk)
|
328
|
-
# params = { orderId: order_id, auth: true }
|
329
|
-
# if block_given?
|
330
|
-
# websocket.subscribe :orderstate, params: params, &blk
|
331
|
-
# else
|
332
|
-
# http.get :orderstate, auth: true, params: params
|
333
|
-
# end
|
334
|
-
# end
|
335
327
|
end
|
336
328
|
end
|
data/lib/deribit/http.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
module Deribit
|
2
|
-
# HTTP API
|
2
|
+
# HTTP API adapter
|
3
3
|
# @author Iulian Costan (deribit-api@iuliancostan.com)
|
4
4
|
# @see https://docs.deribit.com/api-http.html
|
5
5
|
class Http
|
6
|
-
def initialize(host, key: nil, secret: nil, debug: false)
|
6
|
+
def initialize(host, key: nil, secret: nil, debug: false, raise_error: true)
|
7
7
|
@connection = Faraday::Connection.new(url: http_url(host)) do |f|
|
8
8
|
f.request :json
|
9
9
|
f.use Deribit::Authentication, key, secret
|
10
10
|
f.response :mashify
|
11
11
|
f.response :json
|
12
|
-
f.use Faraday::Response::RaiseError
|
12
|
+
f.use Faraday::Response::RaiseError if raise_error
|
13
13
|
f.response :detailed_logger if debug
|
14
14
|
f.adapter Faraday.default_adapter
|
15
15
|
end
|
data/lib/deribit/naming.rb
CHANGED
@@ -1,82 +1,88 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
module Deribit
|
4
|
+
# @author Iulian Costan (deribit-api@iuliancostan.com)
|
5
|
+
# TODO: refactor and clean this up
|
6
|
+
module Naming
|
7
|
+
def self.trades_channel(options)
|
8
|
+
private = options.delete :private
|
9
|
+
trades = private ? 'user.trades' : 'trades'
|
10
|
+
channel trades, options
|
11
|
+
end
|
9
12
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
def self.trades_uri(options)
|
14
|
+
private = options.delete :private
|
15
|
+
uri = private ? 'private/get_user_trades' : 'public/get_last_trades'
|
16
|
+
uri += by_instrument(options) + by_currency(options)
|
17
|
+
uri += options[:end_timestamp] ? '_and_time' : ''
|
18
|
+
uri
|
19
|
+
end
|
17
20
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
+
def self.book_channel(options)
|
22
|
+
'book' + for_instrument(options) + with_group_and_depth(options) + with_interval(options)
|
23
|
+
end
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
+
def self.channel(prefix, options)
|
26
|
+
prefix + channel_suffix(options)
|
27
|
+
end
|
25
28
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
+
def self.channel_for_instrument(prefix, options)
|
30
|
+
prefix + for_instrument(options)
|
31
|
+
end
|
29
32
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
+
def self.instrument_with_interval(prefix, options)
|
34
|
+
prefix + for_instrument(options) + with_interval(options)
|
35
|
+
end
|
33
36
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
+
def self.cancel_uri(options)
|
38
|
+
'/private/cancel_all' + by_instrument(options) + by_currency(options)
|
39
|
+
end
|
37
40
|
|
38
|
-
|
41
|
+
def self.orders_uri(options)
|
42
|
+
'/private/get_open_orders' + by_instrument(options) + by_currency(options)
|
43
|
+
end
|
39
44
|
|
40
|
-
|
41
|
-
|
42
|
-
|
45
|
+
def self.by_instrument(options)
|
46
|
+
options[:instrument_name] ? '_by_instrument' : ''
|
47
|
+
end
|
43
48
|
|
44
|
-
|
45
|
-
|
46
|
-
|
49
|
+
def self.by_currency(options)
|
50
|
+
options[:currency] ? '_by_currency' : ''
|
51
|
+
end
|
47
52
|
|
48
|
-
|
49
|
-
|
53
|
+
def self.for_instrument(options)
|
54
|
+
raise 'instrument_name param is required' unless options[:instrument_name]
|
50
55
|
|
51
|
-
|
52
|
-
|
56
|
+
".#{options[:instrument_name]}"
|
57
|
+
end
|
53
58
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
59
|
+
def self.with_interval(options)
|
60
|
+
interval = options[:interval] || '100ms'
|
61
|
+
".#{interval}"
|
62
|
+
end
|
58
63
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
64
|
+
def self.with_group_and_depth(options)
|
65
|
+
if options[:group] || options[:depth]
|
66
|
+
group = options[:group] || '5'
|
67
|
+
depth = options[:depth] || '10'
|
68
|
+
".#{group}.#{depth}"
|
69
|
+
else
|
70
|
+
''
|
71
|
+
end
|
66
72
|
end
|
67
|
-
end
|
68
73
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
80
86
|
end
|
81
87
|
end
|
82
88
|
end
|
data/lib/deribit/version.rb
CHANGED
data/lib/deribit/websocket.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Deribit
|
4
|
-
# Websocket API
|
4
|
+
# Websocket API adapter
|
5
5
|
# @author Iulian Costan (deribit-api@iuliancostan.com)
|
6
6
|
# @see https://docs.deribit.com/#subscriptions
|
7
7
|
class Websocket
|
@@ -62,10 +62,18 @@ module Deribit
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def authorize
|
65
|
+
@callbacks['auth'] = lambda do |result|
|
66
|
+
@access_token = result['access_token']
|
67
|
+
end
|
68
|
+
|
69
|
+
@ws.send authorize_payload.to_json.to_s
|
70
|
+
end
|
71
|
+
|
72
|
+
def authorize_payload
|
65
73
|
timestamp = Time.now.utc.to_i * 1000
|
66
74
|
nonce = rand(999_999).to_s
|
67
75
|
signature = Deribit.signature timestamp, nonce, '', @secret
|
68
|
-
|
76
|
+
{
|
69
77
|
jsonrpc: '2.0',
|
70
78
|
method: 'public/auth',
|
71
79
|
id: 'auth',
|
@@ -78,10 +86,6 @@ module Deribit
|
|
78
86
|
signature: signature
|
79
87
|
}
|
80
88
|
}
|
81
|
-
@callbacks['auth'] = lambda do |result|
|
82
|
-
@access_token = result['access_token']
|
83
|
-
end
|
84
|
-
@ws.send payload.to_json.to_s
|
85
89
|
end
|
86
90
|
|
87
91
|
def websocket_url
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Iulian Costan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|