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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 01033c2b53f215d35bbfe632dfa2c36b1892ebe305943d2d126aafe3a026c231
4
- data.tar.gz: 82540961814471f3c11dcdd0be67b7bfd7d4a5c8fc57a17d43ed22be3d281509
3
+ metadata.gz: c7d582e9a80f6deedcc4047f1e299903c0ea18883b329b41240e93780982a213
4
+ data.tar.gz: 0d3f86ea956bcf6b706fb63da469ac4da52ae92da99e1af68edab7c73ee53374
5
5
  SHA512:
6
- metadata.gz: 5f8fd1d0aa6c42a4c9f0e0fa4ac89fff4387774e29f4e5e451542a284e9ec8a1c217177cf203f3cab9e0504bbc1ce80f01fad7488a082fa0716d401dff6c448a
7
- data.tar.gz: '097fb448d4addd3c5ca370f788dca646d7a2a8ff57509fefb84023b60e7a4547cd90daf973aad73e18b46cf089d6aa56353df5ad6119799459a087758b2705dc'
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
- * `getinstruments(expired: false, only_active: true)` - [Doc](https://www.deribit.com/docs/api/#getinstruments), public
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
- * `getorderbook(instrument)` - [Doc](https://www.deribit.com/docs/api/#getinstruments), public
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()` - [Doc](https://www.deribit.com/docs/api/#index), public
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()` - [Doc](https://www.deribit.com/docs/api/#getcurrencies), public
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
- * `getopenorders(instrument)` - [Doc](https://www.deribit.com/docs/api/#getopenorders), private
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()` - [Doc](https://www.deribit.com/docs/api/#positions), private
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 getinstruments(json)
230
+ def instruments(json)
240
231
  #you actions here
241
232
  end
242
233
  end
@@ -2,7 +2,7 @@ module Deribit
2
2
  class API
3
3
  attr_reader :request
4
4
 
5
- def initialize(key, secret, test_server: nil)
5
+ def initialize(key = nil, secret = nil, test_server: nil)
6
6
  @request = Request.new(key, secret, test_server: test_server)
7
7
  end
8
8
 
@@ -1,5 +1,6 @@
1
1
  require 'base64'
2
2
  require 'net/http'
3
+ require 'json'
3
4
 
4
5
  module Deribit
5
6
  class Request
@@ -1,3 +1,3 @@
1
1
  module Deribit
2
- VERSION = "1.3.2"
2
+ VERSION = "1.4.3"
3
3
  end
@@ -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 = ENV["DERIBIT_TEST_SERVER"] if test_server == nil
9
+ @test_server = test_server || ENV["DERIBIT_TEST_SERVER"]
11
10
  @request = Request.new(key, secret, test_server: test_server)
12
- @socket = connect(test_server ? WS_TEST_URL : WS_SERVER_URL)
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(url)
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
- instance.handler.timestamp = Time.now.to_i
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!
@@ -1,8 +1,7 @@
1
1
  module Deribit
2
2
  class WS
3
-
4
3
  class Handler
5
- attr_accessor :timestamp
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.2
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-09 00:00:00.000000000 Z
12
+ date: 2019-08-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler