deribit-api 0.1.2 → 0.1.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: d9384ba752c4c01d89a64e693199e7a22e57cf03d0de5f3f69cf47d3cd420079
4
- data.tar.gz: 8c7497902c3cfcf5d799379f721460b73bb75137d2a82ce5d99245be03252e1f
3
+ metadata.gz: a62314b7e75414635ba071509257b3351fc60ad480be229c244cc35dd546887e
4
+ data.tar.gz: f40fa635d14dbe3547f37cca66fcc8f5752ae73f4e1f0a4eb061c85e4e2a7f3c
5
5
  SHA512:
6
- metadata.gz: cc000a2fc6d98a8db24e1742c5f61ada7e67e6b5634ebbf6d72eb9566f92146471feff17126d320608fb1aa37d584f63f8dad9c8ecfd2cd847bc9b905182b952
7
- data.tar.gz: c2763b97462ee107278bb699e7f79ea16587e49d1fde62a1d7d13b2b5173731d4d55b6b475788375ba2e0522d0cb0ae0b0254ccde0c67f49db1ec9a36858bd60
6
+ metadata.gz: 41939581f1de76212b2a7b621fc004078edfada5cd732ff660e2d292ed915f9c376ce7a3eff9510a2daa30e9e1a8821a03cd02e7ece147635334b9867ef5a6f5
7
+ data.tar.gz: 3e3e2a78c651293ec0a0e6cddf8caefc68890cf37599242ac917708687a6cca2bf7d513616c3e2a70875c5f8982c3bab22f08a575c29a99f8bdd9512099cfd1f
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ /.env
@@ -1 +1 @@
1
- 2.5.3
1
+ 2.6.3
@@ -3,14 +3,14 @@ sudo: false
3
3
  language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
- - 2.5.3
6
+ - 2.6.3
7
7
 
8
8
  env:
9
9
  global:
10
10
  - CC_TEST_REPORTER_ID=d6a710d8173e78db96a25675960ddf02d27d9cd1fd4e237785cafd8878f8a5ba
11
11
 
12
12
  before_install:
13
- - gem install bundler -v 1.17.1
13
+ - gem install bundler
14
14
  - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
15
15
  - chmod +x ./cc-test-reporter
16
16
 
@@ -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
+ ## [0.1.3] - 2019-07-02
9
+ ### Changed
10
+ - extract HTTP class
11
+ - upgrade Ruby to 2.6.3
12
+ - update all gems
13
+ ### Fixed
14
+ - trade history tests
15
+ - new test prices
16
+
8
17
  ## [0.1.2] - 2019-04-17
9
18
  ### Added
10
19
  - private Websocket API
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- deribit-api (0.1.2)
4
+ deribit-api (0.1.3)
5
5
  faraday
6
6
  faraday_middleware
7
7
  faye-websocket
@@ -23,15 +23,15 @@ GEM
23
23
  descendants_tracker (~> 0.0.1)
24
24
  descendants_tracker (0.0.4)
25
25
  thread_safe (~> 0.3, >= 0.3.1)
26
- docile (1.3.1)
27
- dotenv (2.7.1)
26
+ docile (1.3.2)
27
+ dotenv (2.7.4)
28
28
  equalizer (0.0.11)
29
29
  eventmachine (1.2.7)
30
30
  faraday (0.15.4)
31
31
  multipart-post (>= 1.2, < 3)
32
32
  faraday_middleware (0.13.1)
33
33
  faraday (>= 0.7.4, < 1.0)
34
- faye-websocket (0.10.7)
34
+ faye-websocket (0.10.9)
35
35
  eventmachine (>= 0.12.0)
36
36
  websocket-driver (>= 0.5.1)
37
37
  hashie (3.6.0)
@@ -40,8 +40,8 @@ GEM
40
40
  kwalify (0.7.2)
41
41
  method_source (0.9.2)
42
42
  minitest (5.11.3)
43
- multipart-post (2.0.0)
44
- parser (2.6.0.0)
43
+ multipart-post (2.1.1)
44
+ parser (2.6.3.0)
45
45
  ast (~> 2.4.0)
46
46
  pry (0.12.2)
47
47
  coderay (~> 1.1.0)
@@ -52,13 +52,13 @@ GEM
52
52
  psych (3.1.0)
53
53
  rainbow (3.0.0)
54
54
  rake (12.3.2)
55
- reek (5.3.1)
55
+ reek (5.4.0)
56
56
  codeclimate-engine-rb (~> 0.4.0)
57
57
  kwalify (~> 0.7.0)
58
58
  parser (>= 2.5.0.0, < 2.7, != 2.5.1.1)
59
59
  psych (~> 3.1.0)
60
60
  rainbow (>= 2.0, < 4.0)
61
- simplecov (0.16.1)
61
+ simplecov (0.17.0)
62
62
  docile (~> 1.1)
63
63
  json (>= 1.8, < 3)
64
64
  simplecov-html (~> 0.10.0)
@@ -69,10 +69,10 @@ GEM
69
69
  coercible (~> 1.0)
70
70
  descendants_tracker (~> 0.0, >= 0.0.3)
71
71
  equalizer (~> 0.0, >= 0.0.9)
72
- websocket-driver (0.7.0)
72
+ websocket-driver (0.7.1)
73
73
  websocket-extensions (>= 0.1.0)
74
- websocket-extensions (0.1.3)
75
- yard (0.9.18)
74
+ websocket-extensions (0.1.4)
75
+ yard (0.9.20)
76
76
 
77
77
  PLATFORMS
78
78
  ruby
@@ -90,4 +90,4 @@ DEPENDENCIES
90
90
  simplecov
91
91
 
92
92
  BUNDLED WITH
93
- 2.0.1
93
+ 2.0.2
data/TODOs.org CHANGED
@@ -8,7 +8,11 @@
8
8
  ** FIX API
9
9
  ** DONE use minitest
10
10
  CLOSED: [2019-02-26 Tue] SCHEDULED: <2019-02-26 Tue>
11
- ** extract HTTP client
11
+ ** DONE extract HTTP client
12
+ CLOSED: [2019-04-23 Tue 15:24]
13
+ :LOGBOOK:
14
+ CLOCK: [2019-04-23 Tue 14:31]--[2019-04-23 Tue 15:18] => 0:47
15
+ :END:
12
16
  ** DONE public Websocket API
13
17
  CLOSED: [2019-04-02 Tue 13:12] SCHEDULED: <2019-03-29 Fri>
14
18
  :LOGBOOK:
@@ -22,13 +26,17 @@
22
26
  :END:
23
27
  ** response middleware
24
28
  ** check key/secret present for private endpoints
25
- ** fix trade history
29
+ ** DONE fix trade history
30
+ CLOSED: [2019-04-23 Tue 15:17]
26
31
  ** research async websocket implementation
27
- ** cleaup 'params' for both http and websocket
32
+ ** cleanup 'params' for both http and websocket
33
+ ** update buy/sell endpoints with new params
28
34
  ** TODO Deribit implementation
29
- SCHEDULED: <2019-04-23 Tue +1w>
35
+ SCHEDULED: <2019-08-02 Tue +1m>
30
36
  :PROPERTIES:
31
- :LAST_REPEAT: [2019-04-17 Wed 18:26]
37
+ :LAST_REPEAT: [2019-07-02 Tue 13:01]
32
38
  :END:
39
+ - State "DONE" from "TODO" [2019-07-02 Tue 13:01]
40
+ - State "DONE" from "TODO" [2019-04-23 Tue 15:24]
33
41
  - State "DONE" from "TODO" [2019-04-17 Wed 18:26]
34
42
  - State "DONE" from "TODO" [2019-04-02 Tue 13:02]
@@ -7,6 +7,7 @@ require 'deribit/version'
7
7
  require 'deribit/client'
8
8
  require 'deribit/authentication'
9
9
  require 'deribit/websocket'
10
+ require 'deribit/http'
10
11
 
11
12
  # Root module
12
13
  module Deribit
@@ -6,7 +6,7 @@ module Deribit
6
6
  # URL for mainnet
7
7
  MAINNET_URL = 'www.deribit.com'
8
8
 
9
- attr_reader :websocket
9
+ attr_reader :http, :websocket
10
10
 
11
11
  # Create new instance
12
12
  # @param key [String] Deribit Access Key
@@ -16,14 +16,7 @@ module Deribit
16
16
  # @return [Deribit::Client] the instance of client
17
17
  def initialize(key: nil, secret: nil, testnet: false, debug: false)
18
18
  host = testnet ? TESTNET_URL : MAINNET_URL
19
- @connection = Faraday::Connection.new(url: 'https://' + host) do |f|
20
- f.request :json
21
- f.response :mashify
22
- f.response :json
23
- f.use Deribit::Authentication, key, secret
24
- f.response :logger if debug
25
- f.adapter Faraday.default_adapter
26
- end
19
+ @http = Deribit::Http.new host, key: key, secret: secret
27
20
  @websocket = Deribit::Websocket.new host, key: key, secret: secret
28
21
  end
29
22
 
@@ -35,7 +28,7 @@ module Deribit
35
28
  if block_given?
36
29
  websocket.subscribe :time, &blk
37
30
  else
38
- get :time
31
+ http.get :time
39
32
  end
40
33
  end
41
34
 
@@ -68,7 +61,7 @@ module Deribit
68
61
  if block_given?
69
62
  websocket.subscribe :test, params: params, &blk
70
63
  else
71
- get :test, params: params, raw_body: true
64
+ http.get :test, params: params, raw_body: true
72
65
  end
73
66
  end
74
67
 
@@ -80,7 +73,7 @@ module Deribit
80
73
  if block_given?
81
74
  websocket.subscribe :ping, &blk
82
75
  else
83
- get :ping
76
+ http.get :ping
84
77
  end
85
78
  end
86
79
 
@@ -94,7 +87,7 @@ module Deribit
94
87
  if block_given?
95
88
  websocket.subscribe :getinstruments, params: params, &blk
96
89
  else
97
- get :getinstruments, params: params
90
+ http.get :getinstruments, params: params
98
91
  end
99
92
  end
100
93
 
@@ -106,7 +99,7 @@ module Deribit
106
99
  if block_given?
107
100
  websocket.subscribe :getcurrencies, &blk
108
101
  else
109
- get :getcurrencies
102
+ http.get :getcurrencies
110
103
  end
111
104
  end
112
105
 
@@ -120,7 +113,7 @@ module Deribit
120
113
  if block_given?
121
114
  websocket.subscribe :index, params: params, &blk
122
115
  else
123
- get :index, params: params
116
+ http.get :index, params: params
124
117
  end
125
118
  end
126
119
 
@@ -137,7 +130,7 @@ module Deribit
137
130
  if block_given?
138
131
  websocket.subscribe :getorderbook, params: params, &blk
139
132
  else
140
- get :getorderbook, params: params
133
+ http.get :getorderbook, params: params
141
134
  end
142
135
  end
143
136
 
@@ -163,7 +156,7 @@ module Deribit
163
156
  if block_given?
164
157
  websocket.subscribe :getlasttrades, params: params, &blk
165
158
  else
166
- get :getlasttrades, params: params
159
+ http.get :getlasttrades, params: params
167
160
  end
168
161
  end
169
162
 
@@ -179,7 +172,7 @@ module Deribit
179
172
  if block_given?
180
173
  websocket.subscribe :getsummary, params: params, &blk
181
174
  else
182
- get :getsummary, params: params
175
+ http.get :getsummary, params: params
183
176
  end
184
177
  end
185
178
 
@@ -191,7 +184,7 @@ module Deribit
191
184
  if block_given?
192
185
  websocket.subscribe :stats, &blk
193
186
  else
194
- get :stats
187
+ http.get :stats
195
188
  end
196
189
  end
197
190
 
@@ -203,7 +196,7 @@ module Deribit
203
196
  if block_given?
204
197
  websocket.subscribe :getannouncements, &blk
205
198
  else
206
- get :getannouncements
199
+ http.get :getannouncements
207
200
  end
208
201
  end
209
202
 
@@ -221,7 +214,7 @@ module Deribit
221
214
  if block_given?
222
215
  websocket.subscribe :getlastsettlements, params: filters, &blk
223
216
  else
224
- get :getlastsettlements, params: filters
217
+ http.get :getlastsettlements, params: filters
225
218
  end
226
219
  end
227
220
 
