binance_client 3.0.1 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +25 -0
  3. data/Gemfile.lock +5 -3
  4. data/README.md +1 -1
  5. data/binance_client.gemspec +1 -0
  6. data/lib/binance_client/client.rb +13 -2
  7. data/lib/binance_client/loader.rb +44 -0
  8. data/lib/binance_client/models/book_ticker.rb +26 -0
  9. data/lib/binance_client/models/deposit.rb +9 -1
  10. data/lib/binance_client/models/order_book.rb +4 -12
  11. data/lib/binance_client/models/order_fill.rb +21 -0
  12. data/lib/binance_client/requests/base_create_order_request.rb +25 -0
  13. data/lib/binance_client/requests/book_ticker_request.rb +3 -1
  14. data/lib/binance_client/requests/create_order_request.rb +11 -0
  15. data/lib/binance_client/requests/create_sub_account_request.rb +19 -0
  16. data/lib/binance_client/requests/create_test_order_request.rb +11 -0
  17. data/lib/binance_client/requests/ping_request.rb +11 -0
  18. data/lib/binance_client/requests/sub_account_bnb_burn_status_request.rb +15 -0
  19. data/lib/binance_client/requests/sub_account_create_api_keys_request.rb +27 -0
  20. data/lib/binance_client/requests/sub_account_set_spot_bnb_burn_request.rb +20 -0
  21. data/lib/binance_client/requests/sub_account_transfer_request.rb +29 -0
  22. data/lib/binance_client/requests/withdraw_request.rb +46 -0
  23. data/lib/binance_client/responses/base_create_order_response.rb +48 -0
  24. data/lib/binance_client/responses/base_response.rb +3 -2
  25. data/lib/binance_client/responses/book_ticker_response.rb +9 -0
  26. data/lib/binance_client/responses/create_order_response.rb +5 -0
  27. data/lib/binance_client/responses/create_sub_account_response.rb +16 -0
  28. data/lib/binance_client/responses/create_test_order_response.rb +5 -0
  29. data/lib/binance_client/responses/ping_response.rb +5 -0
  30. data/lib/binance_client/responses/sub_account_bnb_burn_status_response.rb +10 -0
  31. data/lib/binance_client/responses/sub_account_create_api_keys_response.rb +27 -0
  32. data/lib/binance_client/responses/sub_account_set_spot_bnb_burn_response.rb +11 -0
  33. data/lib/binance_client/responses/sub_account_transfer_response.rb +18 -0
  34. data/lib/binance_client/responses/withdraw_response.rb +13 -0
  35. data/lib/binance_client/version.rb +1 -1
  36. data/lib/binance_client.rb +2 -34
  37. metadata +39 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0ffbedc335b6922f76dc12d791c2e362e012408ec15d89ccbc9a601277874d2
4
- data.tar.gz: d260ca781537671f0efa3cbefad3543f681b5d8c8616d52ceaa8f411dda02d02
3
+ metadata.gz: 9d5c9aa23792c3ce05d700f255a811031aadc407e54184a415fe08d6810a2e04
4
+ data.tar.gz: 65356315dfc2e010d17ceb6d3e48a1c9f7b420c96acfa1a28beae1f944a68872
5
5
  SHA512:
6
- metadata.gz: ae418449f912f5acab8efea9cb2369d221ff25477254f973e4dc87e44b54d1a4eb9b4835cb2e926af9b725a3187a974a105d1c815dd704f4b03d78e2eb61871a
7
- data.tar.gz: 81b69e1a4cbb64e0a22459a98909f605421a6fbf9286a94a448868cf951d4004cd468e2a08a2ab2d47843b2e18d774dd1284ac6acb242ded188182799a0629a1
6
+ metadata.gz: 79ad182390c4a8046fb1e72cf438c6bcd6732270180d6432e3c27cecc4169d3bbc193b7d0ca6d7f75bb5034fe8ed1c815158cde4c725e8f4796757252b98494f
7
+ data.tar.gz: 39a88c90b97074c6af9a7e66e4a5f77e3054e8342f7bfc8f8a46f82c008835fbd9b00cedb5fadf9827561ae65c818f87b28a8f240ba6efebcfb5b0fcc7aad92e
data/CHANGELOG.md CHANGED
@@ -4,6 +4,31 @@ 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.1.0] - 2022-04-22
8
+ ### Added
9
+ - `#ping`
10
+
11
+ ## [5.0.0] - 2022-04-06
12
+ ### Added
13
+ - `#sub_account_bnb_burn_status`
14
+ - `#sub_account_set_spot_bnb_burn`
15
+ - `#sub_account_transfer`
16
+ - `#sub_account_create_api_keys`
17
+ - `#create_test_order`
18
+ - `#create_order`
19
+ - `#withdraw`
20
+
21
+ ### Changed
22
+ - `Deposit#sub_account_id` is an Integer and no longer a String. Consistent with sub_account_id everywhere else
23
+ - `#book_ticker`
24
+ - accepts symbol as only arg or no args
25
+ - response has `#book_tickers` that is used to access tickers whether or not a symbol was passed in
26
+
27
+ ## [4.0.0]
28
+ ### Added
29
+ - Add optional `network` parameter when getting deposit address of a specific network
30
+ - Use keyword arguments when calling `sub_account_deposit_address`
31
+
7
32
  ## [3.0.1]
8
33
  ### Fixed
9
34
  - `Coin#network_list` is initialized properly
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- binance_client (3.0.1)
4
+ binance_client (5.1.0)
5
5
  activesupport
6
6
  api_client_base (~> 1.11)
7
7
  typhoeus
@@ -39,7 +39,7 @@ GEM
39
39
  ffi (>= 1.15.0)
40
40
  factory_bot (6.2.0)
41
41
  activesupport (>= 5.0.0)
42
- ffi (1.15.4)
42
+ ffi (1.15.5)
43
43
  gem_config (0.3.2)
44
44
  hashdiff (1.0.1)
45
45
  i18n (1.8.11)
@@ -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,7 +100,8 @@ DEPENDENCIES
99
100
  rspec (~> 3.0)
100
101
  rspec-its
101
102
  vcr
103
+ wait
102
104
  webmock
103
105
 
104
106
  BUNDLED WITH
105
- 2.2.28
107
+ 2.2.29
data/README.md CHANGED
@@ -35,7 +35,7 @@ We provide one method per API endpoint.
35
35
  client.system_status
36
36
  client.account_snapshot
37
37
  client.coins_info
38
- client.book_ticker(symbol: "BTCETH")
38
+ client.book_ticker("BTCETH")
39
39
  client.order_book_depth(symbol: "BTCUSDT", limit: 100)
