binance_client 1.0.0 → 1.1.0

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: 7f3905cb869b611e99b318cb5066477236ed55a9fc206681b7991c91c6bdaad3
4
- data.tar.gz: a0f67542cf08ebaa538c4a740cf6ca4186ab619bc92a6b842ae3f3a5e1e039ef
3
+ metadata.gz: 2b8e52b3c3199ac128f970071e84b73cc25781a92f2206170b1513d523321631
4
+ data.tar.gz: 81f4c9e55772be4cb4ba350c764ebca822d66d541cb560a6477fe5e6ae0bd91e
5
5
  SHA512:
6
- metadata.gz: e57ec0318a7ed587a32154bd2c8de4c7ec5499137a33c46bb4cf166f1c89846c83cb8872037b87723a74c94c5c6ebef9aea0c72983b6a18cd4e4dae486400b18
7
- data.tar.gz: e9a67ecd796b0a7baa21c8fc48e3b2e49ede84b3271f816a014bf007c0950d5255937242c8910af7d42c98659944cf1484ed59cc49977f4786f9fccd37cbc647
6
+ metadata.gz: bfb4049818b8846b1e2bcb1913ff473b9d9a9c782aab2a7dfc9b7b6cd262a2144aa17530fc2aeccccd4314df0a77f074c5b9ffa5afad615ab269b645edcb9e09
7
+ data.tar.gz: 55054e667ceb9219fdb4098dcbd14257126d8568a463eb8fbe28692d0b545587ce30a1d1372f30141b688b5ad06402e88469f6b484079f91c028b6884b958069
data/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [1.1.0]
8
+ ### Added
9
+ - `order_book_depth` (`/api/v3/depth`) to get a snapshot of the order book
10
+
7
11
  ## [1.0.0]
8
12
  ### Fixed
9
13
  - Avoid "Signature for this request is not valid" errors by using the same timestamp
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- binance_client (1.0.0)
4
+ binance_client (1.1.0)
5
5
  activesupport
6
6
  api_client_base
7
7
  typhoeus
@@ -9,15 +9,15 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activesupport (6.0.3.4)
12
+ activesupport (6.1.4.1)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
- i18n (>= 0.7, < 2)
15
- minitest (~> 5.1)
16
- tzinfo (~> 1.1)
17
- zeitwerk (~> 2.2, >= 2.2.2)
14
+ i18n (>= 1.6, < 2)
15
+ minitest (>= 5.1)
16
+ tzinfo (~> 2.0)
17
+ zeitwerk (~> 2.3)
18
18
  addressable (2.7.0)
19
19
  public_suffix (>= 2.0.2, < 5.0)
20
- api_client_base (1.9.0)
20
+ api_client_base (1.10.0)
21
21
  activesupport (>= 3.0)
22
22
  gem_config (>= 0.3.1)
23
23
  virtus (>= 1.0)
@@ -29,23 +29,22 @@ GEM
29
29
  coderay (1.1.3)
30
30
  coercible (1.0.0)
31
31
  descendants_tracker (~> 0.0.1)
32
- concurrent-ruby (1.1.7)
32
+ concurrent-ruby (1.1.9)
33
33
  crack (0.4.3)
34
34
  safe_yaml (~> 1.0.0)
35
35
  descendants_tracker (0.0.4)
36
36
  thread_safe (~> 0.3, >= 0.3.1)
37
37
  diff-lcs (1.4.4)
38
- equalizer (0.0.11)
39
- ethon (0.12.0)
40
- ffi (>= 1.3.0)
41
- ffi (1.13.1)
38
+ ethon (0.14.0)
39
+ ffi (>= 1.15.0)
40
+ ffi (1.15.4)
42
41
  gem_config (0.3.2)
43
42
  hashdiff (1.0.1)
44
- i18n (1.8.5)
43
+ i18n (1.8.10)
45
44
  concurrent-ruby (~> 1.0)
46
45
  ice_nine (0.11.2)
47
46
  method_source (1.0.0)
48
- minitest (5.14.2)
47
+ minitest (5.14.4)
49
48
  pry (0.13.1)
50
49
  coderay (~> 1.1)