@@ -234,7 +227,7 @@ module Deribit
234
227
  if block_given?
235
228
  websocket.subscribe :account, params: { auth: true }, &blk
236
229
  else
237
- get :account, auth: true
230
+ http.get :account, auth: true
238
231
  end
239
232
  end
240
233
 
@@ -260,7 +253,7 @@ module Deribit
260
253
  if block_given?
261
254
  websocket.subscribe :buy, params: params.merge(auth: true), &blk
262
255
  else
263
- post :buy, params
256
+ http.post :buy, params
264
257
  end
265
258
  end
266
259
 
@@ -276,7 +269,7 @@ module Deribit
276
269
  if block_given?
277
270
  websocket.subscribe :sell, params: params, &blk
278
271
  else
279
- post :sell, params
272
+ http.post :sell, params
280
273
  end
281
274
  end
282
275
 
@@ -296,7 +289,7 @@ module Deribit
296
289
  if block_given?
297
290
  websocket.subscribe :edit, params: params, &blk
298
291
  else
299
- post :edit, params
292
+ http.post :edit, params
300
293
  end
301
294
  end
302
295
 
@@ -310,7 +303,7 @@ module Deribit
310
303
  if block_given?
311
304
  websocket.subscribe :cancel, params: params, &blk
312
305
  else
313
- post :cancel, params
306
+ http.post :cancel, params
314
307
  end
315
308
  end
316
309
 
@@ -326,7 +319,7 @@ module Deribit
326
319
  if block_given?
327
320
  websocket.subscribe :cancelall, params: params, &blk
328
321
  else
329
- post :cancelall, params
322
+ http.post :cancelall, params
330
323
  end
331
324
  end
332
325
 
@@ -342,7 +335,7 @@ module Deribit
342
335
  if block_given?
343
336
  websocket.subscribe :getopenorders, params: options.merge(auth: true), &blk
344
337
  else
345
- get :getopenorders, auth: true, params: options
338
+ http.get :getopenorders, auth: true, params: options
346
339
  end
347
340
  end
348
341
 
@@ -355,7 +348,7 @@ module Deribit
355
348
  if block_given?
356
349
  websocket.subscribe :positions, params: params, &blk
357
350
  else
358
- get :positions, params
351
+ http.get :positions, params
359
352
  end
360
353
  end
361
354
 
@@ -371,7 +364,7 @@ module Deribit
371
364
  if block_given?
372
365
  websocket.subscribe :orderhistory, params: options.merge(auth: true), &blk
373
366
  else
374
- get :orderhistory, auth: true, params: options
367
+ http.get :orderhistory, auth: true, params: options
375
368
  end
376
369
  end
377
370
 
@@ -385,7 +378,7 @@ module Deribit
385
378
  if block_given?
386
379
  websocket.subscribe :orderstate, params: params, &blk
387
380
  else
388
- get :orderstate, auth: true, params: params
381
+ http.get :orderstate, auth: true, params: params
389
382
  end
390
383
  end
391
384
 
@@ -400,7 +393,7 @@ module Deribit
400
393
  if block_given?
401
394
  websocket.subscribe :tradehistory, params: params, &blk
402
395
  else
403
- get :tradehistory, auth: true, params: params
396
+ http.get :tradehistory, auth: true, params: params
404
397
  end
405
398
  end
406
399
 
@@ -411,7 +404,7 @@ module Deribit
411
404
  if block_given?
412
405
  websocket.subscribe :newannouncements, params: { auth: true }, &blk
413
406
  else
414
- get :newannouncements, auth: true
407
+ http.get :newannouncements, auth: true
415
408
  end
416
409
  end
417
410
 
@@ -441,7 +434,7 @@ module Deribit
441
434
  if block_given?
442
435
  websocket.subscribe :getemaillang, params: { auth: true }, &blk
443
436
  else
444
- get :getemaillang, auth: true
437
+ http.get :getemaillang, auth: true
445
438
  end
446
439
  end
447
440
 
@@ -453,7 +446,7 @@ module Deribit
453
446
  if block_given?
454
447
  websocket.subscribe :setemaillang, params: { lang: lang, auth: true }, &blk
455
448
  else
456
- post :setemaillang, lang: lang
449
+ http.post :setemaillang, lang: lang
457
450
  end
