bitmex-api 0.1.1 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 448191dd7c9613d1201fd02d19c14e089e4c58a4b8f0976043d6940b958fdd49
4
- data.tar.gz: 5dbaa19973f3ecf4265124adb2e19f2df3e446c826241916bbbc7d971ab1bbcb
3
+ metadata.gz: b65d3eb22f3a7755e996177401b795eaae4bea1694e4d0de371caa88e828c1c6
4
+ data.tar.gz: b725cd715818f4679b84e455d323024328b8424d4762b6a9bd1d1941c69ee61e
5
5
  SHA512:
6
- metadata.gz: 7226c9c0656f4e13af581708a4493ad89a4f5d272a9f8de290cdb35423b7847d3af506cd2a51f4b02428bcb0bdfb39ce69782e5f9a5fc90cd7fc1c57d151e602
7
- data.tar.gz: 940894dc0f2af98dc25dbf8a893fddbc14877519e449e11a141a69355833d395206397651ae301b05ff078f10b2f6e2ded2c10be87b3c52f0c5bf7568b90ebc4
6
+ metadata.gz: efec1809ffe7a59ed89f5039e8198658288543781c8b7f9ad5e4562040b7fd18c1271a5c030d08a75e4976e861b52530444bbce8780cc89c82eef718e39fa94d
7
+ data.tar.gz: 18ce484b82e20f10fa234f90662a9114c0e0014a84a9e56abda54754aae11ce419db3cef350f8693ceb7e5f2b99e01d523c185a6f1a665cacb4ebbfe9c299b75
@@ -1 +1 @@
1
- 2.5.3
1
+ 2.7.1
@@ -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=62a2cea238cf89f14f968d9a91fe41af7a11f414f6cc9194df7abc7887e61f6e
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,42 @@
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.6] - 2020-06-10
9
+ ### Added
10
+ - lcov formatter for simplecov
11
+ ### Changed
12
+ - update all gems
13
+ - update Ruby to 2.7.1
14
+ ### Fixed
15
+ - brittle tests
16
+
17
+ ## [0.1.5] - 2019-12-17
18
+ ### Changed
19
+ - update gems
20
+ ### Fixed
21
+ - outdated specs
22
+ - typos in README
23
+
24
+ ## [0.1.4] - 2019-09-12
25
+ ### Fixed
26
+ - hash filters in user#executions
27
+ - outdated specs
28
+ ### Changed
29
+ - update all gems
30
+
31
+ ## [0.1.3] - 2019-07-03
32
+ ### Changed
33
+ - update Ruby to 2.6.3
34
+ - update all gems
35
+ ### Fixed
36
+ - query params for filtering in GET requests
37
+
38
+ ## [0.1.2] - 2019-04-17
39
+ ### Changed
40
+ - update gems
41
+ ### Fixed
42
+ - price for limit order spec
43
+
8
44
  ## [0.1.1] - 2019-03-06
9
45
  ### Added
10
46
  - functional state transfer from one websocket block to the next
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bitmex-api (0.1.1)
4
+ bitmex-api (0.1.6)
5
5
  eventmachine
6
6
  faye-websocket
7
7
  hashie
@@ -11,97 +11,79 @@ GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
13
  ast (2.4.0)
14
- axiom-types (0.1.1)
15
- descendants_tracker (~> 0.0.4)
16
- ice_nine (~> 0.11.0)
17
- thread_safe (~> 0.3, >= 0.3.1)
18
- bump (0.8.0)
19
- codeclimate-engine-rb (0.4.1)
20
- virtus (~> 1.0)
21
- coderay (1.1.2)
22
- coercible (1.0.0)
23
- descendants_tracker (~> 0.0.1)
24
- descendants_tracker (0.0.4)
25
- thread_safe (~> 0.3, >= 0.3.1)
14
+ bump (0.9.0)
15
+ coderay (1.1.3)
26
16
  diff-lcs (1.3)
27
- docile (1.3.1)
28
- dotenv (2.7.1)
29
- equalizer (0.0.11)
17
+ docile (1.3.2)
18
+ dotenv (2.7.5)
30
19
  eventmachine (1.2.7)