40
40
  ```
41
41
 
@@ -32,4 +32,5 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency "vcr"
33
33
  spec.add_development_dependency "webmock"
34
34
  spec.add_development_dependency "rspec-its"
35
+ spec.add_development_dependency "wait"
35
36
  end
@@ -7,11 +7,22 @@ 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
- api_action :sub_account_deposit_address, args: [:email, :coin]
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
15
26
 
16
27
  attribute :host
17
28
  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 default_bids
23
- _entries_from body["bids"]
14
+ def bids
15
+ @bids ||= _entries_from(body["bids"])
24
16
  end
25
17
 
26
- def default_asks
27
- _entries_from body["asks"]
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
@@ -7,7 +7,9 @@ module BinanceClient
7
7
  end
8
8
 
9
9
  def params
10
- {symbol: symbol}.to_query
10
+ {}.tap do |hash|
11
+ hash[:symbol] = symbol if symbol
12
+ end.to_query
11
13
  end
12
14
  end
13
15
  end
@@ -0,0 +1,11 @@
1
+ module BinanceClient
2
+ class CreateOrderRequest < BaseCreateOrderRequest
3
+
4
+ private
5
+
6
+ def path
7
+ "/api/v3/order"
8
+ end
9
+
10
+ end
11
+ 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,11 @@
1
+ module BinanceClient
2
+ class CreateTestOrderRequest < BaseCreateOrderRequest
3
+
4
+ private
5
+
6
+ def path
7
+ "/api/v3/order/test"
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module BinanceClient
2
+ class PingRequest < BaseRequest
3
+
4
+ private
5
+
6
+ def path
7
+ "/api/v3/ping"
8
+ end
9
+
10
+ end
11
+ 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 message
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,5 @@
1
+ module BinanceClient
2
+ class CreateOrderResponse < BaseCreateOrderResponse
3
+
4
+ end
5
+ 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,5 @@
1
+ module BinanceClient
2
+ class CreateTestOrderResponse < BaseCreateOrderResponse
3
+
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module BinanceClient
2
+ class PingResponse < BaseResponse
3
+
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ module BinanceClient
2
+ class SubAccountBnbBurnStatusResponse < BaseResponse
3
+
4
+ def spot_bnb_burn
5
+ !!body["spotBNBBurn"]
6
+ end
7
+ alias_method :spot_bnb_burn?, :spot_bnb_burn
8
+
9
+ end
10
+ 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,11 @@
1
+ module BinanceClient
2
+ class SubAccountSetSpotBnbBurnResponse < BaseResponse
3
+
4
+ def spot_bnb_burn
5
+ !!body["spotBNBBurn"]
6
+ end
7
+ alias_method :spot_bnb_burn?, :spot_bnb_burn
8
+
9
+
10
+ end
11
+ 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
@@ -0,0 +1,13 @@
1
+ module BinanceClient
2
+ class WithdrawResponse < BaseResponse
3
+
4
+ attribute :withdrawal_id, String, lazy: true, default: :default_withdrawal_id
5
+
6
+ private
7
+
8
+ def default_withdrawal_id
9
+ body["id"]
10
+ end
11
+
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module BinanceClient
2
- VERSION = "3.0.1"
2
+ VERSION = "5.1.0"
3
3
  end
@@ -10,41 +10,9 @@ require "openssl"
10
10
 
11
11
  require "binance_client/client"
12
12
 
13
- require "binance_client/models/base_model"
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
- require "binance_client/requests/base_request"
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: 3.0.1
4
+ version: 5.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-28 00:00:00.000000000 Z
11
+ date: 2022-04-22 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,51 @@ 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
160
+ - lib/binance_client/requests/ping_request.rb
139
161
  - lib/binance_client/requests/sub_account_assets_request.rb
162
+ - lib/binance_client/requests/sub_account_bnb_burn_status_request.rb
163
+ - lib/binance_client/requests/sub_account_create_api_keys_request.rb
140
164
  - lib/binance_client/requests/sub_account_deposit_address_request.rb
141
165
  - lib/binance_client/requests/sub_account_deposit_history_request.rb
166
+ - lib/binance_client/requests/sub_account_set_spot_bnb_burn_request.rb
167
+ - lib/binance_client/requests/sub_account_transfer_request.rb
142
168
  - lib/binance_client/requests/system_status_request.rb
169
+ - lib/binance_client/requests/withdraw_request.rb
143
170
  - lib/binance_client/responses/account_response.rb
144
171
  - lib/binance_client/responses/account_snapshot_response.rb
172
+ - lib/binance_client/responses/base_create_order_response.rb
145
173
  - lib/binance_client/responses/base_response.rb
146
174
  - lib/binance_client/responses/book_ticker_response.rb
147
175
  - lib/binance_client/responses/coins_info_response.rb
176
+ - lib/binance_client/responses/create_order_response.rb
177
+ - lib/binance_client/responses/create_sub_account_response.rb
178
+ - lib/binance_client/responses/create_test_order_response.rb
148
179
  - lib/binance_client/responses/exchange_info_response.rb
149
180
  - lib/binance_client/responses/order_book_depth_response.rb
181
+ - lib/binance_client/responses/ping_response.rb
150
182
  - lib/binance_client/responses/sub_account_assets_response.rb
183
+ - lib/binance_client/responses/sub_account_bnb_burn_status_response.rb
184
+ - lib/binance_client/responses/sub_account_create_api_keys_response.rb
151
185
  - lib/binance_client/responses/sub_account_deposit_address_response.rb
152
186
  - lib/binance_client/responses/sub_account_deposit_history_response.rb
187
+ - lib/binance_client/responses/sub_account_set_spot_bnb_burn_response.rb
188
+ - lib/binance_client/responses/sub_account_transfer_response.rb
153
189
  - lib/binance_client/responses/system_status_response.rb
190
+ - lib/binance_client/responses/withdraw_response.rb
154
191
  - lib/binance_client/version.rb
155
192
  homepage: https://github.com/bloom-solutions/binance_client-ruby
156
193
  licenses: