binance_client 4.0.0 → 5.0.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/CHANGELOG.md +16 -0
- data/Gemfile.lock +3 -1
- data/README.md +1 -1
- data/binance_client.gemspec +1 -0
- data/lib/binance_client/client.rb +11 -1
- data/lib/binance_client/loader.rb +44 -0
- data/lib/binance_client/models/book_ticker.rb +26 -0
- data/lib/binance_client/models/deposit.rb +9 -1
- data/lib/binance_client/models/order_book.rb +4 -12
- data/lib/binance_client/models/order_fill.rb +21 -0
- data/lib/binance_client/requests/base_create_order_request.rb +25 -0
- data/lib/binance_client/requests/book_ticker_request.rb +3 -1
- data/lib/binance_client/requests/create_order_request.rb +11 -0
- data/lib/binance_client/requests/create_sub_account_request.rb +19 -0
- data/lib/binance_client/requests/create_test_order_request.rb +11 -0
- data/lib/binance_client/requests/sub_account_bnb_burn_status_request.rb +15 -0
- data/lib/binance_client/requests/sub_account_create_api_keys_request.rb +27 -0
- data/lib/binance_client/requests/sub_account_set_spot_bnb_burn_request.rb +20 -0
- data/lib/binance_client/requests/sub_account_transfer_request.rb +29 -0
- data/lib/binance_client/requests/withdraw_request.rb +46 -0
- data/lib/binance_client/responses/base_create_order_response.rb +48 -0
- data/lib/binance_client/responses/base_response.rb +3 -2
- data/lib/binance_client/responses/book_ticker_response.rb +9 -0
- data/lib/binance_client/responses/create_order_response.rb +5 -0
- data/lib/binance_client/responses/create_sub_account_response.rb +16 -0
- data/lib/binance_client/responses/create_test_order_response.rb +5 -0
- data/lib/binance_client/responses/sub_account_bnb_burn_status_response.rb +10 -0
- data/lib/binance_client/responses/sub_account_create_api_keys_response.rb +27 -0
- data/lib/binance_client/responses/sub_account_set_spot_bnb_burn_response.rb +11 -0
- data/lib/binance_client/responses/sub_account_transfer_response.rb +18 -0
- data/lib/binance_client/responses/withdraw_response.rb +13 -0
- data/lib/binance_client/version.rb +1 -1
- data/lib/binance_client.rb +2 -34
- metadata +40 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d50e294eccbbcabd5b1488a01cba18e55e78291d7027595f746e744fac3c47ba
|
4
|
+
data.tar.gz: e4476ae6a531184f71a36bad4c96a8c764d45f366539c355269ebd8abbf9f834
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58e58894781ab8f2e1127b592d8df250bfe27000591aebc1dab2550a0f0d49ed5ec58d086641e9cdcabfc471cc5515e5b2c26c98d77c80e2b1649400a5e827b4
|
7
|
+
data.tar.gz: ace12fc8592ab5f794542bb340a15730647edf24d385c495a4638186c7a0b2533a6025bcb3d1404715a8317bffd92448e8355c56ad74ece8028b1eff0367d3e8
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,22 @@ 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
|
+
## [5.0.0] - 2022-04-06
|
8
|
+
### Added
|
9
|
+
- `#sub_account_bnb_burn_status`
|
10
|
+
- `#sub_account_set_spot_bnb_burn`
|
11
|
+
- `#sub_account_transfer`
|
12
|
+
- `#sub_account_create_api_keys`
|
13
|
+
- `#create_test_order`
|
14
|
+
- `#create_order`
|
15
|
+
- `#withdraw`
|
16
|
+
|
17
|
+
### Changed
|
18
|
+
- `Deposit#sub_account_id` is an Integer and no longer a String. Consistent with sub_account_id everywhere else
|
19
|
+
- `#book_ticker`
|
20
|
+
- accepts symbol as only arg or no args
|
21
|
+
- response has `#book_tickers` that is used to access tickers whether or not a symbol was passed in
|
22
|
+
|
7
23
|
## [4.0.0]
|
8
24
|
### Added
|
9
25
|
- Add optional `network` parameter when getting deposit address of a specific network
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
binance_client (
|
4
|
+
binance_client (5.0.0)
|
5
5
|
activesupport
|
6
6
|
api_client_base (~> 1.11)
|
7
7
|
typhoeus
|
@@ -82,6 +82,7 @@ GEM
|
|
82
82
|
axiom-types (~> 0.1)
|
83
83
|
coercible (~> 1.0)
|
84
84
|
descendants_tracker (~> 0.0, >= 0.0.3)
|
85
|
+
wait (0.5.3)
|
85
86
|
webmock (3.9.1)
|
86
87
|
addressable (>= 2.3.6)
|
87
88
|
crack (>= 0.3.2)
|
@@ -99,6 +100,7 @@ DEPENDENCIES
|
|
99
100
|
rspec (~> 3.0)
|
100
101
|
rspec-its
|
101
102
|
vcr
|
103
|
+
wait
|
102
104
|
webmock
|
103
105
|
|
104
106
|
BUNDLED WITH
|
data/README.md
CHANGED
data/binance_client.gemspec
CHANGED
@@ -7,11 +7,21 @@ module BinanceClient
|
|
7
7
|
api_action :account_snapshot
|
8
8
|
api_action :coins_info
|
9
9
|
api_action :exchange_info
|
10
|
-
api_action :book_ticker
|
10
|
+
api_action :book_ticker, args: [:symbol]
|
11
11
|
api_action :order_book_depth
|
12
12
|
api_action :sub_account_assets, args: [:email]
|
13
13
|
api_action :sub_account_deposit_address
|
14
14
|
api_action :sub_account_deposit_history
|
15
|
+
api_action :sub_account_bnb_burn_status, args: [:sub_account_id]
|
16
|
+
api_action(:sub_account_set_spot_bnb_burn, {
|
17
|
+
args: [:sub_account_id, :spot_bnb_burn_status],
|
18
|
+
})
|
19
|
+
api_action :create_sub_account
|
20
|
+
api_action :sub_account_transfer
|
21
|
+
api_action :sub_account_create_api_keys
|
22
|
+
api_action :create_test_order
|
23
|
+
api_action :create_order
|
24
|
+
api_action :withdraw
|
15
25
|
|
16
26
|
attribute :host
|
17
27
|
attribute :api_key
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class Loader
|
3
|
+
|
4
|
+
def self.call
|
5
|
+
self.new.call
|
6
|
+
end
|
7
|
+
|
8
|
+
def call
|
9
|
+
models
|
10
|
+
requests
|
11
|
+
responses
|
12
|
+
end
|
13
|
+
|
14
|
+
def models
|
15
|
+
require "binance_client/models/base_model"
|
16
|
+
|
17
|
+
Dir[File.join(binance_client_dir, "models/*.rb")].each do |f|
|
18
|
+
require f
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def requests
|
23
|
+
require "binance_client/requests/base_request"
|
24
|
+
require "binance_client/requests/authenticated_base_request"
|
25
|
+
require "binance_client/requests/base_create_order_request"
|
26
|
+
Dir[File.join(binance_client_dir, "requests/*.rb")].each do |f|
|
27
|
+
require f
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def responses
|
32
|
+
require "binance_client/responses/base_response"
|
33
|
+
require "binance_client/responses/base_create_order_response"
|
34
|
+
Dir[File.join(binance_client_dir, "responses/*.rb")].each do |f|
|
35
|
+
require f
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def binance_client_dir
|
40
|
+
File.join(File.dirname(__FILE__))
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class BookTicker < BaseModel
|
3
|
+
|
4
|
+
ATTRIBUTES = [
|
5
|
+
:symbol,
|
6
|
+
:bid_price,
|
7
|
+
:bid_qty,
|
8
|
+
:ask_price,
|
9
|
+
:ask_qty
|
10
|
+
].freeze
|
11
|
+
|
12
|
+
attribute :symbol, String
|
13
|
+
attribute :bid_price, BigDecimal
|
14
|
+
attribute :bid_qty, BigDecimal
|
15
|
+
attribute :ask_price, BigDecimal
|
16
|
+
attribute :ask_qty, BigDecimal
|
17
|
+
|
18
|
+
def self.new_from_raw_hash(raw_hash)
|
19
|
+
attrs = ATTRIBUTES.each_with_object({}) do |local_attr, hash|
|
20
|
+
hash[local_attr] = raw_hash[local_attr.to_s.camelcase(:lower)]
|
21
|
+
end
|
22
|
+
self.new(attrs)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -1,8 +1,12 @@
|
|
1
1
|
module BinanceClient
|
2
2
|
class Deposit < BaseModel
|
3
3
|
|
4
|
+
attribute(:sub_account_id, Integer, {
|
5
|
+
lazy: true,
|
6
|
+
default: :default_sub_acccount_id,
|
7
|
+
})
|
8
|
+
|
4
9
|
METHODS = %i[
|
5
|
-
sub_account_id
|
6
10
|
address
|
7
11
|
address_tag
|
8
12
|
amount
|
@@ -24,6 +28,10 @@ module BinanceClient
|
|
24
28
|
end
|
25
29
|
end
|
26
30
|
|
31
|
+
def default_sub_acccount_id
|
32
|
+
raw_hash["subAccountId"]
|
33
|
+
end
|
34
|
+
|
27
35
|
METHODS.each do |method_name|
|
28
36
|
define_method method_name do
|
29
37
|
memoize_results "@#{method_name}" do
|
@@ -6,25 +6,17 @@ module BinanceClient
|
|
6
6
|
lazy: true,
|
7
7
|
default: :default_last_update_id,
|
8
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
9
|
|
18
10
|
def default_last_update_id
|
19
11
|
body["lastUpdateId"]
|
20
12
|
end
|
21
13
|
|
22
|
-
def
|
23
|
-
_entries_from
|
14
|
+
def bids
|
15
|
+
@bids ||= _entries_from(body["bids"])
|
24
16
|
end
|
25
17
|
|
26
|
-
def
|
27
|
-
_entries_from
|
18
|
+
def asks
|
19
|
+
@asks ||= _entries_from(body["asks"])
|
28
20
|
end
|
29
21
|
|
30
22
|
private
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class OrderFill < BaseModel
|
3
|
+
|
4
|
+
attribute :price, BigDecimal
|
5
|
+
attribute :qty, BigDecimal
|
6
|
+
attribute :commission, BigDecimal
|
7
|
+
attribute :commission_asset, String
|
8
|
+
attribute :trade_id, Integer
|
9
|
+
|
10
|
+
def self.new_from_raw_hash(raw_hash)
|
11
|
+
self.new(
|
12
|
+
price: raw_hash["price"],
|
13
|
+
qty: raw_hash["qty"],
|
14
|
+
commission: raw_hash["commission"],
|
15
|
+
commission_asset: raw_hash["commissionAsset"],
|
16
|
+
trade_id: raw_hash["tradeId"],
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class BaseCreateOrderRequest < AuthenticatedBaseRequest
|
3
|
+
|
4
|
+
attribute :symbol, String
|
5
|
+
attribute :side, String
|
6
|
+
attribute :type, String
|
7
|
+
attribute :quantity, String
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def default_action
|
12
|
+
:post
|
13
|
+
end
|
14
|
+
|
15
|
+
def params_without_signature
|
16
|
+
{
|
17
|
+
symbol: symbol,
|
18
|
+
side: side,
|
19
|
+
type: type,
|
20
|
+
quantity: quantity,
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class CreateSubAccountRequest < AuthenticatedBaseRequest
|
3
|
+
attribute :tag
|
4
|
+
|
5
|
+
private
|
6
|
+
|
7
|
+
def path
|
8
|
+
"/sapi/v1/broker/subAccount"
|
9
|
+
end
|
10
|
+
|
11
|
+
def default_action
|
12
|
+
:post
|
13
|
+
end
|
14
|
+
|
15
|
+
def params_without_signature
|
16
|
+
{}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class SubAccountBnbBurnStatusRequest < AuthenticatedBaseRequest
|
3
|
+
attribute :sub_account_id
|
4
|
+
|
5
|
+
private
|
6
|
+
|
7
|
+
def path
|
8
|
+
"/sapi/v1/broker/subAccount/bnbBurn/status"
|
9
|
+
end
|
10
|
+
|
11
|
+
def params_without_signature
|
12
|
+
{subAccountId: sub_account_id}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class SubAccountCreateApiKeysRequest < AuthenticatedBaseRequest
|
3
|
+
attribute :sub_account_id
|
4
|
+
attribute :can_trade, Boolean, default: true
|
5
|
+
attribute :margin_trade, Boolean, default: false
|
6
|
+
attribute :futures_trade, Boolean, default: false
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def path
|
11
|
+
"/sapi/v1/broker/subAccountApi"
|
12
|
+
end
|
13
|
+
|
14
|
+
def default_action
|
15
|
+
:post
|
16
|
+
end
|
17
|
+
|
18
|
+
def params_without_signature
|
19
|
+
{
|
20
|
+
subAccountId: sub_account_id,
|
21
|
+
canTrade: can_trade,
|
22
|
+
marginTrade: margin_trade,
|
23
|
+
futuresTrade: futures_trade,
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class SubAccountSetSpotBnbBurnRequest < AuthenticatedBaseRequest
|
3
|
+
attribute :sub_account_id
|
4
|
+
attribute :spot_bnb_burn_status
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def path
|
9
|
+
"/sapi/v1/broker/subAccount/bnbBurn/spot"
|
10
|
+
end
|
11
|
+
|
12
|
+
def default_action
|
13
|
+
:post
|
14
|
+
end
|
15
|
+
|
16
|
+
def params_without_signature
|
17
|
+
{subAccountId: sub_account_id, spotBNBBurn: spot_bnb_burn_status}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class SubAccountTransferRequest < AuthenticatedBaseRequest
|
3
|
+
attribute :from_id
|
4
|
+
attribute :to_id
|
5
|
+
attribute :client_tran_id
|
6
|
+
attribute :asset
|
7
|
+
attribute :amount
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def path
|
12
|
+
"/sapi/v1/broker/transfer"
|
13
|
+
end
|
14
|
+
|
15
|
+
def default_action
|
16
|
+
:post
|
17
|
+
end
|
18
|
+
|
19
|
+
def params_without_signature
|
20
|
+
{
|
21
|
+
fromId: from_id,
|
22
|
+
toId: to_id,
|
23
|
+
clientTranId: client_tran_id,
|
24
|
+
asset: asset,
|
25
|
+
amount: amount,
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class WithdrawRequest < AuthenticatedBaseRequest
|
3
|
+
|
4
|
+
attribute :coin, String
|
5
|
+
attribute :address, String
|
6
|
+
attribute :amount, Float
|
7
|
+
attribute :withdraw_order_id, String
|
8
|
+
attribute :network, String
|
9
|
+
attribute :address_tag, String
|
10
|
+
attribute :transaction_fee_flag, Boolean
|
11
|
+
attribute :name, String
|
12
|
+
attribute :wallet_type, Integer
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def escaped_name
|
17
|
+
return nil if name.blank?
|
18
|
+
name.gsub("\s", "%20")
|
19
|
+
end
|
20
|
+
|
21
|
+
def path
|
22
|
+
"/sapi/v1/capital/withdraw/apply"
|
23
|
+
end
|
24
|
+
|
25
|
+
def default_action
|
26
|
+
:post
|
27
|
+
end
|
28
|
+
|
29
|
+
def params_without_signature
|
30
|
+
{
|
31
|
+
coin: coin,
|
32
|
+
address: address,
|
33
|
+
amount: amount,
|
34
|
+
withdrawOrderId: withdraw_order_id,
|
35
|
+
network: network,
|
36
|
+
addressTag: address_tag,
|
37
|
+
transactionFeeFlag: transaction_fee_flag,
|
38
|
+
name: escaped_name,
|
39
|
+
walletType: wallet_type,
|
40
|
+
}.reject do |key, value|
|
41
|
+
value.blank?
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class BaseCreateOrderResponse < BaseResponse
|
3
|
+
|
4
|
+
attribute :symbol, String, lazy: true, default: :default_symbol
|
5
|
+
attribute :order_id, Integer, lazy: true, default: :default_order_id
|
6
|
+
attribute :client_order_id, String, lazy: true, default: :default_client_order_id
|
7
|
+
attribute :transact_time, Integer, lazy: true, default: :default_transact_time
|
8
|
+
attribute :price, BigDecimal, lazy: true, default: :default_price
|
9
|
+
attribute :orig_qty, BigDecimal, lazy: true, default: :default_orig_qty
|
10
|
+
attribute :executed_qty, BigDecimal, lazy: true, default: :default_executed_qty
|
11
|
+
attribute :cummulative_quote_qty, BigDecimal, lazy: true, default: :default_cummulative_quote_qty
|
12
|
+
attribute :status, String, lazy: true, default: :default_status
|
13
|
+
attribute :time_in_force, String, lazy: true, default: :default_time_in_force
|
14
|
+
attribute :type, String, lazy: true, default: :default_type
|
15
|
+
attribute :side, String, lazy: true, default: :default_side
|
16
|
+
attribute :time_in_force, String, lazy: true, default: :default_time_in_force
|
17
|
+
attribute :type, String, lazy: true, default: :default_type
|
18
|
+
attribute :side, String, lazy: true, default: :default_side
|
19
|
+
|
20
|
+
def fills
|
21
|
+
@fills ||= body["fills"].map do |fill_entry|
|
22
|
+
OrderFill.new_from_raw_hash(fill_entry)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
{
|
29
|
+
symbol: :symbol,
|
30
|
+
order_id: :orderId,
|
31
|
+
client_order_id: :clientOrderId,
|
32
|
+
transact_time: :transactTime,
|
33
|
+
price: :price,
|
34
|
+
orig_qty: :origQty,
|
35
|
+
executed_qty: :executedQty,
|
36
|
+
cummulative_quote_qty: :cummulativeQuoteQty,
|
37
|
+
status: :status,
|
38
|
+
time_in_force: :timeInForce,
|
39
|
+
type: :type,
|
40
|
+
side: :side,
|
41
|
+
}.each do |attr, remote_attr|
|
42
|
+
define_method :"default_#{attr}" do
|
43
|
+
body[remote_attr.to_s]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -3,6 +3,7 @@ module BinanceClient
|
|
3
3
|
include APIClientBase::Response.module
|
4
4
|
|
5
5
|
attribute :body, Object, lazy: true, default: :default_body
|
6
|
+
attribute :message, String, lazy: true, default: :default_message
|
6
7
|
|
7
8
|
def used_weights
|
8
9
|
@used_weights ||= headers.each_with_object({}) do |(key, value), hash|
|
@@ -12,8 +13,8 @@ module BinanceClient
|
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
15
|
-
def
|
16
|
-
body["message"]
|
16
|
+
def default_message
|
17
|
+
body["message"].presence || body["msg"]
|
17
18
|
end
|
18
19
|
|
19
20
|
def body_code
|
@@ -1,4 +1,13 @@
|
|
1
1
|
module BinanceClient
|
2
2
|
class BookTickerResponse < BaseResponse
|
3
|
+
|
4
|
+
def book_tickers
|
5
|
+
book_ticker_hashes = [body].flatten
|
6
|
+
|
7
|
+
@book_tickers ||= book_ticker_hashes.map do |book_ticker_hash|
|
8
|
+
BookTicker.new_from_raw_hash(book_ticker_hash)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
3
12
|
end
|
4
13
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class CreateSubAccountResponse < BaseResponse
|
3
|
+
|
4
|
+
attribute :sub_account_id, Integer, lazy: true, default: :default_sub_acccount_id
|
5
|
+
attribute :email, String, lazy: true, default: :default_email
|
6
|
+
|
7
|
+
def default_sub_acccount_id
|
8
|
+
body["subaccountId"]
|
9
|
+
end
|
10
|
+
|
11
|
+
def default_email
|
12
|
+
body["email"]
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class SubAccountCreateApiKeysResponse < BaseResponse
|
3
|
+
|
4
|
+
attribute :sub_account_id, Integer, lazy: true, default: :default_sub_account_id
|
5
|
+
attribute :api_key, String, lazy: true, default: :default_api_key
|
6
|
+
attribute :secret_key, String, lazy: true, default: :default_secret_key
|
7
|
+
attribute :can_trade, Boolean, lazy: true, default: :default_can_trade
|
8
|
+
attribute :margin_trade, Boolean, lazy: true, default: :default_margin_trade
|
9
|
+
attribute :futures_trade, Boolean, lazy: true, default: :default_futures_trade
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
{
|
14
|
+
sub_account_id: :subaccountId,
|
15
|
+
api_key: :apiKey,
|
16
|
+
secret_key: :secretKey,
|
17
|
+
can_trade: :canTrade,
|
18
|
+
margin_trade: :marginTrade,
|
19
|
+
futures_trade: :futuresTrade,
|
20
|
+
}.each do |attr, remote_attr|
|
21
|
+
define_method :"default_#{attr}" do
|
22
|
+
body[remote_attr.to_s]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class SubAccountTransferResponse < BaseResponse
|
3
|
+
|
4
|
+
attribute :txn_id, Integer, lazy: true, default: :default_txn_id
|
5
|
+
attribute :client_tran_id, String, lazy: true, default: :default_client_tran_id
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def default_txn_id
|
10
|
+
body["txnId"]
|
11
|
+
end
|
12
|
+
|
13
|
+
def default_client_tran_id
|
14
|
+
body["clientTranId"]
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
data/lib/binance_client.rb
CHANGED
@@ -10,41 +10,9 @@ require "openssl"
|
|
10
10
|
|
11
11
|
require "binance_client/client"
|
12
12
|
|
13
|
-
require "binance_client/
|
14
|
-
require "binance_client/models/order_book_entry"
|
15
|
-
require "binance_client/models/order_book"
|
16
|
-
require "binance_client/models/asset_balance"
|
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"
|
22
|
-
require "binance_client/models/network"
|
23
|
-
require "binance_client/models/coin"
|
13
|
+
require "binance_client/loader"
|
24
14
|
|
25
|
-
|
26
|
-
require "binance_client/requests/authenticated_base_request"
|
27
|
-
require "binance_client/responses/base_response"
|
28
|
-
require "binance_client/requests/system_status_request"
|
29
|
-
require "binance_client/requests/account_snapshot_request"
|
30
|
-
require "binance_client/requests/exchange_info_request"
|
31
|
-
require "binance_client/requests/coins_info_request"
|
32
|
-
require "binance_client/requests/book_ticker_request"
|
33
|
-
require "binance_client/requests/order_book_depth_request"
|
34
|
-
require "binance_client/requests/sub_account_assets_request"
|
35
|
-
require "binance_client/requests/sub_account_deposit_address_request"
|
36
|
-
require "binance_client/requests/sub_account_deposit_history_request"
|
37
|
-
require "binance_client/requests/account_request"
|
38
|
-
require "binance_client/responses/system_status_response"
|
39
|
-
require "binance_client/responses/account_snapshot_response"
|
40
|
-
require "binance_client/responses/coins_info_response"
|
41
|
-
require "binance_client/responses/exchange_info_response"
|
42
|
-
require "binance_client/responses/book_ticker_response"
|
43
|
-
require "binance_client/responses/order_book_depth_response"
|
44
|
-
require "binance_client/responses/sub_account_assets_response"
|
45
|
-
require "binance_client/responses/sub_account_deposit_address_response"
|
46
|
-
require "binance_client/responses/sub_account_deposit_history_response"
|
47
|
-
require "binance_client/responses/account_response"
|
15
|
+
BinanceClient::Loader.()
|
48
16
|
|
49
17
|
module BinanceClient
|
50
18
|
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:
|
4
|
+
version: 5.0.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: 2022-
|
11
|
+
date: 2022-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: api_client_base
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: wait
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: Ruby wrapper for Binance API
|
98
112
|
email:
|
99
113
|
- hi@ajvillalobos.com
|
@@ -117,8 +131,10 @@ files:
|
|
117
131
|
- lib/binance_client.rb
|
118
132
|
- lib/binance_client/client.rb
|
119
133
|
- lib/binance_client/factories.rb
|
134
|
+
- lib/binance_client/loader.rb
|
120
135
|
- lib/binance_client/models/asset_balance.rb
|
121
136
|
- lib/binance_client/models/base_model.rb
|
137
|
+
- lib/binance_client/models/book_ticker.rb
|
122
138
|
- lib/binance_client/models/coin.rb
|
123
139
|
- lib/binance_client/models/deposit.rb
|
124
140
|
- lib/binance_client/models/deposit_address.rb
|
@@ -127,30 +143,49 @@ files:
|
|
127
143
|
- lib/binance_client/models/network.rb
|
128
144
|
- lib/binance_client/models/order_book.rb
|
129
145
|
- lib/binance_client/models/order_book_entry.rb
|
146
|
+
- lib/binance_client/models/order_fill.rb
|
130
147
|
- lib/binance_client/models/rate_limit.rb
|
131
148
|
- lib/binance_client/requests/account_request.rb
|
132
149
|
- lib/binance_client/requests/account_snapshot_request.rb
|
133
150
|
- lib/binance_client/requests/authenticated_base_request.rb
|
151
|
+
- lib/binance_client/requests/base_create_order_request.rb
|
134
152
|
- lib/binance_client/requests/base_request.rb
|
135
153
|
- lib/binance_client/requests/book_ticker_request.rb
|
136
154
|
- lib/binance_client/requests/coins_info_request.rb
|
155
|
+
- lib/binance_client/requests/create_order_request.rb
|
156
|
+
- lib/binance_client/requests/create_sub_account_request.rb
|
157
|
+
- lib/binance_client/requests/create_test_order_request.rb
|
137
158
|
- lib/binance_client/requests/exchange_info_request.rb
|
138
159
|
- lib/binance_client/requests/order_book_depth_request.rb
|
139
160
|
- lib/binance_client/requests/sub_account_assets_request.rb
|
161
|
+
- lib/binance_client/requests/sub_account_bnb_burn_status_request.rb
|
162
|
+
- lib/binance_client/requests/sub_account_create_api_keys_request.rb
|
140
163
|
- lib/binance_client/requests/sub_account_deposit_address_request.rb
|
141
164
|
- lib/binance_client/requests/sub_account_deposit_history_request.rb
|
165
|
+
- lib/binance_client/requests/sub_account_set_spot_bnb_burn_request.rb
|
166
|
+
- lib/binance_client/requests/sub_account_transfer_request.rb
|
142
167
|
- lib/binance_client/requests/system_status_request.rb
|
168
|
+
- lib/binance_client/requests/withdraw_request.rb
|
143
169
|
- lib/binance_client/responses/account_response.rb
|
144
170
|
- lib/binance_client/responses/account_snapshot_response.rb
|
171
|
+
- lib/binance_client/responses/base_create_order_response.rb
|
145
172
|
- lib/binance_client/responses/base_response.rb
|
146
173
|
- lib/binance_client/responses/book_ticker_response.rb
|
147
174
|
- lib/binance_client/responses/coins_info_response.rb
|
175
|
+
- lib/binance_client/responses/create_order_response.rb
|
176
|
+
- lib/binance_client/responses/create_sub_account_response.rb
|
177
|
+
- lib/binance_client/responses/create_test_order_response.rb
|
148
178
|
- lib/binance_client/responses/exchange_info_response.rb
|
149
179
|
- lib/binance_client/responses/order_book_depth_response.rb
|
150
180
|
- lib/binance_client/responses/sub_account_assets_response.rb
|
181
|
+
- lib/binance_client/responses/sub_account_bnb_burn_status_response.rb
|
182
|
+
- lib/binance_client/responses/sub_account_create_api_keys_response.rb
|
151
183
|
- lib/binance_client/responses/sub_account_deposit_address_response.rb
|
152
184
|
- lib/binance_client/responses/sub_account_deposit_history_response.rb
|
185
|
+
- lib/binance_client/responses/sub_account_set_spot_bnb_burn_response.rb
|
186
|
+
- lib/binance_client/responses/sub_account_transfer_response.rb
|
153
187
|
- lib/binance_client/responses/system_status_response.rb
|
188
|
+
- lib/binance_client/responses/withdraw_response.rb
|
154
189
|
- lib/binance_client/version.rb
|
155
190
|
homepage: https://github.com/bloom-solutions/binance_client-ruby
|
156
191
|
licenses:
|
@@ -159,7 +194,7 @@ metadata:
|
|
159
194
|
homepage_uri: https://github.com/bloom-solutions/binance_client-ruby
|
160
195
|
source_code_uri: https://github.com/bloom-solutions/binance_client-ruby
|
161
196
|
changelog_uri: https://github.com/bloom-solutions/binance_client-ruby/CHANGELOG.md
|
162
|
-
post_install_message:
|
197
|
+
post_install_message:
|
163
198
|
rdoc_options: []
|
164
199
|
require_paths:
|
165
200
|
- lib
|
@@ -175,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
210
|
version: '0'
|
176
211
|
requirements: []
|
177
212
|
rubygems_version: 3.1.6
|
178
|
-
signing_key:
|
213
|
+
signing_key:
|
179
214
|
specification_version: 4
|
180
215
|
summary: Ruby wrapper for Binance API
|
181
216
|
test_files: []
|