31
- faye-websocket (0.10.7)
20
+ faye-websocket (0.10.9)
32
21
  eventmachine (>= 0.12.0)
33
22
  websocket-driver (>= 0.5.1)
34
- hashie (3.6.0)
35
- httparty (0.16.4)
23
+ hashie (4.1.0)
24
+ httparty (0.18.0)
36
25
  mime-types (~> 3.0)
37
26
  multi_xml (>= 0.5.2)
38
- ice_nine (0.11.2)
39
- jaro_winkler (1.5.2)
40
- json (2.2.0)
41
27
  kwalify (0.7.2)
42
- method_source (0.9.2)
43
- mime-types (3.2.2)
28
+ method_source (1.0.0)
29
+ mime-types (3.3.1)
44
30
  mime-types-data (~> 3.2015)
45
- mime-types-data (3.2018.0812)
31
+ mime-types-data (3.2020.0512)
46
32
  multi_xml (0.6.0)
47
- parallel (1.14.0)
48
- parser (2.6.0.0)
33
+ parallel (1.19.1)
34
+ parser (2.7.1.3)
49
35
  ast (~> 2.4.0)
50
- powerpack (0.1.2)
51
- pry (0.12.2)
52
- coderay (~> 1.1.0)
53
- method_source (~> 0.9.0)
54
- pry-doc (1.0.0)
36
+ pry (0.13.1)
37
+ coderay (~> 1.1)
38
+ method_source (~> 1.0)
39
+ pry-doc (1.1.0)
55
40
  pry (~> 0.11)
56
41
  yard (~> 0.9.11)
57
42
  psych (3.1.0)
58
43
  rainbow (3.0.0)
59
- rake (12.3.2)
60
- reek (5.3.1)
61
- codeclimate-engine-rb (~> 0.4.0)
44
+ rake (13.0.1)
45
+ reek (6.0.1)
62
46
  kwalify (~> 0.7.0)
63
- parser (>= 2.5.0.0, < 2.7, != 2.5.1.1)
47
+ parser (>= 2.5.0.0, < 2.8, != 2.5.1.1)
64
48
  psych (~> 3.1.0)
65
49
  rainbow (>= 2.0, < 4.0)
66
- rspec (3.8.0)
67
- rspec-core (~> 3.8.0)
68
- rspec-expectations (~> 3.8.0)
69
- rspec-mocks (~> 3.8.0)
70
- rspec-core (3.8.0)
71
- rspec-support (~> 3.8.0)
72
- rspec-expectations (3.8.2)
50
+ regexp_parser (1.7.1)
51
+ rexml (3.2.4)
52
+ rspec (3.9.0)
53
+ rspec-core (~> 3.9.0)
54
+ rspec-expectations (~> 3.9.0)
55
+ rspec-mocks (~> 3.9.0)
56
+ rspec-core (3.9.2)
57
+ rspec-support (~> 3.9.3)
58
+ rspec-expectations (3.9.2)
73
59
  diff-lcs (>= 1.2.0, < 2.0)
74
- rspec-support (~> 3.8.0)
75
- rspec-mocks (3.8.0)
60
+ rspec-support (~> 3.9.0)
61
+ rspec-mocks (3.9.1)
76
62
  diff-lcs (>= 1.2.0, < 2.0)
77
- rspec-support (~> 3.8.0)
78
- rspec-support (3.8.0)
79
- rubocop (0.65.0)
80
- jaro_winkler (~> 1.5.1)
63
+ rspec-support (~> 3.9.0)
64
+ rspec-support (3.9.3)
65
+ rubocop (0.85.1)
81
66
  parallel (~> 1.10)
82
- parser (>= 2.5, != 2.5.1.1)
83
- powerpack (~> 0.1)
84
- psych (>= 3.1.0)
67
+ parser (>= 2.7.0.1)
85
68
  rainbow (>= 2.2.2, < 4.0)
69
+ regexp_parser (>= 1.7)
70
+ rexml
71
+ rubocop-ast (>= 0.0.3)
86
72
  ruby-progressbar (~> 1.7)
