binance_client 1.0.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +26 -21
- data/README.md +28 -2
- data/binance_client.gemspec +2 -1
- data/lib/binance_client/client.rb +5 -1
- data/lib/binance_client/factories.rb +13 -0
- data/lib/binance_client/models/asset_balance.rb +21 -0
- data/lib/binance_client/models/base_model.rb +7 -0
- data/lib/binance_client/models/deposit_address.rb +28 -0
- data/lib/binance_client/models/order_book.rb +40 -0
- data/lib/binance_client/models/order_book_entry.rb +8 -0
- data/lib/binance_client/requests/account_snapshot_request.rb +3 -17
- data/lib/binance_client/requests/authenticated_base_request.rb +34 -0
- data/lib/binance_client/requests/base_request.rb +0 -12
- data/lib/binance_client/requests/get_all_request.rb +1 -16
- data/lib/binance_client/requests/order_book_depth_request.rb +18 -0
- data/lib/binance_client/requests/sub_account_assets_request.rb +15 -0
- data/lib/binance_client/requests/sub_account_deposit_address_request.rb +25 -0
- data/lib/binance_client/responses/base_response.rb +18 -1
- data/lib/binance_client/responses/order_book_depth_response.rb +14 -0
- data/lib/binance_client/responses/sub_account_assets_response.rb +16 -0
- data/lib/binance_client/responses/sub_account_deposit_address_response.rb +14 -0
- data/lib/binance_client/version.rb +1 -1
- data/lib/binance_client.rb +14 -0
- metadata +34 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b4624eac956c44c052169d1c6598f527ac24dbee062321dd23525d33cc5fea0
|
4
|
+
data.tar.gz: 3cc4c5a13eedf200f51a218daf89aeb2ad4a8b49607149db8397af47b5c45c02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 416797926140c8928d4db9eb322db9187d3744af4d8c0a9f5090ce1bbedc85edabd4ea2f26b9249591d329d6da01445f38a98f881d12a91d88d3f76349c3cc0f
|
7
|
+
data.tar.gz: 49cec6ad29790c32623484f23ca6986f79d635d738d18da4b3fec3b8a0495696d146380fea9a77f9011930ca2c8bdb7ab2d871f4ea7e1a7efdf7ded25d6b3037
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,26 @@ 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.4.0] - 2021-12-09
|
8
|
+
### Added
|
9
|
+
- Add factories for use in app development
|
10
|
+
- Add `#sub_account_deposit_address`
|
11
|
+
|
12
|
+
## [1.3.0] - 2021-11-29
|
13
|
+
### Added
|
14
|
+
- Add proxy support
|
15
|
+
|
16
|
+
## [1.2.0] - 2021-11-26
|
17
|
+
### Added
|
18
|
+
- Allow easy access to the `used_weight` header in a response by calling `#used_weight(interval)`
|
19
|
+
- `#sub_account_assets` to get the assets of a sub-account
|
20
|
+
- `#body_code` to return the value of "code" in the body, if it exists
|
21
|
+
- `#message` to return the value of "message" in the body, if it exists
|
22
|
+
|
23
|
+
## [1.1.0]
|
24
|
+
### Added
|
25
|
+
- `order_book_depth` (`/api/v3/depth`) to get a snapshot of the order book
|
26
|
+
|
7
27
|
## [1.0.0]
|
8
28
|
### Fixed
|
9
29
|
- Avoid "Signature for this request is not valid" errors by using the same timestamp
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
binance_client (1.
|
4
|
+
binance_client (1.4.0)
|
5
5
|
activesupport
|
6
|
-
api_client_base
|
6
|
+
api_client_base (~> 1.11)
|
7
7
|
typhoeus
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activesupport (6.
|
12
|
+
activesupport (6.1.4.1)
|
13
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
-
i18n (>=
|
15
|
-
minitest (
|
16
|
-
tzinfo (~>
|
17
|
-
zeitwerk (~> 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.
|
20
|
+
api_client_base (1.11.0)
|
21
21
|
activesupport (>= 3.0)
|
22
22
|
gem_config (>= 0.3.1)
|
23
23
|
virtus (>= 1.0)
|
@@ -29,23 +29,24 @@ 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.
|
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
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
ethon (0.15.0)
|
39
|
+
ffi (>= 1.15.0)
|
40
|
+
factory_bot (6.2.0)
|
41
|
+
activesupport (>= 5.0.0)
|
42
|
+
ffi (1.15.4)
|
42
43
|
gem_config (0.3.2)
|
43
44
|
hashdiff (1.0.1)
|
44
|
-
i18n (1.8.
|
45
|
+
i18n (1.8.11)
|
45
46
|
concurrent-ruby (~> 1.0)
|
46
47
|
ice_nine (0.11.2)
|
47
48
|
method_source (1.0.0)
|
48
|
-
minitest (5.14.
|
49
|
+
minitest (5.14.4)
|
49
50
|
pry (0.13.1)
|
50
51
|
coderay (~> 1.1)
|
51
52
|
method_source (~> 1.0)
|
@@ -63,6 +64,9 @@ GEM
|
|
63
64
|
rspec-expectations (3.9.2)
|
64
65
|
diff-lcs (>= 1.2.0, < 2.0)
|
65
66
|
rspec-support (~> 3.9.0)
|
67
|
+
rspec-its (1.3.0)
|
68
|
+
rspec-core (>= 3.0.0)
|
69
|
+
rspec-expectations (>= 3.0.0)
|
66
70
|
rspec-mocks (3.9.1)
|
67
71
|
diff-lcs (>= 1.2.0, < 2.0)
|
68
72
|
rspec-support (~> 3.9.0)
|
@@ -71,30 +75,31 @@ GEM
|
|
71
75
|
thread_safe (0.3.6)
|
72
76
|
typhoeus (1.4.0)
|
73
77
|
ethon (>= 0.9.0)
|
74
|
-
tzinfo (
|
75
|
-
|
78
|
+
tzinfo (2.0.4)
|
79
|
+
concurrent-ruby (~> 1.0)
|
76
80
|
vcr (6.0.0)
|
77
|
-
virtus (
|
81
|
+
virtus (2.0.0)
|
78
82
|
axiom-types (~> 0.1)
|
79
83
|
coercible (~> 1.0)
|
80
84
|
descendants_tracker (~> 0.0, >= 0.0.3)
|
81
|
-
equalizer (~> 0.0, >= 0.0.9)
|
82
85
|
webmock (3.9.1)
|
83
86
|
addressable (>= 2.3.6)
|
84
87
|
crack (>= 0.3.2)
|
85
88
|
hashdiff (>= 0.4.0, < 2.0.0)
|
86
|
-
zeitwerk (2.
|
89
|
+
zeitwerk (2.5.1)
|
87
90
|
|
88
91
|
PLATFORMS
|
89
92
|
ruby
|
90
93
|
|
91
94
|
DEPENDENCIES
|
92
95
|
binance_client!
|
96
|
+
factory_bot
|
93
97
|
pry-byebug
|
94
98
|
rake (~> 12.0)
|
95
99
|
rspec (~> 3.0)
|
100
|
+
rspec-its
|
96
101
|
vcr
|
97
102
|
webmock
|
98
103
|
|
99
104
|
BUNDLED WITH
|
100
|
-
2.
|
105
|
+
2.2.28
|
data/README.md
CHANGED
@@ -21,8 +21,8 @@ Or install it yourself as:
|
|
21
21
|
## Authenticate
|
22
22
|
```
|
23
23
|
client = BinanceClient.new(
|
24
|
-
|
25
|
-
|
24
|
+
api_key: "your-api-key",
|
25
|
+
api_secret: "your-api-secret"
|
26
26
|
)
|
27
27
|
```
|
28
28
|
|
@@ -36,15 +36,41 @@ 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
|
42
43
|
The default representation of response data is a JSON hash
|
43
44
|
|
45
|
+
## Hooks
|
46
|
+
You can set a hook to do application-specific things per request. This is useful when monitoring the rate limits:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
BinanceClient.configuration.after_response = DoSomethingAfterBinanceResponse
|
50
|
+
```
|
51
|
+
|
52
|
+
What you assign can be a proc -- it just needs to respond to `call` and accept the `BinanceClient` response object:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
class DoSomethingAfterBinanceResponse
|
56
|
+
|
57
|
+
def self.call(request, response)
|
58
|
+
one_minute_weight = response.used_weight("1m")
|
59
|
+
if one_minute_weight > 1200
|
60
|
+
Rails.logger.info "Looks like we've hit the request limit!"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
```
|
44
66
|
|
45
67
|
## Development
|
46
68
|
Edit the `config.yml.sample` with your own credentials for testing
|
47
69
|
|
70
|
+
## Factories
|
71
|
+
|
72
|
+
To make testing easier in your app, `require "binance_client/factories"` to get access to factories of the models.
|
73
|
+
|
48
74
|
## Contributing
|
49
75
|
|
50
76
|
Bug reports and pull requests are welcome on GitHub at https://github.com/bloom-solutions/binance_client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/bloom-solutions/binance_client/blob/master/CODE_OF_CONDUCT.md).
|
data/binance_client.gemspec
CHANGED
@@ -25,10 +25,11 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
26
|
spec.require_paths = ["lib"]
|
27
27
|
|
28
|
-
spec.add_dependency "api_client_base"
|
28
|
+
spec.add_dependency "api_client_base", "~> 1.11"
|
29
29
|
spec.add_dependency "activesupport"
|
30
30
|
spec.add_dependency "typhoeus"
|
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,15 +6,19 @@ 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
|
10
|
+
api_action :sub_account_assets, args: [:email]
|
11
|
+
api_action :sub_account_deposit_address, args: [:email, :coin]
|
9
12
|
|
10
13
|
attribute :host
|
11
14
|
attribute :api_key
|
12
15
|
attribute :api_secret
|
16
|
+
attribute :proxy
|
13
17
|
|
14
18
|
private
|
15
19
|
|
16
20
|
def default_opts
|
17
|
-
{host: host, api_key: api_key, api_secret: api_secret}
|
21
|
+
{host: host, api_key: api_key, api_secret: api_secret, proxy: proxy}
|
18
22
|
end
|
19
23
|
end
|
20
24
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
|
3
|
+
factory :binance_client_asset_balance, class: "BinanceClient::AssetBalance" do
|
4
|
+
sequence(:asset) { |n| "ASSET#{n}" }
|
5
|
+
free { rand(10_000) }
|
6
|
+
locked { rand(1_000) }
|
7
|
+
|
8
|
+
initialize_with do
|
9
|
+
new(asset: asset, free: free, locked: locked)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class AssetBalance
|
3
|
+
|
4
|
+
attr_reader :asset
|
5
|
+
|
6
|
+
def initialize(asset:, free:, locked:)
|
7
|
+
@asset = asset
|
8
|
+
@free = free
|
9
|
+
@locked = locked
|
10
|
+
end
|
11
|
+
|
12
|
+
def free
|
13
|
+
@free.to_d
|
14
|
+
end
|
15
|
+
|
16
|
+
def locked
|
17
|
+
@locked.to_d
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class DepositAddress
|
3
|
+
|
4
|
+
def self.new_from_raw(raw_hash)
|
5
|
+
args = raw_hash.each_with_object({}) do |(k, v), h|
|
6
|
+
h[k.underscore] = v
|
7
|
+
end
|
8
|
+
|
9
|
+
self.new(**args)
|
10
|
+
end
|
11
|
+
|
12
|
+
ATTRS = [
|
13
|
+
:address,
|
14
|
+
:coin,
|
15
|
+
:tag,
|
16
|
+
:url,
|
17
|
+
]
|
18
|
+
|
19
|
+
attr_accessor(*ATTRS)
|
20
|
+
|
21
|
+
def initialize(**kwargs)
|
22
|
+
kwargs.each do |attr, value|
|
23
|
+
self.send("#{attr}=", value)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
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
|
@@ -1,28 +1,14 @@
|
|
1
1
|
module BinanceClient
|
2
|
-
class AccountSnapshotRequest <
|
2
|
+
class AccountSnapshotRequest < AuthenticatedBaseRequest
|
3
3
|
private
|
4
4
|
|
5
5
|
def path
|
6
6
|
"/sapi/v1/accountSnapshot"
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
10
|
-
type
|
11
|
-
limit = 30
|
12
|
-
query = query(type: type, limit: limit)
|
13
|
-
|
14
|
-
[
|
15
|
-
query,
|
16
|
-
"signature=#{signature(query)}"
|
17
|
-
].join("&")
|
9
|
+
def params_without_signature
|
10
|
+
{ type: "SPOT", limit: 30 }
|
18
11
|
end
|
19
12
|
|
20
|
-
def query(options={})
|
21
|
-
[
|
22
|
-
"type=#{options[:type]}",
|
23
|
-
"timestamp=#{timestamp}",
|
24
|
-
"limit=#{options[:limit]}",
|
25
|
-
].join("&")
|
26
|
-
end
|
27
13
|
end
|
28
14
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class AuthenticatedBaseRequest < BaseRequest
|
3
|
+
include APIClientBase::Request.module
|
4
|
+
|
5
|
+
def signature
|
6
|
+
OpenSSL::HMAC.hexdigest(
|
7
|
+
OpenSSL::Digest.new("sha256"),
|
8
|
+
api_secret,
|
9
|
+
params_without_signature_with_timestamp.to_query,
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
def signature_hash
|
14
|
+
{ signature: signature }
|
15
|
+
end
|
16
|
+
|
17
|
+
def timestamp
|
18
|
+
@timestamp ||= DateTime.now.strftime("%Q")
|
19
|
+
end
|
20
|
+
|
21
|
+
def params
|
22
|
+
params_without_signature_with_timestamp.merge(signature_hash).to_query
|
23
|
+
end
|
24
|
+
|
25
|
+
def params_without_signature_with_timestamp
|
26
|
+
params_without_signature.merge(timestamp: timestamp)
|
27
|
+
end
|
28
|
+
|
29
|
+
def params_without_signature
|
30
|
+
{}
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -4,7 +4,6 @@ module BinanceClient
|
|
4
4
|
|
5
5
|
attribute :api_key, String
|
6
6
|
attribute :api_secret, String
|
7
|
-
attribute :timestamp, Integer, lazy: true, default: :default_timestamp
|
8
7
|
|
9
8
|
def headers
|
10
9
|
{
|
@@ -13,16 +12,5 @@ module BinanceClient
|
|
13
12
|
}
|
14
13
|
end
|
15
14
|
|
16
|
-
def signature(query)
|
17
|
-
OpenSSL::HMAC.hexdigest(
|
18
|
-
OpenSSL::Digest.new("sha256"),
|
19
|
-
api_secret,
|
20
|
-
query,
|
21
|
-
)
|
22
|
-
end
|
23
|
-
|
24
|
-
def default_timestamp
|
25
|
-
DateTime.now.strftime("%Q")
|
26
|
-
end
|
27
15
|
end
|
28
16
|
end
|
@@ -1,25 +1,10 @@
|
|
1
1
|
module BinanceClient
|
2
|
-
class GetAllRequest <
|
2
|
+
class GetAllRequest < AuthenticatedBaseRequest
|
3
3
|
private
|
4
4
|
|
5
5
|
def path
|
6
6
|
"/sapi/v1/capital/config/getall"
|
7
7
|
end
|
8
8
|
|
9
|
-
def query
|
10
|
-
uri = Addressable::URI.new(query_values: {
|
11
|
-
timestamp: timestamp,
|
12
|
-
})
|
13
|
-
uri.normalized_query
|
14
|
-
end
|
15
|
-
|
16
|
-
def params
|
17
|
-
uri = Addressable::URI.new(query: query)
|
18
|
-
uri.query_values = [
|
19
|
-
uri.query,
|
20
|
-
["signature", signature(query)],
|
21
|
-
]
|
22
|
-
uri.normalized_query
|
23
|
-
end
|
24
9
|
end
|
25
10
|
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,25 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class SubAccountDepositAddressRequest < AuthenticatedBaseRequest
|
3
|
+
|
4
|
+
attribute :email, String
|
5
|
+
attribute :coin, String
|
6
|
+
attribute :network, String
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def path
|
11
|
+
"/sapi/v1/capital/deposit/subAddress"
|
12
|
+
end
|
13
|
+
|
14
|
+
def params_without_signature
|
15
|
+
{
|
16
|
+
email: email,
|
17
|
+
coin: coin,
|
18
|
+
network: network,
|
19
|
+
}.reject do |key, value|
|
20
|
+
value.nil?
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -2,12 +2,29 @@ module BinanceClient
|
|
2
2
|
class BaseResponse
|
3
3
|
include APIClientBase::Response.module
|
4
4
|
|
5
|
-
attribute :body, Object, default: :default_body
|
5
|
+
attribute :body, Object, lazy: true, default: :default_body
|
6
|
+
|
7
|
+
def used_weight(interval)
|
8
|
+
val = header("X-MBX-USED-WEIGHT-#{interval}")
|
9
|
+
return nil if val.nil?
|
10
|
+
val.to_i
|
11
|
+
end
|
12
|
+
|
13
|
+
def message
|
14
|
+
body["message"]
|
15
|
+
end
|
16
|
+
|
17
|
+
def body_code
|
18
|
+
val = body["code"]
|
19
|
+
return nil if val.nil?
|
20
|
+
val.to_i
|
21
|
+
end
|
6
22
|
|
7
23
|
private
|
8
24
|
|
9
25
|
def default_body
|
10
26
|
JSON.parse(raw_response.body)
|
11
27
|
end
|
28
|
+
|
12
29
|
end
|
13
30
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class SubAccountAssetsResponse < BaseResponse
|
3
|
+
|
4
|
+
attribute(:balances, Array[BinanceClient::AssetBalance], {
|
5
|
+
lazy: true,
|
6
|
+
default: :default_balances,
|
7
|
+
})
|
8
|
+
|
9
|
+
def default_balances
|
10
|
+
body["balances"].map do |balance_hash|
|
11
|
+
AssetBalance.new(**balance_hash.symbolize_keys)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
data/lib/binance_client.rb
CHANGED
@@ -7,16 +7,29 @@ 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
|
+
require "binance_client/models/asset_balance"
|
14
|
+
require "binance_client/models/deposit_address"
|
15
|
+
|
10
16
|
require "binance_client/requests/base_request"
|
17
|
+
require "binance_client/requests/authenticated_base_request"
|
11
18
|
require "binance_client/responses/base_response"
|
12
19
|
require "binance_client/requests/system_status_request"
|
13
20
|
require "binance_client/requests/account_snapshot_request"
|
14
21
|
require "binance_client/requests/get_all_request"
|
15
22
|
require "binance_client/requests/book_ticker_request"
|
23
|
+
require "binance_client/requests/order_book_depth_request"
|
24
|
+
require "binance_client/requests/sub_account_assets_request"
|
25
|
+
require "binance_client/requests/sub_account_deposit_address_request"
|
16
26
|
require "binance_client/responses/system_status_response"
|
17
27
|
require "binance_client/responses/account_snapshot_response"
|
18
28
|
require "binance_client/responses/get_all_response"
|
19
29
|
require "binance_client/responses/book_ticker_response"
|
30
|
+
require "binance_client/responses/order_book_depth_response"
|
31
|
+
require "binance_client/responses/sub_account_assets_response"
|
32
|
+
require "binance_client/responses/sub_account_deposit_address_response"
|
20
33
|
|
21
34
|
module BinanceClient
|
22
35
|
class Error < StandardError; end
|
@@ -29,5 +42,6 @@ module BinanceClient
|
|
29
42
|
has :host, classes: String, default: DEFAULT_HOST
|
30
43
|
has :api_key, classes: String
|
31
44
|
has :api_secret, classes: String
|
45
|
+
has :proxy
|
32
46
|
end
|
33
47
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: binance_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.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:
|
11
|
+
date: 2021-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: api_client_base
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1.11'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '1.11'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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,28 @@ files:
|
|
102
116
|
- binance_client.gemspec
|
103
117
|
- lib/binance_client.rb
|
104
118
|
- lib/binance_client/client.rb
|
119
|
+
- lib/binance_client/factories.rb
|
120
|
+
- lib/binance_client/models/asset_balance.rb
|
121
|
+
- lib/binance_client/models/base_model.rb
|
122
|
+
- lib/binance_client/models/deposit_address.rb
|
123
|
+
- lib/binance_client/models/order_book.rb
|
124
|
+
- lib/binance_client/models/order_book_entry.rb
|
105
125
|
- lib/binance_client/requests/account_snapshot_request.rb
|
126
|
+
- lib/binance_client/requests/authenticated_base_request.rb
|
106
127
|
- lib/binance_client/requests/base_request.rb
|
107
128
|
- lib/binance_client/requests/book_ticker_request.rb
|
108
129
|
- lib/binance_client/requests/get_all_request.rb
|
130
|
+
- lib/binance_client/requests/order_book_depth_request.rb
|
131
|
+
- lib/binance_client/requests/sub_account_assets_request.rb
|
132
|
+
- lib/binance_client/requests/sub_account_deposit_address_request.rb
|
109
133
|
- lib/binance_client/requests/system_status_request.rb
|
110
134
|
- lib/binance_client/responses/account_snapshot_response.rb
|
111
135
|
- lib/binance_client/responses/base_response.rb
|
112
136
|
- lib/binance_client/responses/book_ticker_response.rb
|
113
137
|
- lib/binance_client/responses/get_all_response.rb
|
138
|
+
- lib/binance_client/responses/order_book_depth_response.rb
|
139
|
+
- lib/binance_client/responses/sub_account_assets_response.rb
|
140
|
+
- lib/binance_client/responses/sub_account_deposit_address_response.rb
|
114
141
|
- lib/binance_client/responses/system_status_response.rb
|
115
142
|
- lib/binance_client/version.rb
|
116
143
|
homepage: https://github.com/bloom-solutions/binance_client-ruby
|
@@ -135,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
162
|
- !ruby/object:Gem::Version
|
136
163
|
version: '0'
|
137
164
|
requirements: []
|
138
|
-
rubygems_version: 3.
|
165
|
+
rubygems_version: 3.1.6
|
139
166
|
signing_key:
|
140
167
|
specification_version: 4
|
141
168
|
summary: Ruby wrapper for Binance API
|