458
451
  end
459
452
 
@@ -465,7 +458,7 @@ module Deribit
465
458
  if block_given?
466
459
  websocket.subscribe :setannouncementasread, params: { announcementid: announcement_id, auth: true }, &blk
467
460
  else
468
- post :setannouncementasread, announcementid: announcement_id
461
+ http.post :setannouncementasread, announcementid: announcement_id
469
462
  end
470
463
  end
471
464
 
@@ -483,32 +476,8 @@ module Deribit
483
476
  if block_given?
484
477
  websocket.subscribe :settlementhistory, params: filters.merge(auth: true), &blk
485
478
  else
486
- get :settlementhistory, auth: true, params: filters
479
+ http.get :settlementhistory, auth: true, params: filters
487
480
  end
488
481
  end
489
-
490
- private
491
-
492
- def get(action, params: {}, raw_body: false, auth: false)
493
- response = @connection.get path(action, auth), params
494
- # TODO: move to middleware
495
- raise response.message unless response.success?
496
- raise response.body.message unless response.body.success
497
- body = response.body
498
- raw_body ? body : body.result
499
- end
500
-
501
- def post(action, params)
502
- response = @connection.post path(action, true), params
503
- raise response.message unless response.success?
504
- raise response.body.message unless response.body.success
505
-
506
- response.body.result || response.body.success?
507
- end
508
-
509
- def path(action, auth = false)
510
- access = auth ? 'private' : 'public'
511
- "/api/v1/#{access}/#{action}"
512
- end
513
482
  end
514
483
  end
@@ -0,0 +1,45 @@
1
+ module Deribit
2
+ # HTTP API
3
+ # @see https://docs.deribit.com/api-http.html
4
+ class Http
5
+ def initialize(host, key: nil, secret: nil, debug: false)
6
+ url = 'https://' + host
7
+ @connection = Faraday::Connection.new(url: url) do |f|
8
+ f.request :json
9
+ f.response :mashify
10
+ f.response :json
11
+ f.use Deribit::Authentication, key, secret
12
+ f.response :logger if debug
13
+ f.adapter Faraday.default_adapter
14
+ end
15
+ end
16
+
17
+ def get(action, params: {}, raw_body: false, auth: false)
18
+ response = @connection.get path(action, auth), params
19
+
20
+ # TODO: move to middleware
21
+ raise response.message unless response.success?
22
+ raise response.body.message unless response.body.success
23
+
24
+ body = response.body
25
+ raw_body ? body : body.result
26
+ end
27
+
28
+ def post(action, params)
29
+ response = @connection.post path(action, true), params
30
+
31
+ # TODO: move to middleware
32
+ raise response.message unless response.success?
33
+ raise response.body.message unless response.body.success
34
+
35
+ response.body.result || response.body.success?
36
+ end
37
+
38
+ private
39
+
40
+ def path(action, auth = false)
41
+ access = auth ? 'private' : 'public'
42
+ "/api/v1/#{access}/#{action}"
43
+ end
44
+ end
45
+ end
@@ -1,3 +1,3 @@
1
1
  module Deribit
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
@@ -1,4 +1,6 @@
1
1
  module Deribit
2
+ # Websocket API
3
+ # @see https://docs.deribit.com/api-websocket.html
2
4
  class Websocket
3
5
  attr_reader :host, :key, :secret
4
6
 
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: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iulian Costan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-17 00:00:00.000000000 Z
11
+ date: 2019-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -217,6 +217,7 @@ files:
217
217
  - lib/deribit.rb
218
218
  - lib/deribit/authentication.rb
219
219
  - lib/deribit/client.rb
220
+ - lib/deribit/http.rb
220
221
  - lib/deribit/version.rb
221
222
  - lib/deribit/websocket.rb
222
223
  homepage: https://github.com/icostan/deribit-api-ruby
@@ -241,8 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
242
  - !ruby/object:Gem::Version
242
243
  version: '0'
243
244
  requirements: []
244
- rubyforge_project:
245
- rubygems_version: 2.7.6
245
+ rubygems_version: 3.0.4
246
246
  signing_key:
247
247
  specification_version: 4
248
248
  summary: Ruby library for Deribit API