51
50
  method_source (~> 1.0)
@@ -63,6 +62,9 @@ GEM
63
62
  rspec-expectations (3.9.2)
64
63
  diff-lcs (>= 1.2.0, < 2.0)
65
64
  rspec-support (~> 3.9.0)
65
+ rspec-its (1.3.0)
66
+ rspec-core (>= 3.0.0)
67
+ rspec-expectations (>= 3.0.0)
66
68
  rspec-mocks (3.9.1)
67
69
  diff-lcs (>= 1.2.0, < 2.0)
68
70
  rspec-support (~> 3.9.0)
@@ -71,14 +73,13 @@ GEM
71
73
  thread_safe (0.3.6)
72
74
  typhoeus (1.4.0)
73
75
  ethon (>= 0.9.0)
74
- tzinfo (1.2.8)
75
- thread_safe (~> 0.1)
76
+ tzinfo (2.0.4)
77
+ concurrent-ruby (~> 1.0)
76
78
  vcr (6.0.0)
77
- virtus (1.0.5)
79
+ virtus (2.0.0)
78
80
  axiom-types (~> 0.1)
79
81
  coercible (~> 1.0)
80
82
  descendants_tracker (~> 0.0, >= 0.0.3)
81
- equalizer (~> 0.0, >= 0.0.9)
82
83
  webmock (3.9.1)
83
84
  addressable (>= 2.3.6)
84
85
  crack (>= 0.3.2)
@@ -93,8 +94,9 @@ DEPENDENCIES
93
94
  pry-byebug
94
95
  rake (~> 12.0)
95
96
  rspec (~> 3.0)
97
+ rspec-its
96
98
  vcr
97
99
  webmock
98
100
 
99
101
  BUNDLED WITH
100
- 2.1.4
102
+ 2.2.24
data/README.md CHANGED
@@ -21,8 +21,8 @@ Or install it yourself as:
21
21
  ## Authenticate
22
22
  ```
23
23
  client = BinanceClient.new(
24
- api_key: "your-api-key",
25
- api_secret: "your-api-secret"
24
+ api_key: "your-api-key",
25
+ api_secret: "your-api-secret"
26
26
  )
27
27
  ```
28
28
 
@@ -36,6 +36,7 @@ client.system_status
36
36
  client.account_snapshot
37
37
  client.get_all
38
38
  client.book_ticker(symbol: "BTCETH")
39
+ client.order_book_depth(symbol: "BTCUSDT", limit: 100)
39
40
  ```
40
41
 
41
42
  ## Responses
@@ -31,4 +31,5 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  spec.add_development_dependency "vcr"
33
33
  spec.add_development_dependency "webmock"
34
+ spec.add_development_dependency "rspec-its"
34
35
  end
@@ -6,6 +6,7 @@ module BinanceClient
6
6
  api_action :account_snapshot
7
7
  api_action :get_all
8
8
  api_action :book_ticker
9
+ api_action :order_book_depth
9
10
 
10
11
  attribute :host
11
12
  attribute :api_key
@@ -0,0 +1,7 @@
1
+ module BinanceClient
2
+ class BaseModel
3
+
4
+ include Virtus.model
5
+
6
+ end
7
+ end
@@ -0,0 +1,40 @@
1
+ module BinanceClient
2
+ class OrderBook < BaseModel
3
+
4
+ attribute :body, Hash
5
+ attribute(:last_update_id, Integer, {
6
+ lazy: true,
7
+ default: :default_last_update_id,
8
+ })
9
+ attribute(:bids, Array[BinanceClient::OrderBookEntry], {
10
+ lazy: true,
11
+ default: :default_bids,
12
+ })
13
+ attribute(:asks, Array[BinanceClient::OrderBookEntry], {
14
+ lazy: true,
15
+ default: :default_asks,
16
+ })
17
+
18
+ def default_last_update_id
19
+ body["lastUpdateId"]
20
+ end
21
+
22
+ def default_bids
23
+ _entries_from body["bids"]
24
+ end
25
+
26
+ def default_asks
27
+ _entries_from body["asks"]
28
+ end
29
+
30
+ private
31
+
32
+ def _entries_from(array)
33
+ array.map do |raw_entry|
34
+ price, quantity = raw_entry
35
+ OrderBookEntry.new(price: price, quantity: quantity)
36
+ end
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,8 @@
1
+ module BinanceClient
2
+ class OrderBookEntry < BaseModel
3
+
4
+ attribute :price, BigDecimal
5
+ attribute :quantity, BigDecimal
6
+
7
+ end
8
+ end
@@ -0,0 +1,18 @@
1
+ module BinanceClient
2
+ class OrderBookDepthRequest < BaseRequest
3
+
4
+ attribute :symbol, String
5
+ attribute :limit, Integer
6
+
7
+ def path
8
+ "/api/v3/depth"
9
+ end
10
+
11
+ def params
12
+ h = {symbol: symbol}
13
+ h[:limit] = limit if not limit.nil?
14
+ h.to_query
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ module BinanceClient
2
+ class OrderBookDepthResponse < BaseResponse
3
+
4
+ attribute(:order_book, BinanceClient::OrderBook, {
5
+ lazy: true,
6
+ default: :default_order_book,
7
+ })
8
+
9
+ def default_order_book
10
+ OrderBook.new(body: body)
11
+ end
12
+
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module BinanceClient
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -7,16 +7,22 @@ require "openssl"
7
7
 
8
8
  require "binance_client/client"
9
9
 
10
+ require "binance_client/models/base_model"
11
+ require "binance_client/models/order_book_entry"
12
+ require "binance_client/models/order_book"
13
+
10
14
  require "binance_client/requests/base_request"
11
15
  require "binance_client/responses/base_response"
12
16
  require "binance_client/requests/system_status_request"
13
17
  require "binance_client/requests/account_snapshot_request"
14
18
  require "binance_client/requests/get_all_request"
15
19
  require "binance_client/requests/book_ticker_request"
20
+ require "binance_client/requests/order_book_depth_request"
16
21
  require "binance_client/responses/system_status_response"
17
22
  require "binance_client/responses/account_snapshot_response"
18
23
  require "binance_client/responses/get_all_response"
19
24
  require "binance_client/responses/book_ticker_response"
25
+ require "binance_client/responses/order_book_depth_response"
20
26
 
21
27
  module BinanceClient
22
28
  class Error < StandardError; end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: binance_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AJ Villalobos
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-02 00:00:00.000000000 Z
11
+ date: 2021-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: api_client_base
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-its
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: Ruby wrapper for Binance API
84
98
  email:
85
99
  - hi@ajvillalobos.com
@@ -102,15 +116,20 @@ files:
102
116
  - binance_client.gemspec
103
117
  - lib/binance_client.rb
104
118
  - lib/binance_client/client.rb
119
+ - lib/binance_client/models/base_model.rb
120
+ - lib/binance_client/models/order_book.rb
121
+ - lib/binance_client/models/order_book_entry.rb
105
122
  - lib/binance_client/requests/account_snapshot_request.rb
106
123
  - lib/binance_client/requests/base_request.rb
107
124
  - lib/binance_client/requests/book_ticker_request.rb
108
125
  - lib/binance_client/requests/get_all_request.rb
126
+ - lib/binance_client/requests/order_book_depth_request.rb
109
127
  - lib/binance_client/requests/system_status_request.rb
110
128
  - lib/binance_client/responses/account_snapshot_response.rb
111
129
  - lib/binance_client/responses/base_response.rb
112
130
  - lib/binance_client/responses/book_ticker_response.rb
113
131
  - lib/binance_client/responses/get_all_response.rb
132
+ - lib/binance_client/responses/order_book_depth_response.rb
114
133
  - lib/binance_client/responses/system_status_response.rb
115
134
  - lib/binance_client/version.rb
116
135
  homepage: https://github.com/bloom-solutions/binance_client-ruby
@@ -135,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
154
  - !ruby/object:Gem::Version
136
155
  version: '0'
137
156
  requirements: []
138
- rubygems_version: 3.0.8
157
+ rubygems_version: 3.1.6
139
158
  signing_key:
140
159
  specification_version: 4
141
160
  summary: Ruby wrapper for Binance API