binance_client 4.0.0 → 5.2.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 +24 -0
- data/Gemfile.lock +3 -1
- data/README.md +1 -1
- data/binance_client.gemspec +1 -0
- data/lib/binance_client/client.rb +13 -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.rb +23 -0
- 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/all_orders_request.rb +17 -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/ping_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/all_orders_response.rb +15 -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/ping_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 +42 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2da825e960057759234b17aae2722429df0a91a6e87343aa63b5177d2f0dea0f
|
4
|
+
data.tar.gz: ce99de0cdae0c663a384559d780f79933985cbc8cf6f06793dde6091d185b7a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f600ea14ca7dff15ac8b9626f812eccbf0843b9cc09455d04569ae98c25894455c15ba61cc6e1dfab0b7fa50854f520d7c9fa0dad558e3436a5acfe208d56073
|
7
|
+
data.tar.gz: 2014a2de0f2d412aace73888cd1ad817f4943d64c6f264df15faebae9de970bc6ae0acc045237f52a610026ba46d849f561a344faa7bb033ce2232cb5fcf7862
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,30 @@ 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.2.0] - 2022-05-20
|
8
|
+
### Added
|
9
|
+
- `#all_orders`
|
10
|
+
|
11
|
+
## [5.1.0] - 2022-04-22
|
12
|
+
### Added
|
13
|
+
- `#ping`
|
14
|
+
|
15
|
+
## [5.0.0] - 2022-04-06
|
16
|
+
### Added
|
17
|
+
- `#sub_account_bnb_burn_status`
|
18
|
+
- `#sub_account_set_spot_bnb_burn`
|
19
|
+
- `#sub_account_transfer`
|
20
|
+
- `#sub_account_create_api_keys`
|
21
|
+
- `#create_test_order`
|
22
|
+
- `#create_order`
|
23
|
+
- `#withdraw`
|
24
|
+
|
25
|
+
### Changed
|
26
|
+
- `Deposit#sub_account_id` is an Integer and no longer a String. Consistent with sub_account_id everywhere else
|
27
|
+
- `#book_ticker`
|
28
|
+
- accepts symbol as only arg or no args
|
29
|
+
- response has `#book_tickers` that is used to access tickers whether or not a symbol was passed in
|
30
|
+
|
7
31
|
## [4.0.0]
|
8
32
|
### Added
|
9
33
|
- 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.2.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,23 @@ 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
|
25
|
+
api_action :ping
|
26
|
+
api_action :all_orders, args: [:symbol, :start_time]
|
15
27
|
|
16
28
|
attribute :host
|
17
29
|
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
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class Order
|
3
|
+
attr_reader :symbol
|
4
|
+
attr_reader :executed_quantity
|
5
|
+
attr_reader :cummulative_quote_quantity
|
6
|
+
attr_reader :order_id
|
7
|
+
attr_reader :side
|
8
|
+
|
9
|
+
def initialize(
|
10
|
+
symbol:,
|
11
|
+
executed_quantity:,
|
12
|
+
cummulative_quote_quantity:,
|
13
|
+
order_id:,
|
14
|
+
side:
|
15
|
+
)
|
16
|
+
@symbol = symbol
|
17
|
+
@executed_quantity = executed_quantity
|
18
|
+
@cummulative_quote_quantity = cummulative_quote_quantity
|
19
|
+
@order_id = order_id
|
20
|
+
@side = side
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -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,17 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class AllOrdersRequest < AuthenticatedBaseRequest
|
3
|
+
attribute :symbol, String
|
4
|
+
attribute :start_time, Integer
|
5
|
+
|
6
|
+
def path
|
7
|
+
"/api/v3/allOrders"
|
8
|
+
end
|
9
|
+
|
10
|
+
def params_without_signature
|
11
|
+
{
|
12
|
+
symbol: symbol,
|
13
|
+
startTime: start_time
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
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,15 @@
|
|
1
|
+
module BinanceClient
|
2
|
+
class AllOrdersResponse < BaseResponse
|
3
|
+
def orders
|
4
|
+
body.map do |hash|
|
5
|
+
Order.new({
|
6
|
+
symbol: hash["symbol"],
|
7
|
+
executed_quantity: hash["executedQty"],
|
8
|
+
cummulative_quote_quantity: hash["cummulativeQuoteQty"],
|
9
|
+
order_id: hash["orderId"],
|
10
|
+
side: hash["side"],
|
11
|
+
})
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
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.2.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: 2022-
|
11
|
+
date: 2022-05-20 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,40 +131,66 @@ 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
|
125
141
|
- lib/binance_client/models/market.rb
|
126
142
|
- lib/binance_client/models/market_filter.rb
|
127
143
|
- lib/binance_client/models/network.rb
|
144
|
+
- lib/binance_client/models/order.rb
|
128
145
|
- lib/binance_client/models/order_book.rb
|
129
146
|
- lib/binance_client/models/order_book_entry.rb
|
147
|
+
- lib/binance_client/models/order_fill.rb
|
130
148
|
- lib/binance_client/models/rate_limit.rb
|
131
149
|
- lib/binance_client/requests/account_request.rb
|
132
150
|
- lib/binance_client/requests/account_snapshot_request.rb
|
151
|
+
- lib/binance_client/requests/all_orders_request.rb
|
133
152
|
- lib/binance_client/requests/authenticated_base_request.rb
|
153
|
+
- lib/binance_client/requests/base_create_order_request.rb
|
134
154
|
- lib/binance_client/requests/base_request.rb
|
135
155
|
- lib/binance_client/requests/book_ticker_request.rb
|
136
156
|
- lib/binance_client/requests/coins_info_request.rb
|
157
|
+
- lib/binance_client/requests/create_order_request.rb
|
158
|
+
- lib/binance_client/requests/create_sub_account_request.rb
|
159
|
+
- lib/binance_client/requests/create_test_order_request.rb
|
137
160
|
- lib/binance_client/requests/exchange_info_request.rb
|
138
161
|
- lib/binance_client/requests/order_book_depth_request.rb
|
162
|
+
- lib/binance_client/requests/ping_request.rb
|
139
163
|
- lib/binance_client/requests/sub_account_assets_request.rb
|
164
|
+
- lib/binance_client/requests/sub_account_bnb_burn_status_request.rb
|
165
|
+
- lib/binance_client/requests/sub_account_create_api_keys_request.rb
|
140
166
|
- lib/binance_client/requests/sub_account_deposit_address_request.rb
|
141
167
|
- lib/binance_client/requests/sub_account_deposit_history_request.rb
|
168
|
+
- lib/binance_client/requests/sub_account_set_spot_bnb_burn_request.rb
|
169
|
+
- lib/binance_client/requests/sub_account_transfer_request.rb
|
142
170
|
- lib/binance_client/requests/system_status_request.rb
|
171
|
+
- lib/binance_client/requests/withdraw_request.rb
|
143
172
|
- lib/binance_client/responses/account_response.rb
|
144
173
|
- lib/binance_client/responses/account_snapshot_response.rb
|
174
|
+
- lib/binance_client/responses/all_orders_response.rb
|
175
|
+
- lib/binance_client/responses/base_create_order_response.rb
|
145
176
|
- lib/binance_client/responses/base_response.rb
|
146
177
|
- lib/binance_client/responses/book_ticker_response.rb
|
147
178
|
- lib/binance_client/responses/coins_info_response.rb
|
179
|
+
- lib/binance_client/responses/create_order_response.rb
|
180
|
+
- lib/binance_client/responses/create_sub_account_response.rb
|
181
|
+
- lib/binance_client/responses/create_test_order_response.rb
|
148
182
|
- lib/binance_client/responses/exchange_info_response.rb
|
149
183
|
- lib/binance_client/responses/order_book_depth_response.rb
|
184
|
+
- lib/binance_client/responses/ping_response.rb
|
150
185
|
- lib/binance_client/responses/sub_account_assets_response.rb
|
186
|
+
- lib/binance_client/responses/sub_account_bnb_burn_status_response.rb
|
187
|
+
- lib/binance_client/responses/sub_account_create_api_keys_response.rb
|
151
188
|
- lib/binance_client/responses/sub_account_deposit_address_response.rb
|
152
189
|
- lib/binance_client/responses/sub_account_deposit_history_response.rb
|
190
|
+
- lib/binance_client/responses/sub_account_set_spot_bnb_burn_response.rb
|
191
|
+
- lib/binance_client/responses/sub_account_transfer_response.rb
|
153
192
|
- lib/binance_client/responses/system_status_response.rb
|
193
|
+
- lib/binance_client/responses/withdraw_response.rb
|
154
194
|
- lib/binance_client/version.rb
|
155
195
|
homepage: https://github.com/bloom-solutions/binance_client-ruby
|
156
196
|
licenses:
|