binance_client 0.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +31 -0
- data/CHANGELOG.md +33 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +43 -23
- data/README.md +27 -4
- data/binance_client.gemspec +8 -6
- data/lib/binance_client/client.rb +3 -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/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 -11
- data/lib/binance_client/requests/book_ticker_request.rb +13 -0
- data/lib/binance_client/requests/get_all_request.rb +2 -12
- 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/responses/base_response.rb +18 -1
- data/lib/binance_client/responses/book_ticker_response.rb +4 -0
- data/lib/binance_client/responses/get_all_response.rb +0 -14
- 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/version.rb +1 -1
- data/lib/binance_client.rb +12 -0
- metadata +55 -15
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65dba4f920f7c9e017d74cee2c972ae54af6f731faa17c6eb15c9602061e0bb7
|
4
|
+
data.tar.gz: 0aa2e07fac3321d91513d0ab3904e80f09351b538507d7b915cf20145166f13f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e72bc48d33af094253cbbe395f9bf8f6d67343a7bcc8cf912e69740e4733c4161f7a1d06fc4755f1ff236f214b8026c1f896b360b99204e9338b18c02e95b906
|
7
|
+
data.tar.gz: 43f1d01d8a1ac0ab5fd540f13933e4d5cd17d34f063ab1dc924372a0a94e74599c4672fbeb411e6378c97f86182eb61a46a8ee3285c1838f98ce11d17b3706cd
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ master ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ master ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@v2
|
23
|
+
- uses: actions/setup-ruby@v1
|
24
|
+
with:
|
25
|
+
ruby-version: '2.7'
|
26
|
+
- name: Install dependencies
|
27
|
+
run: bundle install
|
28
|
+
- name: Setup config
|
29
|
+
run: cp spec/config.yml{.sample,}
|
30
|
+
- name: Run tests
|
31
|
+
run: bundle exec rspec
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [1.2.0] - 2021-11-26
|
8
|
+
### Added
|
9
|
+
- Allow easy access to the `used_weight` header in a response by calling `#used_weight(interval)`
|
10
|
+
- `#sub_account_assets` to get the assets of a sub-account
|
11
|
+
- `#body_code` to return the value of "code" in the body, if it exists
|
12
|
+
- `#message` to return the value of "message" in the body, if it exists
|
13
|
+
|
14
|
+
## [1.1.0]
|
15
|
+
### Added
|
16
|
+
- `order_book_depth` (`/api/v3/depth`) to get a snapshot of the order book
|
17
|
+
|
18
|
+
## [1.0.0]
|
19
|
+
### Fixed
|
20
|
+
- Avoid "Signature for this request is not valid" errors by using the same timestamp
|
21
|
+
- Remove pry as a development dependency
|
22
|
+
|
23
|
+
## [0.2.0] - 2020-09-14
|
24
|
+
### Added
|
25
|
+
|
26
|
+
- [enable vcr for other tests](/../../commit/aaf2fbb))
|
27
|
+
- [add book_ticker endpoint](/../../commit/bc7c896))
|
28
|
+
- [added get_all endpoint](/../../commit/b22fa3f))
|
29
|
+
- [add account_snapshot endpoint](/../../commit/e64826a))
|
30
|
+
- [add system_status endpoint](/../../commit/fbc3c36))
|
31
|
+
|
32
|
+
### Fixed
|
33
|
+
- [ignore non deterministic part of the url](/../../commit/647a822))
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,21 +1,23 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
binance_client
|
4
|
+
binance_client (1.2.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.
|
18
|
-
|
14
|
+
i18n (>= 1.6, < 2)
|
15
|
+
minitest (>= 5.1)
|
16
|
+
tzinfo (~> 2.0)
|
17
|
+
zeitwerk (~> 2.3)
|
18
|
+
addressable (2.7.0)
|
19
|
+
public_suffix (>= 2.0.2, < 5.0)
|
20
|
+
api_client_base (1.11.0)
|
19
21
|
activesupport (>= 3.0)
|
20
22
|
gem_config (>= 0.3.1)
|
21
23
|
virtus (>= 1.0)
|
@@ -23,26 +25,33 @@ GEM
|
|
23
25
|
descendants_tracker (~> 0.0.4)
|
24
26
|
ice_nine (~> 0.11.0)
|
25
27
|
thread_safe (~> 0.3, >= 0.3.1)
|
28
|
+
byebug (11.1.3)
|
26
29
|
coderay (1.1.3)
|
27
30
|
coercible (1.0.0)
|
28
31
|
descendants_tracker (~> 0.0.1)
|
29
|
-
concurrent-ruby (1.1.
|
32
|
+
concurrent-ruby (1.1.9)
|
33
|
+
crack (0.4.3)
|
34
|
+
safe_yaml (~> 1.0.0)
|
30
35
|
descendants_tracker (0.0.4)
|
31
36
|
thread_safe (~> 0.3, >= 0.3.1)
|
32
37
|
diff-lcs (1.4.4)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
ffi (1.13.1)
|
38
|
+
ethon (0.15.0)
|
39
|
+
ffi (>= 1.15.0)
|
40
|
+
ffi (1.15.4)
|
37
41
|
gem_config (0.3.2)
|
38
|
-
|
42
|
+
hashdiff (1.0.1)
|
43
|
+
i18n (1.8.11)
|
39
44
|
concurrent-ruby (~> 1.0)
|
40
45
|
ice_nine (0.11.2)
|
41
46
|
method_source (1.0.0)
|
42
|
-
minitest (5.14.
|
47
|
+
minitest (5.14.4)
|
43
48
|
pry (0.13.1)
|
44
49
|
coderay (~> 1.1)
|
45
50
|
method_source (~> 1.0)
|
51
|
+
pry-byebug (3.9.0)
|
52
|
+
byebug (~> 11.0)
|
53
|
+
pry (~> 0.13.0)
|
54
|
+
public_suffix (4.0.6)
|
46
55
|
rake (12.3.3)
|
47
56
|
rspec (3.9.0)
|
48
57
|
rspec-core (~> 3.9.0)
|
@@ -53,30 +62,41 @@ GEM
|
|
53
62
|
rspec-expectations (3.9.2)
|
54
63
|
diff-lcs (>= 1.2.0, < 2.0)
|
55
64
|
rspec-support (~> 3.9.0)
|
65
|
+
rspec-its (1.3.0)
|
66
|
+
rspec-core (>= 3.0.0)
|
67
|
+
rspec-expectations (>= 3.0.0)
|
56
68
|
rspec-mocks (3.9.1)
|
57
69
|
diff-lcs (>= 1.2.0, < 2.0)
|
58
70
|
rspec-support (~> 3.9.0)
|
59
71
|
rspec-support (3.9.3)
|
72
|
+
safe_yaml (1.0.5)
|
60
73
|
thread_safe (0.3.6)
|
61
74
|
typhoeus (1.4.0)
|
62
75
|
ethon (>= 0.9.0)
|
63
|
-
tzinfo (
|
64
|
-
|
65
|
-
|
76
|
+
tzinfo (2.0.4)
|
77
|
+
concurrent-ruby (~> 1.0)
|
78
|
+
vcr (6.0.0)
|
79
|
+
virtus (2.0.0)
|
66
80
|
axiom-types (~> 0.1)
|
67
81
|
coercible (~> 1.0)
|
68
82
|
descendants_tracker (~> 0.0, >= 0.0.3)
|
69
|
-
|
70
|
-
|
83
|
+
webmock (3.9.1)
|
84
|
+
addressable (>= 2.3.6)
|
85
|
+
crack (>= 0.3.2)
|
86
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
87
|
+
zeitwerk (2.5.1)
|
71
88
|
|
72
89
|
PLATFORMS
|
73
90
|
ruby
|
74
91
|
|
75
92
|
DEPENDENCIES
|
76
|
-
binance_client
|
77
|
-
pry
|
93
|
+
binance_client!
|
94
|
+
pry-byebug
|
78
95
|
rake (~> 12.0)
|
79
96
|
rspec (~> 3.0)
|
97
|
+
rspec-its
|
98
|
+
vcr
|
99
|
+
webmock
|
80
100
|
|
81
101
|
BUNDLED WITH
|
82
|
-
2.
|
102
|
+
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
|
|
@@ -35,18 +35,41 @@ We provide one method per API endpoint.
|
|
35
35
|
client.system_status
|
36
36
|
client.account_snapshot
|
37
37
|
client.get_all
|
38
|
+
client.book_ticker(symbol: "BTCETH")
|
39
|
+
client.order_book_depth(symbol: "BTCUSDT", limit: 100)
|
38
40
|
```
|
39
41
|
|
40
42
|
## Responses
|
41
43
|
The default representation of response data is a JSON hash
|
42
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.after_request = DoSomethingAfterBinanceRequest
|
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 DoSomethingAfterBinanceRequest
|
56
|
+
|
57
|
+
def self.call(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
|
+
```
|
43
66
|
|
44
67
|
## Development
|
45
68
|
Edit the `config.yml.sample` with your own credentials for testing
|
46
69
|
|
47
70
|
## Contributing
|
48
71
|
|
49
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
72
|
+
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).
|
50
73
|
|
51
74
|
|
52
75
|
## License
|
@@ -55,4 +78,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
55
78
|
|
56
79
|
## Code of Conduct
|
57
80
|
|
58
|
-
Everyone interacting in the BinanceClient project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
81
|
+
Everyone interacting in the BinanceClient project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/bloom-solutions/binance_client/blob/master/CODE_OF_CONDUCT.md).
|
data/binance_client.gemspec
CHANGED
@@ -8,13 +8,13 @@ Gem::Specification.new do |spec|
|
|
8
8
|
|
9
9
|
spec.summary = "Ruby wrapper for Binance API"
|
10
10
|
spec.description = "Ruby wrapper for Binance API"
|
11
|
-
spec.homepage = "https://github.com/
|
11
|
+
spec.homepage = "https://github.com/bloom-solutions/binance_client-ruby"
|
12
12
|
spec.license = "MIT"
|
13
13
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
14
|
|
15
15
|
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
-
spec.metadata["source_code_uri"] = "https://github.com/
|
17
|
-
spec.metadata["changelog_uri"] = "https://github.com/
|
16
|
+
spec.metadata["source_code_uri"] = "https://github.com/bloom-solutions/binance_client-ruby"
|
17
|
+
spec.metadata["changelog_uri"] = "https://github.com/bloom-solutions/binance_client-ruby/CHANGELOG.md"
|
18
18
|
|
19
19
|
# Specify which files should be added to the gem when it is released.
|
20
20
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -25,9 +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
|
-
|
32
|
-
spec.add_development_dependency "
|
31
|
+
|
32
|
+
spec.add_development_dependency "vcr"
|
33
|
+
spec.add_development_dependency "webmock"
|
34
|
+
spec.add_development_dependency "rspec-its"
|
33
35
|
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,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
|
@@ -1,20 +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
|
-
"timestamp=#{timestamp}"
|
11
|
-
end
|
12
|
-
|
13
|
-
def params
|
14
|
-
[
|
15
|
-
query,
|
16
|
-
"signature=#{signature(query)}"
|
17
|
-
].join("&")
|
18
|
-
end
|
19
9
|
end
|
20
|
-
end
|
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
|
@@ -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
|
@@ -1,18 +1,4 @@
|
|
1
1
|
module BinanceClient
|
2
2
|
class GetAllResponse < BaseResponse
|
3
|
-
attribute :body, Object, default: :default_body
|
4
|
-
|
5
|
-
private
|
6
|
-
|
7
|
-
def default_body
|
8
|
-
payload = {}
|
9
|
-
parsed_body = JSON.parse(raw_response.body)
|
10
|
-
|
11
|
-
parsed_body.map do |coin_details|
|
12
|
-
payload[coin_details["coin"]] = coin_details
|
13
|
-
end
|
14
|
-
|
15
|
-
payload
|
16
|
-
end
|
17
3
|
end
|
18
4
|
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,14 +7,26 @@ 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
|
+
|
10
15
|
require "binance_client/requests/base_request"
|
16
|
+
require "binance_client/requests/authenticated_base_request"
|
11
17
|
require "binance_client/responses/base_response"
|
12
18
|
require "binance_client/requests/system_status_request"
|
13
19
|
require "binance_client/requests/account_snapshot_request"
|
14
20
|
require "binance_client/requests/get_all_request"
|
21
|
+
require "binance_client/requests/book_ticker_request"
|
22
|
+
require "binance_client/requests/order_book_depth_request"
|
23
|
+
require "binance_client/requests/sub_account_assets_request"
|
15
24
|
require "binance_client/responses/system_status_response"
|
16
25
|
require "binance_client/responses/account_snapshot_response"
|
17
26
|
require "binance_client/responses/get_all_response"
|
27
|
+
require "binance_client/responses/book_ticker_response"
|
28
|
+
require "binance_client/responses/order_book_depth_response"
|
29
|
+
require "binance_client/responses/sub_account_assets_response"
|
18
30
|
|
19
31
|
module BinanceClient
|
20
32
|
class Error < StandardError; end
|
metadata
CHANGED
@@ -1,17 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: binance_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AJ Villalobos
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: api_client_base
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - ">="
|
@@ -25,7 +39,7 @@ dependencies:
|
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
42
|
+
name: typhoeus
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - ">="
|
@@ -39,13 +53,27 @@ dependencies:
|
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
56
|
+
name: vcr
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
61
|
version: '0'
|
48
|
-
type: :
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
49
77
|
prerelease: false
|
50
78
|
version_requirements: !ruby/object:Gem::Requirement
|
51
79
|
requirements:
|
@@ -53,7 +81,7 @@ dependencies:
|
|
53
81
|
- !ruby/object:Gem::Version
|
54
82
|
version: '0'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
84
|
+
name: rspec-its
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
58
86
|
requirements:
|
59
87
|
- - ">="
|
@@ -73,9 +101,10 @@ executables: []
|
|
73
101
|
extensions: []
|
74
102
|
extra_rdoc_files: []
|
75
103
|
files:
|
104
|
+
- ".github/workflows/ruby.yml"
|
76
105
|
- ".gitignore"
|
77
106
|
- ".rspec"
|
78
|
-
-
|
107
|
+
- CHANGELOG.md
|
79
108
|
- CODE_OF_CONDUCT.md
|
80
109
|
- Gemfile
|
81
110
|
- Gemfile.lock
|
@@ -87,23 +116,34 @@ files:
|
|
87
116
|
- binance_client.gemspec
|
88
117
|
- lib/binance_client.rb
|
89
118
|
- lib/binance_client/client.rb
|
119
|
+
- lib/binance_client/models/asset_balance.rb
|
120
|
+
- lib/binance_client/models/base_model.rb
|
121
|
+
- lib/binance_client/models/order_book.rb
|
122
|
+
- lib/binance_client/models/order_book_entry.rb
|
90
123
|
- lib/binance_client/requests/account_snapshot_request.rb
|
124
|
+
- lib/binance_client/requests/authenticated_base_request.rb
|
91
125
|
- lib/binance_client/requests/base_request.rb
|
126
|
+
- lib/binance_client/requests/book_ticker_request.rb
|
92
127
|
- lib/binance_client/requests/get_all_request.rb
|
128
|
+
- lib/binance_client/requests/order_book_depth_request.rb
|
129
|
+
- lib/binance_client/requests/sub_account_assets_request.rb
|
93
130
|
- lib/binance_client/requests/system_status_request.rb
|
94
131
|
- lib/binance_client/responses/account_snapshot_response.rb
|
95
132
|
- lib/binance_client/responses/base_response.rb
|
133
|
+
- lib/binance_client/responses/book_ticker_response.rb
|
96
134
|
- lib/binance_client/responses/get_all_response.rb
|
135
|
+
- lib/binance_client/responses/order_book_depth_response.rb
|
136
|
+
- lib/binance_client/responses/sub_account_assets_response.rb
|
97
137
|
- lib/binance_client/responses/system_status_response.rb
|
98
138
|
- lib/binance_client/version.rb
|
99
|
-
homepage: https://github.com/
|
139
|
+
homepage: https://github.com/bloom-solutions/binance_client-ruby
|
100
140
|
licenses:
|
101
141
|
- MIT
|
102
142
|
metadata:
|
103
|
-
homepage_uri: https://github.com/
|
104
|
-
source_code_uri: https://github.com/
|
105
|
-
changelog_uri: https://github.com/
|
106
|
-
post_install_message:
|
143
|
+
homepage_uri: https://github.com/bloom-solutions/binance_client-ruby
|
144
|
+
source_code_uri: https://github.com/bloom-solutions/binance_client-ruby
|
145
|
+
changelog_uri: https://github.com/bloom-solutions/binance_client-ruby/CHANGELOG.md
|
146
|
+
post_install_message:
|
107
147
|
rdoc_options: []
|
108
148
|
require_paths:
|
109
149
|
- lib
|
@@ -118,8 +158,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
158
|
- !ruby/object:Gem::Version
|
119
159
|
version: '0'
|
120
160
|
requirements: []
|
121
|
-
rubygems_version: 3.1.
|
122
|
-
signing_key:
|
161
|
+
rubygems_version: 3.1.6
|
162
|
+
signing_key:
|
123
163
|
specification_version: 4
|
124
164
|
summary: Ruby wrapper for Binance API
|
125
165
|
test_files: []
|