binance_client 0.2.0 → 1.3.0
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 +4 -4
- data/.github/workflows/ruby.yml +31 -0
- data/CHANGELOG.md +37 -18
- data/Gemfile +1 -0
- data/Gemfile.lock +28 -22
- data/README.md +26 -4
- data/binance_client.gemspec +6 -6
- data/lib/binance_client/client.rb +4 -1
- 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/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/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 +11 -0
- metadata +27 -18
- 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: 52c8b1596a4976bc9b6e2743fad40d6e33d050f6a614bcb550128ce29bb97d00
|
|
4
|
+
data.tar.gz: 2cb12b4ad491d438303a745e357793f4c2d9df97d66c05fd59226f2649e7b492
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cd519eeaff647220d99d6abea75054cc1eae2fd2dea9f6733d44afb4c40977957aeb74e8720bda35f5d159fff28d4092a0bb1c6fcddc3995bdc8bb84d5a4ccda
|
|
7
|
+
data.tar.gz: 0d4570d268372084d100619469064d6ae5f364e63b99d6c0063f6bb4b68f1b6dad84a94bccd15d1308361a7bfe72371791e2a27f5f3a97465217f200f076a931
|
|
@@ -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
CHANGED
|
@@ -1,18 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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.3.0] - 2021-11-29
|
|
8
|
+
### Added
|
|
9
|
+
- Add proxy support
|
|
10
|
+
|
|
11
|
+
## [1.2.0] - 2021-11-26
|
|
12
|
+
### Added
|
|
13
|
+
- Allow easy access to the `used_weight` header in a response by calling `#used_weight(interval)`
|
|
14
|
+
- `#sub_account_assets` to get the assets of a sub-account
|
|
15
|
+
- `#body_code` to return the value of "code" in the body, if it exists
|
|
16
|
+
- `#message` to return the value of "message" in the body, if it exists
|
|
17
|
+
|
|
18
|
+
## [1.1.0]
|
|
19
|
+
### Added
|
|
20
|
+
- `order_book_depth` (`/api/v3/depth`) to get a snapshot of the order book
|
|
21
|
+
|
|
22
|
+
## [1.0.0]
|
|
23
|
+
### Fixed
|
|
24
|
+
- Avoid "Signature for this request is not valid" errors by using the same timestamp
|
|
25
|
+
- Remove pry as a development dependency
|
|
26
|
+
|
|
27
|
+
## [0.2.0] - 2020-09-14
|
|
28
|
+
### Added
|
|
29
|
+
|
|
30
|
+
- [enable vcr for other tests](/../../commit/aaf2fbb))
|
|
31
|
+
- [add book_ticker endpoint](/../../commit/bc7c896))
|
|
32
|
+
- [added get_all endpoint](/../../commit/b22fa3f))
|
|
33
|
+
- [add account_snapshot endpoint](/../../commit/e64826a))
|
|
34
|
+
- [add system_status endpoint](/../../commit/fbc3c36))
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
- [ignore non deterministic part of the url](/../../commit/647a822))
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
binance_client (
|
|
4
|
+
binance_client (1.3.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)
|
|
@@ -25,29 +25,32 @@ GEM
|
|
|
25
25
|
descendants_tracker (~> 0.0.4)
|
|
26
26
|
ice_nine (~> 0.11.0)
|
|
27
27
|
thread_safe (~> 0.3, >= 0.3.1)
|
|
28
|
+
byebug (11.1.3)
|
|
28
29
|
coderay (1.1.3)
|
|
29
30
|
coercible (1.0.0)
|
|
30
31
|
descendants_tracker (~> 0.0.1)
|
|
31
|
-
concurrent-ruby (1.1.
|
|
32
|
+
concurrent-ruby (1.1.9)
|
|
32
33
|
crack (0.4.3)
|
|
33
34
|
safe_yaml (~> 1.0.0)
|
|
34
35
|
descendants_tracker (0.0.4)
|
|
35
36
|
thread_safe (~> 0.3, >= 0.3.1)
|
|
36
37
|
diff-lcs (1.4.4)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
ffi (1.13.1)
|
|
38
|
+
ethon (0.15.0)
|
|
39
|
+
ffi (>= 1.15.0)
|
|
40
|
+
ffi (1.15.4)
|
|
41
41
|
gem_config (0.3.2)
|
|
42
42
|
hashdiff (1.0.1)
|
|
43
|
-
i18n (1.8.
|
|
43
|
+
i18n (1.8.11)
|
|
44
44
|
concurrent-ruby (~> 1.0)
|
|
45
45
|
ice_nine (0.11.2)
|
|
46
46
|
method_source (1.0.0)
|
|
47
|
-
minitest (5.14.
|
|
47
|
+
minitest (5.14.4)
|
|
48
48
|
pry (0.13.1)
|
|
49
49
|
coderay (~> 1.1)
|
|
50
50
|
method_source (~> 1.0)
|
|
51
|
+
pry-byebug (3.9.0)
|
|
52
|
+
byebug (~> 11.0)
|
|
53
|
+
pry (~> 0.13.0)
|
|
51
54
|
public_suffix (4.0.6)
|
|
52
55
|
rake (12.3.3)
|
|
53
56
|
rspec (3.9.0)
|
|
@@ -59,6 +62,9 @@ GEM
|
|
|
59
62
|
rspec-expectations (3.9.2)
|
|
60
63
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
61
64
|
rspec-support (~> 3.9.0)
|
|
65
|
+
rspec-its (1.3.0)
|
|
66
|
+
rspec-core (>= 3.0.0)
|
|
67
|
+
rspec-expectations (>= 3.0.0)
|
|
62
68
|
rspec-mocks (3.9.1)
|
|
63
69
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
64
70
|
rspec-support (~> 3.9.0)
|
|
@@ -67,30 +73,30 @@ GEM
|
|
|
67
73
|
thread_safe (0.3.6)
|
|
68
74
|
typhoeus (1.4.0)
|
|
69
75
|
ethon (>= 0.9.0)
|
|
70
|
-
tzinfo (
|
|
71
|
-
|
|
76
|
+
tzinfo (2.0.4)
|
|
77
|
+
concurrent-ruby (~> 1.0)
|
|
72
78
|
vcr (6.0.0)
|
|
73
|
-
virtus (
|
|
79
|
+
virtus (2.0.0)
|
|
74
80
|
axiom-types (~> 0.1)
|
|
75
81
|
coercible (~> 1.0)
|
|
76
82
|
descendants_tracker (~> 0.0, >= 0.0.3)
|
|
77
|
-
equalizer (~> 0.0, >= 0.0.9)
|
|
78
83
|
webmock (3.9.1)
|
|
79
84
|
addressable (>= 2.3.6)
|
|
80
85
|
crack (>= 0.3.2)
|
|
81
86
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
82
|
-
zeitwerk (2.
|
|
87
|
+
zeitwerk (2.5.1)
|
|
83
88
|
|
|
84
89
|
PLATFORMS
|
|
85
90
|
ruby
|
|
86
91
|
|
|
87
92
|
DEPENDENCIES
|
|
88
93
|
binance_client!
|
|
89
|
-
pry
|
|
94
|
+
pry-byebug
|
|
90
95
|
rake (~> 12.0)
|
|
91
96
|
rspec (~> 3.0)
|
|
97
|
+
rspec-its
|
|
92
98
|
vcr
|
|
93
99
|
webmock
|
|
94
100
|
|
|
95
101
|
BUNDLED WITH
|
|
96
|
-
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
|
|
|
@@ -36,18 +36,40 @@ 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
|
|
|
48
70
|
## Contributing
|
|
49
71
|
|
|
50
|
-
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).
|
|
51
73
|
|
|
52
74
|
|
|
53
75
|
## License
|
|
@@ -56,4 +78,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
|
56
78
|
|
|
57
79
|
## Code of Conduct
|
|
58
80
|
|
|
59
|
-
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,11 +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 "pry"
|
|
31
|
+
|
|
33
32
|
spec.add_development_dependency "vcr"
|
|
34
33
|
spec.add_development_dependency "webmock"
|
|
34
|
+
spec.add_development_dependency "rspec-its"
|
|
35
35
|
end
|
|
@@ -6,15 +6,18 @@ 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]
|
|
9
11
|
|
|
10
12
|
attribute :host
|
|
11
13
|
attribute :api_key
|
|
12
14
|
attribute :api_secret
|
|
15
|
+
attribute :proxy
|
|
13
16
|
|
|
14
17
|
private
|
|
15
18
|
|
|
16
19
|
def default_opts
|
|
17
|
-
{host: host, api_key: api_key, api_secret: api_secret}
|
|
20
|
+
{host: host, api_key: api_key, api_secret: api_secret, proxy: proxy}
|
|
18
21
|
end
|
|
19
22
|
end
|
|
20
23
|
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
|
|
@@ -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,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"
|
|
15
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"
|
|
16
24
|
require "binance_client/responses/system_status_response"
|
|
17
25
|
require "binance_client/responses/account_snapshot_response"
|
|
18
26
|
require "binance_client/responses/get_all_response"
|
|
19
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"
|
|
20
30
|
|
|
21
31
|
module BinanceClient
|
|
22
32
|
class Error < StandardError; end
|
|
@@ -29,5 +39,6 @@ module BinanceClient
|
|
|
29
39
|
has :host, classes: String, default: DEFAULT_HOST
|
|
30
40
|
has :api_key, classes: String
|
|
31
41
|
has :api_secret, classes: String
|
|
42
|
+
has :proxy
|
|
32
43
|
end
|
|
33
44
|
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:
|
|
4
|
+
version: 1.3.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-29 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
|
|
@@ -53,7 +53,7 @@ dependencies:
|
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '0'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
56
|
+
name: vcr
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - ">="
|
|
@@ -67,7 +67,7 @@ dependencies:
|
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: '0'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
70
|
+
name: webmock
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
73
|
- - ">="
|
|
@@ -81,7 +81,7 @@ dependencies:
|
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '0'
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
|
-
name:
|
|
84
|
+
name: rspec-its
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
86
86
|
requirements:
|
|
87
87
|
- - ">="
|
|
@@ -101,9 +101,9 @@ executables: []
|
|
|
101
101
|
extensions: []
|
|
102
102
|
extra_rdoc_files: []
|
|
103
103
|
files:
|
|
104
|
+
- ".github/workflows/ruby.yml"
|
|
104
105
|
- ".gitignore"
|
|
105
106
|
- ".rspec"
|
|
106
|
-
- ".travis.yml"
|
|
107
107
|
- CHANGELOG.md
|
|
108
108
|
- CODE_OF_CONDUCT.md
|
|
109
109
|
- Gemfile
|
|
@@ -116,25 +116,34 @@ files:
|
|
|
116
116
|
- binance_client.gemspec
|
|
117
117
|
- lib/binance_client.rb
|
|
118
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
|
|
119
123
|
- lib/binance_client/requests/account_snapshot_request.rb
|
|
124
|
+
- lib/binance_client/requests/authenticated_base_request.rb
|
|
120
125
|
- lib/binance_client/requests/base_request.rb
|
|
121
126
|
- lib/binance_client/requests/book_ticker_request.rb
|
|
122
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
|
|
123
130
|
- lib/binance_client/requests/system_status_request.rb
|
|
124
131
|
- lib/binance_client/responses/account_snapshot_response.rb
|
|
125
132
|
- lib/binance_client/responses/base_response.rb
|
|
126
133
|
- lib/binance_client/responses/book_ticker_response.rb
|
|
127
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
|
|
128
137
|
- lib/binance_client/responses/system_status_response.rb
|
|
129
138
|
- lib/binance_client/version.rb
|
|
130
|
-
homepage: https://github.com/
|
|
139
|
+
homepage: https://github.com/bloom-solutions/binance_client-ruby
|
|
131
140
|
licenses:
|
|
132
141
|
- MIT
|
|
133
142
|
metadata:
|
|
134
|
-
homepage_uri: https://github.com/
|
|
135
|
-
source_code_uri: https://github.com/
|
|
136
|
-
changelog_uri: https://github.com/
|
|
137
|
-
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:
|
|
138
147
|
rdoc_options: []
|
|
139
148
|
require_paths:
|
|
140
149
|
- lib
|
|
@@ -149,8 +158,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
149
158
|
- !ruby/object:Gem::Version
|
|
150
159
|
version: '0'
|
|
151
160
|
requirements: []
|
|
152
|
-
rubygems_version: 3.1.
|
|
153
|
-
signing_key:
|
|
161
|
+
rubygems_version: 3.1.6
|
|
162
|
+
signing_key:
|
|
154
163
|
specification_version: 4
|
|
155
164
|
summary: Ruby wrapper for Binance API
|
|
156
165
|
test_files: []
|