87
- unicode-display_width (~> 1.4.0)
88
- ruby-progressbar (1.10.0)
89
- simplecov (0.16.1)
73
+ unicode-display_width (>= 1.4.0, < 2.0)
74
+ rubocop-ast (0.0.3)
75
+ parser (>= 2.7.0.1)
76
+ ruby-progressbar (1.10.1)
77
+ simplecov (0.18.5)
90
78
  docile (~> 1.1)
91
- json (>= 1.8, < 3)
92
- simplecov-html (~> 0.10.0)
93
- simplecov-html (0.10.2)
94
- thread_safe (0.3.6)
95
- unicode-display_width (1.4.1)
96
- virtus (1.0.5)
97
- axiom-types (~> 0.1)
98
- coercible (~> 1.0)
99
- descendants_tracker (~> 0.0, >= 0.0.3)
100
- equalizer (~> 0.0, >= 0.0.9)
101
- websocket-driver (0.7.0)
79
+ simplecov-html (~> 0.11)
80
+ simplecov-html (0.12.2)
81
+ simplecov-lcov (0.8.0)
82
+ unicode-display_width (1.7.0)
83
+ websocket-driver (0.7.2)
102
84
  websocket-extensions (>= 0.1.0)
103
- websocket-extensions (0.1.3)
104
- yard (0.9.18)
85
+ websocket-extensions (0.1.5)
86
+ yard (0.9.25)
105
87
 
106
88
  PLATFORMS
107
89
  ruby
@@ -118,6 +100,7 @@ DEPENDENCIES
118
100
  rspec
119
101
  rubocop
120
102
  simplecov
103
+ simplecov-lcov
121
104
 
122
105
  BUNDLED WITH
123
- 1.17.1
106
+ 2.1.4
data/README.md CHANGED
@@ -43,7 +43,7 @@ client = Bitmex::Client.new api_key: 'KEY', api_secret: 'SECRET'
43
43
 
44
44
  #### REST API
45
45
 
46
- Get last 10 messages in English channel:
46
+ Get last 10 messages from English channel:
47
47
 
48
48
  ```ruby
49
49
  messages = client.chat.messages channelID: 1, count: 10, reverse: true
@@ -86,7 +86,7 @@ All Websocket API blocks yield a pseudo-object `Bitmex::Mash`.
86
86
 
87
87
  #### Whales watching
88
88
 
89
- Filtering traders bigger than 10 XBT {file:bin/whales-watching.rb}
89
+ Filtering trades bigger than 10 XBT {file:bin/whales-watching.rb}
90
90
 
91
91
  ```ruby
92
92
  client = Bitmex::Client.new
data/TODOs.org CHANGED
@@ -1,4 +1,16 @@
1
- * Tasks :BITMEX:
1
+ * [[elisp:(org-projectile-open-project%20"bitmex-api-ruby")][bitmex-api-ruby]] [17/18]
2
+ :PROPERTIES:
3
+ :CATEGORY: bitmex
4
+ :END:
5
+ ** TODO bitmex-api-ruby maintenance
6
+ SCHEDULED: <2020-12-09 Wed +6m>
7
+ :PROPERTIES:
8
+ :LAST_REPEAT: [2020-06-10 Wed 08:12]
9
+ :END:
10
+ - State "DONE" from "TODO" [2020-06-10 Wed 08:12]
11
+ - State "DONE" from "TODO" [2019-12-17 Tue 10:53]
12
+ - State "DONE" from "TODO" [2019-09-12 Thu 18:25]
13
+ - State "DONE" from "TODO" [2019-07-03 Wed 18:52]
2
14
  ** DONE initial gem release
3
15
  SCHEDULED: <2019-01-03 Thu> CLOSED: <2019-01-03 Thu>
4
16
  ** DONE websocket API
@@ -7,8 +19,6 @@
7
19
  CLOSED: [2019-01-16 Wed] SCHEDULED: <2019-01-15 Tue> DEADLINE: <2019-01-16 Wed>
8
20
  ** DONE auth for private subscription topics
9
21
  CLOSED: [2019-02-01 Fri] SCHEDULED: <2019-02-01 Fri>
