deribit 1.3.2 → 1.4.3
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/README.md +7 -16
- data/lib/deribit/api.rb +1 -1
- data/lib/deribit/request.rb +1 -0
- data/lib/deribit/version.rb +1 -1
- data/lib/deribit/ws.rb +9 -7
- data/lib/deribit/ws/handler.rb +5 -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: c7d582e9a80f6deedcc4047f1e299903c0ea18883b329b41240e93780982a213
|
|
4
|
+
data.tar.gz: 0d3f86ea956bcf6b706fb63da469ac4da52ae92da99e1af68edab7c73ee53374
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d2e24585970cf7d86320b593a75ecca28adc80e446d26027ec9762bb4a18f5bde2f221a979075436b7a1897cfda71bd0d64dea5c5a9763a95fdbae06924d246c
|
|
7
|
+
data.tar.gz: c9ebe1dc7045238917fe7280da6aa89f11d5ed04ea76701126b5b5142790ec907c31e51b9b6f8bb36a97f6d85e883891cdde3ea147f1c7c1a1cfd9b35f756127
|
data/README.md
CHANGED
|
@@ -54,7 +54,7 @@ Constructor creates new API client.
|
|
|
54
54
|
|
|
55
55
|
### Methods
|
|
56
56
|
|
|
57
|
-
* `
|
|
57
|
+
* `instruments(expired: false, only_active: true)` - [Doc](https://www.deribit.com/docs/api/#getinstruments), public
|
|
58
58
|
|
|
59
59
|
Returns active instruments
|
|
60
60
|
**Parameters**
|
|
@@ -64,7 +64,7 @@ Constructor creates new API client.
|
|
|
64
64
|
| `expired` | `boolean` | Optional, for returning all expired instruments. |
|
|
65
65
|
| `only_active`| `boolean` | Optional, returns only isActive true instruments |
|
|
66
66
|
|
|
67
|
-
* `
|
|
67
|
+
* `orderbook(instrument)` - [Doc](https://www.deribit.com/docs/api/#getinstruments), public
|
|
68
68
|
|
|
69
69
|
Retrieve the orderbook for a given instrument.
|
|
70
70
|
|
|
@@ -75,11 +75,11 @@ Constructor creates new API client.
|
|
|
75
75
|
| `instrument` | `string` | Required, instrument name |
|
|
76
76
|
|
|
77
77
|
|
|
78
|
-
* `index
|
|
78
|
+
* `index` - [Doc](https://www.deribit.com/docs/api/#index), public
|
|
79
79
|
|
|
80
80
|
Get price index, BTC-USD rates.
|
|
81
81
|
|
|
82
|
-
* `getcurrencies
|
|
82
|
+
* `getcurrencies` - [Doc](https://www.deribit.com/docs/api/#getcurrencies), public
|
|
83
83
|
|
|
84
84
|
Get all supported currencies.
|
|
85
85
|
|
|
@@ -171,7 +171,7 @@ Constructor creates new API client.
|
|
|
171
171
|
|--------------|------------|-----------------------------------------------------------------------------------|
|
|
172
172
|
| `order_id` | `integer` | Required, ID of the order returned by "sell" or "buy" request
|
|
173
173
|
|
|
174
|
-
* `
|
|
174
|
+
* `open_orders(instrument)` - [Doc](https://www.deribit.com/docs/api/#getopenorders), private
|
|
175
175
|
|
|
176
176
|
Retrieve open orders.
|
|
177
177
|
|
|
@@ -181,19 +181,10 @@ Constructor creates new API client.
|
|
|
181
181
|
|--------------|------------|-----------------------------------------------------------------------|
|
|
182
182
|
| `instrument` | `string` | Optional, instrument name, use if want orders for specific instrument |
|
|
183
183
|
|
|
184
|
-
* `positions
|
|
184
|
+
* `positions` - [Doc](https://www.deribit.com/docs/api/#positions), private
|
|
185
185
|
|
|
186
186
|
Retreive positions.
|
|
187
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
188
|
|
|
198
189
|
* `tradehistory(count: count, instrument: instrument, start_trade_id: start_trade_id)` - [Doc](https://www.deribit.com/docs/api/#tradehistory), private
|
|
199
190
|
|
|
@@ -236,7 +227,7 @@ class MyHandler < Deribit::WS::Handler
|
|
|
236
227
|
end
|
|
237
228
|
|
|
238
229
|
#action handler
|
|
239
|
-
def
|
|
230
|
+
def instruments(json)
|
|
240
231
|
#you actions here
|
|
241
232
|
end
|
|
242
233
|
end
|
data/lib/deribit/api.rb
CHANGED
data/lib/deribit/request.rb
CHANGED
data/lib/deribit/version.rb
CHANGED
data/lib/deribit/ws.rb
CHANGED
|
@@ -3,13 +3,12 @@ require 'websocket-client-simple'
|
|
|
3
3
|
module Deribit
|
|
4
4
|
class WS
|
|
5
5
|
AVAILABLE_EVENTS = [:order_book, :trade, :my_trade, :user_order, :index, :portfolio, :announcement]
|
|
6
|
-
|
|
7
|
-
attr_reader :socket, :response, :ids_stack, :handler, :subscribed_instruments
|
|
6
|
+
attr_reader :socket, :response, :ids_stack, :handler, :subscribed_instruments, :test_server
|
|
8
7
|
|
|
9
8
|
def initialize(key, secret, handler: Handler, test_server: nil)
|
|
10
|
-
test_server
|
|
9
|
+
@test_server = test_server || ENV["DERIBIT_TEST_SERVER"]
|
|
11
10
|
@request = Request.new(key, secret, test_server: test_server)
|
|
12
|
-
@socket = connect
|
|
11
|
+
@socket = connect
|
|
13
12
|
@handler = handler.instance_of?(Class) ? handler.new : handler
|
|
14
13
|
@ids_stack = []
|
|
15
14
|
|
|
@@ -32,7 +31,8 @@ module Deribit
|
|
|
32
31
|
end
|
|
33
32
|
end
|
|
34
33
|
|
|
35
|
-
def connect
|
|
34
|
+
def connect
|
|
35
|
+
url = test_server ? WS_TEST_URL : WS_SERVER_URL
|
|
36
36
|
puts "Connecting to #{url}"
|
|
37
37
|
WebSocket::Client::Simple.connect(url)
|
|
38
38
|
end
|
|
@@ -197,7 +197,7 @@ module Deribit
|
|
|
197
197
|
|
|
198
198
|
def set_heartbeat(interval = "60")
|
|
199
199
|
params = {
|
|
200
|
-
"interval": interval
|
|
200
|
+
"interval": interval.to_s
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
send(path: '/api/v1/public/setheartbeat', arguments: params)
|
|
@@ -221,6 +221,7 @@ module Deribit
|
|
|
221
221
|
if msg.type == :text
|
|
222
222
|
json = JSON.parse(msg.data, symbolize_names: true)
|
|
223
223
|
puts "Subscribed!" if json[:message] == "subscribed"
|
|
224
|
+
# puts "Got json: #{json}"
|
|
224
225
|
|
|
225
226
|
if json[:message] == "test_request"
|
|
226
227
|
# puts "Got test request: #{json.inspect}" # DEBUG
|
|
@@ -243,7 +244,8 @@ module Deribit
|
|
|
243
244
|
instance.handler.send(:notice, json)
|
|
244
245
|
end
|
|
245
246
|
|
|
246
|
-
|
|
247
|
+
# puts "Want to update timestamp for handler for event: #{json.inspect}"
|
|
248
|
+
instance.handler.update_timestamp!
|
|
247
249
|
elsif msg.type == :close
|
|
248
250
|
puts "trying to reconnect = got close event, msg: #{msg.inspect}"
|
|
249
251
|
instance.reconnect!
|
data/lib/deribit/ws/handler.rb
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
module Deribit
|
|
2
2
|
class WS
|
|
3
|
-
|
|
4
3
|
class Handler
|
|
5
|
-
|
|
4
|
+
attr_reader :timestamp
|
|
6
5
|
|
|
7
6
|
AVAILABLE_METHODS = [
|
|
8
7
|
:account,
|
|
@@ -25,10 +24,6 @@ module Deribit
|
|
|
25
24
|
]
|
|
26
25
|
SILENT = [:setheartbeat, :subscribed, :heartbeat, :"public API test"]
|
|
27
26
|
|
|
28
|
-
def initialize
|
|
29
|
-
@timestamp = Time.now.to_i
|
|
30
|
-
end
|
|
31
|
-
|
|
32
27
|
def method_missing(m, *json, &block)
|
|
33
28
|
return false if SILENT.include?(m.to_sym)
|
|
34
29
|
|
|
@@ -50,6 +45,10 @@ module Deribit
|
|
|
50
45
|
def handle_error(json, error)
|
|
51
46
|
puts "Alert! #{error.class} on message: '#{json.try(:fetch, :message)}', #{json.inspect}. Message: #{error.full_message}"
|
|
52
47
|
end
|
|
48
|
+
|
|
49
|
+
def update_timestamp!
|
|
50
|
+
@timestamp = Time.now.to_i
|
|
51
|
+
end
|
|
53
52
|
end
|
|
54
53
|
|
|
55
54
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: deribit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3
|
|
4
|
+
version: 1.4.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alexander Dmitriev
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2019-08-
|
|
12
|
+
date: 2019-08-14 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bundler
|