binance_client 2.0.0 → 2.1.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 +6 -1
- data/Gemfile.lock +1 -1
- data/README.md +3 -4
- data/lib/binance_client/client.rb +2 -0
- data/lib/binance_client/models/deposit.rb +31 -0
- data/lib/binance_client/models/market.rb +53 -0
- data/lib/binance_client/models/market_filter.rb +25 -0
- data/lib/binance_client/models/rate_limit.rb +24 -0
- data/lib/binance_client/requests/exchange_info_request.rb +10 -0
- data/lib/binance_client/requests/sub_account_deposit_history_request.rb +36 -0
- data/lib/binance_client/responses/exchange_info_response.rb +30 -0
- data/lib/binance_client/responses/sub_account_deposit_history_response.rb +11 -0
- data/lib/binance_client/version.rb +1 -1
- data/lib/binance_client.rb +10 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92d03cdb49a0580cae0efce1cbcaf3f908994f2959473801eccfcabb46cd8c1d
|
4
|
+
data.tar.gz: 8eadce8b6bdb99dad54e1e58724c65595f79a843006e13cc0c4618ee5d62bf88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f31e20576e0c83a044f2f59a3e4a5a8bddb0dfce7eab0a73494ef101dbfce4cefee7c3404b004bd3b1d1438f1accd155d151d819d4028405d9c36c2c10a4ab11
|
7
|
+
data.tar.gz: 7f24cd955d6a8e2ca3ab560b0f45900c514f12001e49e5cfcbfd206b49b24ad7a105111dbc1f673b8831f4091d01486fe6a97922ca0ce12c9dd8116cf6635c7d
|
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,12 @@ 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.
|
7
|
+
## [2.1.0]
|
8
|
+
### Added
|
9
|
+
- `exchange_info` endpoint
|
10
|
+
- `sub_account_deposit_history` endpoint
|
11
|
+
|
12
|
+
## [2.0.0]
|
8
13
|
### Changed
|
9
14
|
- Remove `used_weight` from responses
|
10
15
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -39,6 +39,8 @@ client.book_ticker(symbol: "BTCETH")
|
|
39
39
|
client.order_book_depth(symbol: "BTCUSDT", limit: 100)
|
40
40
|
```
|
41
41
|
|
42
|
+
See `spec/acceptance` for all calls.
|
43
|
+
|
42
44
|
## Responses
|
43
45
|
The default representation of response data is a JSON hash
|
44
46
|
|
@@ -55,10 +57,7 @@ What you assign can be a proc -- it just needs to respond to `call` and accept t
|
|
55
57
|
class DoSomethingAfterBinanceResponse
|
56
58
|
|
57
59
|
def self.call(request, response)
|
58
|
-
|
59
|
-
if one_minute_weight > 1200
|
60
|
-
Rails.logger.info "Looks like we've hit the request limit!"
|
61
|
-
end
|
60
|
+
response.used_weights # Ruby hash of the headers of all the possible used weights
|
62
61
|
end
|
63
62
|
|
64
63
|
end
|
@@ -6,10 +6,12 @@ module BinanceClient
|
|
6
6
|
api_action :system_status
|
7
7
|
api_action :account_snapshot
|
8
8
|
api_action :get_all
|
9
|
+
api_action :exchange_info
|
9
10
|
api_action :book_ticker
|
10
11
|
api_action :order_book_depth
|
11
12
|
api_action :sub_account_assets, args: [:email]
|
12
13
|
api_action :sub_account_deposit_address, args: [:email, :coin]
|
14
|
+
api_action :sub_account_deposit_history
|
13
15
|
|
14
16
|
attribute :host
|
15
17
|
attribute :api_key
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class Deposit
|
3
|
+
|
4
|
+
METHODS = %i[
|
5
|
+
sub_account_id
|
6
|
+
address
|
7
|
+
address_tag
|
8
|
+
amount
|
9
|
+
coin
|
10
|
+
insert_time
|
11
|
+
network
|
12
|
+
status
|
13
|
+
tx_id
|
14
|
+
source_address
|
15
|
+
confirm_times
|
16
|
+
].freeze
|
17
|
+
|
18
|
+
attr_reader :raw_hash
|
19
|
+
|
20
|
+
def initialize(raw_hash:)
|
21
|
+
@raw_hash = raw_hash
|
22
|
+
end
|
23
|
+
|
24
|
+
METHODS.each do |method_name|
|
25
|
+
define_method method_name do
|
26
|
+
raw_hash[method_name.to_s.camelcase(:lower)]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class Market < BaseModel
|
3
|
+
|
4
|
+
METHODS = %i[
|
5
|
+
symbol
|
6
|
+
status
|
7
|
+
base_asset
|
8
|
+
base_asset_precision
|
9
|
+
quote_asset
|
10
|
+
quote_precision
|
11
|
+
quote_asset_precision
|
12
|
+
base_commission_precision
|
13
|
+
quote_commission_precision
|
14
|
+
order_types
|
15
|
+
iceberg_allowed
|
16
|
+
oco_allowed
|
17
|
+
quote_order_qty_market_allowed
|
18
|
+
is_spot_trading_allowed
|
19
|
+
is_margin_trading_allowed
|
20
|
+
].freeze
|
21
|
+
|
22
|
+
BOOL_MAP = {
|
23
|
+
iceberg_allowed: :iceberg_allowed?,
|
24
|
+
oco_allowed: :oco_allowed?,
|
25
|
+
quote_order_qty_market_allowed: :quote_order_qty_market_allowed?,
|
26
|
+
is_spot_trading_allowed: :spot_trading_allowed?,
|
27
|
+
is_margin_trading_allowed: :margin_trading_allowed?,
|
28
|
+
}.freeze
|
29
|
+
|
30
|
+
attr_reader :raw_hash
|
31
|
+
|
32
|
+
def initialize(raw_hash:)
|
33
|
+
@raw_hash = raw_hash
|
34
|
+
end
|
35
|
+
|
36
|
+
METHODS.each do |method_name|
|
37
|
+
define_method method_name do
|
38
|
+
raw_hash[method_name.to_s.camelcase(:lower)]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
BOOL_MAP.each do |original_method_name, alias_method_name|
|
43
|
+
alias_method alias_method_name, original_method_name
|
44
|
+
end
|
45
|
+
|
46
|
+
def filters
|
47
|
+
@filters ||= raw_hash["filters"].map do |filter_hash|
|
48
|
+
MarketFilter.new(raw_hash: filter_hash)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class MarketFilter
|
3
|
+
|
4
|
+
attr_reader :raw_hash
|
5
|
+
|
6
|
+
def initialize(raw_hash:)
|
7
|
+
@raw_hash = raw_hash
|
8
|
+
end
|
9
|
+
|
10
|
+
def method_missing(method_name, *args)
|
11
|
+
key = method_name.to_s.camelcase(:lower)
|
12
|
+
super if raw_hash[key].nil?
|
13
|
+
|
14
|
+
self.class.define_method method_name do
|
15
|
+
value = raw_hash[method_name.to_s.camelcase(:lower)]
|
16
|
+
|
17
|
+
value = value.to_d if value =~ /^[\d\.]+$/
|
18
|
+
|
19
|
+
value
|
20
|
+
end
|
21
|
+
send(method_name)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class RateLimit
|
3
|
+
|
4
|
+
METHODS = %i[
|
5
|
+
rate_limit_type
|
6
|
+
interval
|
7
|
+
interval_num
|
8
|
+
limit
|
9
|
+
].freeze
|
10
|
+
|
11
|
+
attr_reader :raw_hash
|
12
|
+
|
13
|
+
def initialize(raw_hash:)
|
14
|
+
@raw_hash = raw_hash
|
15
|
+
end
|
16
|
+
|
17
|
+
METHODS.each do |method_name|
|
18
|
+
define_method method_name do
|
19
|
+
raw_hash[method_name.to_s.camelcase(:lower)]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class SubAccountDepositHistoryRequest < AuthenticatedBaseRequest
|
3
|
+
attribute :sub_account_id, String
|
4
|
+
attribute :start_time, DateTime
|
5
|
+
attribute :end_time, DateTime
|
6
|
+
attribute :coin, String
|
7
|
+
attribute :status, Integer
|
8
|
+
attribute :limit, Integer
|
9
|
+
attribute :offset, Integer
|
10
|
+
|
11
|
+
PARAMS = [
|
12
|
+
:sub_account_id,
|
13
|
+
:start_time,
|
14
|
+
:end_time,
|
15
|
+
:coin,
|
16
|
+
:status,
|
17
|
+
:limit,
|
18
|
+
:offset,
|
19
|
+
].freeze
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def path
|
24
|
+
"/sapi/v1/broker/subAccount/depositHist"
|
25
|
+
end
|
26
|
+
|
27
|
+
def params_without_signature
|
28
|
+
PARAMS.each_with_object({}) do |param, hash|
|
29
|
+
key = param.to_s.camelcase(:lower)
|
30
|
+
value = send(param)
|
31
|
+
value = value.to_i * 1_000 if value.is_a?(DateTime)
|
32
|
+
hash[key] = value
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class ExchangeInfoResponse < BaseResponse
|
3
|
+
|
4
|
+
def timezone
|
5
|
+
body["timezone"]
|
6
|
+
end
|
7
|
+
|
8
|
+
def timezone
|
9
|
+
body["timezone"]
|
10
|
+
end
|
11
|
+
|
12
|
+
def server_time
|
13
|
+
body["serverTime"]
|
14
|
+
end
|
15
|
+
|
16
|
+
def markets
|
17
|
+
@markets ||= body["symbols"].map do |market_hash|
|
18
|
+
Market.new(raw_hash: market_hash)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
alias_method :symbols, :markets
|
22
|
+
|
23
|
+
def rate_limits
|
24
|
+
@rate_limits ||= body["rateLimits"].map do |rate_limit_hash|
|
25
|
+
RateLimit.new(raw_hash: rate_limit_hash)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
data/lib/binance_client.rb
CHANGED
@@ -3,6 +3,8 @@ require "api_client_base"
|
|
3
3
|
require "active_support/core_ext/hash/indifferent_access"
|
4
4
|
require "active_support/core_ext/object/to_query"
|
5
5
|
require "active_support/core_ext/string/inflections"
|
6
|
+
require "active_support/core_ext/date_time"
|
7
|
+
require "active_support/core_ext/integer"
|
6
8
|
require "json"
|
7
9
|
require "openssl"
|
8
10
|
|
@@ -13,25 +15,33 @@ require "binance_client/models/order_book_entry"
|
|
13
15
|
require "binance_client/models/order_book"
|
14
16
|
require "binance_client/models/asset_balance"
|
15
17
|
require "binance_client/models/deposit_address"
|
18
|
+
require "binance_client/models/market"
|
19
|
+
require "binance_client/models/market_filter"
|
20
|
+
require "binance_client/models/rate_limit"
|
21
|
+
require "binance_client/models/deposit"
|
16
22
|
|
17
23
|
require "binance_client/requests/base_request"
|
18
24
|
require "binance_client/requests/authenticated_base_request"
|
19
25
|
require "binance_client/responses/base_response"
|
20
26
|
require "binance_client/requests/system_status_request"
|
21
27
|
require "binance_client/requests/account_snapshot_request"
|
28
|
+
require "binance_client/requests/exchange_info_request"
|
22
29
|
require "binance_client/requests/get_all_request"
|
23
30
|
require "binance_client/requests/book_ticker_request"
|
24
31
|
require "binance_client/requests/order_book_depth_request"
|
25
32
|
require "binance_client/requests/sub_account_assets_request"
|
26
33
|
require "binance_client/requests/sub_account_deposit_address_request"
|
34
|
+
require "binance_client/requests/sub_account_deposit_history_request"
|
27
35
|
require "binance_client/requests/account_request"
|
28
36
|
require "binance_client/responses/system_status_response"
|
29
37
|
require "binance_client/responses/account_snapshot_response"
|
30
38
|
require "binance_client/responses/get_all_response"
|
39
|
+
require "binance_client/responses/exchange_info_response"
|
31
40
|
require "binance_client/responses/book_ticker_response"
|
32
41
|
require "binance_client/responses/order_book_depth_response"
|
33
42
|
require "binance_client/responses/sub_account_assets_response"
|
34
43
|
require "binance_client/responses/sub_account_deposit_address_response"
|
44
|
+
require "binance_client/responses/sub_account_deposit_history_response"
|
35
45
|
require "binance_client/responses/account_response"
|
36
46
|
|
37
47
|
module BinanceClient
|
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: 2.
|
4
|
+
version: 2.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: 2021-12-
|
11
|
+
date: 2021-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: api_client_base
|
@@ -119,27 +119,35 @@ files:
|
|
119
119
|
- lib/binance_client/factories.rb
|
120
120
|
- lib/binance_client/models/asset_balance.rb
|
121
121
|
- lib/binance_client/models/base_model.rb
|
122
|
+
- lib/binance_client/models/deposit.rb
|
122
123
|
- lib/binance_client/models/deposit_address.rb
|
124
|
+
- lib/binance_client/models/market.rb
|
125
|
+
- lib/binance_client/models/market_filter.rb
|
123
126
|
- lib/binance_client/models/order_book.rb
|
124
127
|
- lib/binance_client/models/order_book_entry.rb
|
128
|
+
- lib/binance_client/models/rate_limit.rb
|
125
129
|
- lib/binance_client/requests/account_request.rb
|
126
130
|
- lib/binance_client/requests/account_snapshot_request.rb
|
127
131
|
- lib/binance_client/requests/authenticated_base_request.rb
|
128
132
|
- lib/binance_client/requests/base_request.rb
|
129
133
|
- lib/binance_client/requests/book_ticker_request.rb
|
134
|
+
- lib/binance_client/requests/exchange_info_request.rb
|
130
135
|
- lib/binance_client/requests/get_all_request.rb
|
131
136
|
- lib/binance_client/requests/order_book_depth_request.rb
|
132
137
|
- lib/binance_client/requests/sub_account_assets_request.rb
|
133
138
|
- lib/binance_client/requests/sub_account_deposit_address_request.rb
|
139
|
+
- lib/binance_client/requests/sub_account_deposit_history_request.rb
|
134
140
|
- lib/binance_client/requests/system_status_request.rb
|
135
141
|
- lib/binance_client/responses/account_response.rb
|
136
142
|
- lib/binance_client/responses/account_snapshot_response.rb
|
137
143
|
- lib/binance_client/responses/base_response.rb
|
138
144
|
- lib/binance_client/responses/book_ticker_response.rb
|
145
|
+
- lib/binance_client/responses/exchange_info_response.rb
|
139
146
|
- lib/binance_client/responses/get_all_response.rb
|
140
147
|
- lib/binance_client/responses/order_book_depth_response.rb
|
141
148
|
- lib/binance_client/responses/sub_account_assets_response.rb
|
142
149
|
- lib/binance_client/responses/sub_account_deposit_address_response.rb
|
150
|
+
- lib/binance_client/responses/sub_account_deposit_history_response.rb
|
143
151
|
- lib/binance_client/responses/system_status_response.rb
|
144
152
|
- lib/binance_client/version.rb
|
145
153
|
homepage: https://github.com/bloom-solutions/binance_client-ruby
|