10
- ** move from rspec to minitest
11
- ** configure autorun
12
22
  ** hearbeat, ping/pong
13
23
  ** DONE implement user actions get/put/post
14
24
  CLOSED: [2019-01-22 Tue] SCHEDULED: <2019-01-17 Thu>
@@ -19,7 +29,13 @@
19
29
  ** DONE orderbook, order resource
20
30
  CLOSED: [2019-01-29 Tue] SCHEDULED: <2019-01-29 Tue>
21
31
  ** refactoring: use class methods when working with multiple entities
22
- ** bug: {"error":{"message":"Signature not valid.","name":"HTTPError"}} in user#executions
32
+ ** DONE bug: {"error":{"message":"Signature not valid.","name":"HTTPError"}} in user#executions
33
+ CLOSED: [2019-09-12 Thu 18:24]
34
+ ** DONE bug: handle query in websocket and skip in POST/PUT/DELETE operations
35
+ CLOSED: [2019-07-03 Wed 18:06]
36
+ :LOGBOOK:
37
+ CLOCK: [2019-07-03 Wed 17:55]--[2019-07-03 Wed 18:06] => 0:11
38
+ :END:
23
39
  ** DONE liquidation, leaderboard, insurance, instrument, funding, execution, chat, announcement
24
40
  CLOSED: [2019-01-30 Wed] SCHEDULED: <2019-01-30 Wed>
25
41
  ** DONE refactoring: extract websocket common logic
@@ -49,4 +49,5 @@ Gem::Specification.new do |spec|
49
49
  spec.add_development_dependency 'rspec'
50
50
  spec.add_development_dependency 'rubocop'
51
51
  spec.add_development_dependency 'simplecov'
52
+ spec.add_development_dependency 'simplecov-lcov'
52
53
  end
@@ -28,22 +28,26 @@ module Bitmex
28
28
  TESTNET_HOST = 'testnet.bitmex.com'.freeze
29
29
  MAINNET_HOST = 'www.bitmex.com'.freeze
30
30
 
31
- def self.signature(api_secret, verb, path, expires, params)
32
- params = '' if params.nil?
33
- params = params.to_s unless params.is_a? String
31
+ def self.signature(api_secret, verb, path, expires, body, query)
32
+ body = '' if body.nil?
33
+ body = body.to_s unless body.is_a? String
34
34
 
35
- data = verb + path + expires.to_s + params
35
+ if query != nil && query.is_a?(Hash) && !query.empty?
36
+ path += "?#{URI.encode_www_form(query)}"
37
+ end
38
+
39
+ data = verb + path + expires.to_s + body
36
40
  OpenSSL::HMAC.hexdigest 'SHA256', api_secret, data
37
41
  end
38
42
 
39
- def self.headers(api_key, api_secret, verb, path, body)
43
+ def self.headers(api_key, api_secret, verb, path, body, query)
40
44
  return {} unless api_key || api_secret
41
45
 
42
46
  expires = Time.now.utc.to_i + 60
43
47
  {
44
48
  'api-expires' => expires.to_s,
45
49
  'api-key' => api_key,
46
- 'api-signature' => Bitmex.signature(api_secret, verb, path, expires, body)
50
+ 'api-signature' => Bitmex.signature(api_secret, verb, path, expires, body, query)
47
51
  }
48
52
  end
49
53
  end
@@ -29,7 +29,7 @@ module Bitmex
29
29
 
30
30
  options = {}
31
31
  options[:query] = params unless params.empty?
32
- options[:headers] = rest_headers 'GET', path, '' if auth
32
+ options[:headers] = rest_headers 'GET', path, '', params if auth
33
33
 
34
34
  response = self.class.get "#{domain_url}#{path}", options
35
35
  block_given? ? yield(response) : response_handler(response)
@@ -40,7 +40,7 @@ module Bitmex
40
40
 
41
41
  options = {}
42
42
  options[:body] = body
43
- options[:headers] = rest_headers 'PUT', path, body, json: json if auth
43
+ options[:headers] = rest_headers 'PUT', path, body, nil, json: json if auth
44
44
 
45
45
  response = self.class.put "#{domain_url}#{path}", options
46
46
  block_given? ? yield(response) : response_handler(response)
@@ -51,7 +51,7 @@ module Bitmex
51
51
 
52
52
  options = {}
53
53
  options[:body] = body
54
- options[:headers] = rest_headers 'POST', path, body, json: json if auth
54
+ options[:headers] = rest_headers 'POST', path, body, nil, json: json if auth
55
55
 
56
56
  response = self.class.post "#{domain_url}#{path}", options
57
57
  block_given? ? yield(response) : response_handler(response)
@@ -62,7 +62,7 @@ module Bitmex
62
62
 
63
63
  options = {}
64
64
  options[:body] = body
65
- options[:headers] = rest_headers 'DELETE', path, body, json: json if auth
65
+ options[:headers] = rest_headers 'DELETE', path, body, nil, json: json if auth
66
66
 
67
67
  response = self.class.delete "#{domain_url}#{path}", options
68
68
  block_given? ? yield(response) : response_handler(response)
@@ -72,8 +72,8 @@ module Bitmex
72
72
  "/api/v1/#{resource}/#{action}"
73
73
  end
74
74
 
75
- def rest_headers(verb, path, body, json: true)
76
- headers = headers verb, path, body
75
+ def rest_headers(verb, path, body, query, json: true)
76
+ headers = headers verb, path, body, query
77
77
  if json
78
78
  headers['Content-Type'] = 'application/json'
79
79
  else
@@ -82,8 +82,8 @@ module Bitmex
82
82
  headers
83
83
  end
84
84
 
85
- def headers(verb, path, body)
86
- Bitmex.headers api_key, api_secret, verb, path, body
85
+ def headers(verb, path, body, query)
86
+ Bitmex.headers api_key, api_secret, verb, path, body, query
87
87
  end
88
88
 
89
89
  def response_handler(response)
@@ -154,7 +154,11 @@ module Bitmex
154
154
  # TODO: find a better way to handle multiple parameters, dig into HTTParty
155
155
  path += '?' if params.size.positive?
156
156
  params.each do |key, value|
157
- path += "#{key}=#{value}&"
157
+ if value.is_a? Hash
158
+ path += "#{key}=#{URI.escape(value.to_json)}&"
159
+ else
160
+ path += "#{key}=#{value}&"
161
+ end
158
162
  end
159
163
  path
160
164
  end
@@ -1,3 +1,3 @@
1
1
  module Bitmex
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.6'
3
3
  end
@@ -97,7 +97,7 @@ module Bitmex
97
97
  end
98
98
 
99
99
  def headers
100
- Bitmex.headers api_key, api_secret, 'GET', '/realtime', ''
100
+ Bitmex.headers api_key, api_secret, 'GET', '/realtime', '', ''
101
101
  end
102
102
 
103
103
  # def authenticate
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitmex-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.6
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: 2019-03-06 00:00:00.000000000 Z
11
+ date: 2020-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine
@@ -206,6 +206,20 @@ dependencies:
206
206
  - - ">="
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: simplecov-lcov
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
209
223
  description: Fully-featured, idiomatic Ruby library for BitMEX API
210
224
  email:
211
225
  - iulian.costan@gmail.com
@@ -255,7 +269,7 @@ metadata:
255
269
  homepage_uri: https://github.com/icostan/bitmex-api-ruby
256
270
  source_code_uri: https://github.com/icostan/bitmex-api-ruby.git
257
271
  changelog_uri: https://github.com/icostan/bitmex-api-ruby/blob/master/CHANGELOG.md
258
- post_install_message:
272
+ post_install_message:
259
273
  rdoc_options: []
260
274
  require_paths:
261
275
  - lib
@@ -270,9 +284,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
270
284
  - !ruby/object:Gem::Version
271
285
  version: '0'
272
286
  requirements: []
273
- rubyforge_project:
274
- rubygems_version: 2.7.6
275
- signing_key:
287
+ rubygems_version: 3.1.2
288
+ signing_key:
276
289
  specification_version: 4
277
290
  summary: Fully-featured, idiomatic Ruby library for BitMEX API
278
291
  test_files: []