binance-ruby 1.3.6 → 1.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e27b5345af57e738af536dbc6693d1a6c73976eceed29c7e666307682707db5
4
- data.tar.gz: 35ca497977bebbbb9cf535d528c5b58dccf1bc6a4e4e384d6e8efb8e440bf431
3
+ metadata.gz: 48d629c5e7b7720c73ae445f82a31d786fb51183d403e58e659447f336fe0ea7
4
+ data.tar.gz: 70cbd682024d0e4ea652002fb723a70a2b7d31cdfcc830c69787ada7eadf2fe2
5
5
  SHA512:
6
- metadata.gz: e332e31370f0d994bc8294fb4df9ec946c9f32e5aa61cfa9ab0316cdb5c59467e83f154f1a36bf48bdcf854a95d5e76c3992aa781b08797a5c6eed73a7c04e66
7
- data.tar.gz: bc7f25f13b9621de4d389645336e62362e599d23383ed5e90a5148e6cdc519a74a3cd6f8e4f46e94c7a6bda26008a469940c02cbebbebbdab491bb8e3856dfb5
6
+ metadata.gz: 826c8667fcbbcbceea7961177d4c05e0dc960527b60b9387784703654237d244a40ff05bc7ba639ff79088266d6bdd89d2b4f7e1b0d1acbd573ceba622de0eaf
7
+ data.tar.gz: c26c5d87112adc36a786ad5fdae71cef2533aeb548a0e870c588b73d024994945562ee934a4df5fecd77f2b3def99c2bea11e3a802a90aa012b2aed524a293b7
@@ -57,6 +57,26 @@ module Binance
57
57
  params: params.delete_if { |key, value| value.nil? }, method: :get,
58
58
  security_type: :user_data, api_key: api_key, api_secret_key: api_secret_key)
59
59
  end
60
+
61
+ def deposit_history(fiatCurrency: nil, startTime: nil, endTime: nil, recvWindow: nil, api_key: nil, api_secret_key: nil)
62
+ timestamp = Configuration.timestamp
63
+ params = { fiatCurrency: fiatCurrency, startTime: startTime,
64
+ endTime: endTime, recvWindow: recvWindow, timestamp: timestamp,
65
+ }
66
+ Request.send!(api_key_type: :read_info, path: "/sapi/v1/fiatpayment/query/deposit/history",
67
+ params: params.delete_if { |key, value| value.nil? }, method: :get,
68
+ security_type: :user_data, api_key: api_key, api_secret_key: api_secret_key)
69
+ end
70
+
71
+ def withdraw_history(fiatCurrency: nil, startTime: nil, endTime: nil, recvWindow: nil, api_key: nil, api_secret_key: nil)
72
+ timestamp = Configuration.timestamp
73
+ params = { fiatCurrency: fiatCurrency, startTime: startTime,
74
+ endTime: endTime, recvWindow: recvWindow, timestamp: timestamp,
75
+ }
76
+ Request.send!(api_key_type: :read_info, path: "/sapi/v1/fiatpayment/query/withdraw/history",
77
+ params: params.delete_if { |key, value| value.nil? }, method: :get,
78
+ security_type: :user_data, api_key: api_key, api_secret_key: api_secret_key)
79
+ end
60
80
  end
61
81
  end
62
82
  end
@@ -36,6 +36,21 @@ module Binance
36
36
  api_key: api_key, api_secret_key: api_secret_key)
37
37
  end
38
38
 
39
+ def status!(orderId: nil, originalClientOrderId: nil, recvWindow: nil, symbol: nil,
40
+ api_key: nil, api_secret_key: nil)
41
+ raise Error.new(message: "symbol is required") if symbol.nil?
42
+ raise Error.new(message: "either orderid or originalclientorderid " \
43
+ "is required") if orderId.nil? && originalClientOrderId.nil?
44
+ timestamp = Configuration.timestamp
45
+ params = {
46
+ orderId: orderId, origClientOrderId: originalClientOrderId, recvWindow: recvWindow,
47
+ symbol: symbol, timestamp: timestamp,
48
+ }.delete_if { |key, value| value.nil? }
49
+ Request.send!(api_key_type: :trading, path: "/sapi/v1/margin/order",
50
+ params: params, security_type: :user_data, tld: Configuration.tld, api_key: api_key,
51
+ api_secret_key: api_secret_key)
52
+ end
53
+
39
54
  private
40
55
 
41
56
  def additional_required_create_keys(type:)
@@ -11,7 +11,7 @@ module Binance
11
11
  raise Error.new(message: "invalid security type #{security_type}") unless security_types.include?(security_type)
12
12
  all_headers = default_headers(api_key_type: api_key_type, security_type: security_type, api_key: api_key)
13
13
  params.delete_if { |k, v| v.nil? }
14
- if %w(trade user_data).include?(security_type&.to_s)
14
+ if %w(trade user_data margin).include?(security_type&.to_s)
15
15
  signature = signed_request_signature(params: params, api_secret_key: api_secret_key)
16
16
  params.merge!(signature: signature)
17
17
  end
@@ -15,6 +15,18 @@ module Binance
15
15
  security_type: :user_stream, api_key: api_key, api_secret_key: api_secret_key)[:listenKey]
16
16
  end
17
17
 
18
+ def margin_start!(api_key: nil, api_secret_key: nil)
19
+ Request.send!(api_key_type: :none, method: :post, path: "/sapi/v1/userDataStream",
20
+ security_type: :user_stream, api_key: api_key, api_secret_key: api_secret_key)[:listenKey]
21
+ end
22
+
23
+ def margin_keepalive!(listen_key: nil, api_key: nil, api_secret_key: nil)
24
+ raise Error.new(message: "listen_key is required") if listen_key.nil?
25
+ Request.send!(api_key_type: :none, method: :put, path: "/sapi/v1/userDataStream",
26
+ params: { listenKey: listen_key }, security_type: :user_stream,
27
+ api_key: api_key, api_secret_key: api_secret_key)
28
+ end
29
+
18
30
  def stop!(listen_key: nil, api_key: nil, api_secret_key: nil)
19
31
  raise Error.new(message: "listen_key is required") if listen_key.nil?
20
32
  Request.send!(api_key_type: :none, method: :delete, path: "/api/v1/userDataStream",
@@ -1,5 +1,5 @@
1
1
  module Binance
2
2
  module Api
3
- VERSION = "1.3.6"
3
+ VERSION = "1.4.0"
4
4
  end
5
5
  end
data/lib/binance/api.rb CHANGED
@@ -2,6 +2,10 @@ module Binance
2
2
  module Api
3
3
  class << self
4
4
  def all_coins_info!(recvWindow: nil, api_key: nil, api_secret_key: nil)
5
+ if Configuration.base_url.include?("testnet")
6
+ raise Error.new(message: "use mainnet for this method. testnet is meant for spot trading and order execution.")
7
+ end
8
+
5
9
  timestamp = Configuration.timestamp
6
10
  params = { recvWindow: recvWindow, timestamp: timestamp }
7
11
  Request.send!(api_key_type: :read_info, security_type: :user_data,
@@ -57,12 +61,18 @@ module Binance
57
61
  Request.send!(path: "/api/v1/ping")
58
62
  end
59
63
 
60
- def ticker!(symbol: nil, type: nil, api_key: nil, api_secret_key: nil)
64
+ def ticker!(symbol: nil, symbols: nil, type: nil, api_key: nil, api_secret_key: nil)
61
65
  ticker_type = type&.to_sym
62
66
  error_message = "type must be one of: #{ticker_types.join(", ")}. #{type} was provided."
63
67
  raise Error.new(message: error_message) unless ticker_types.include? ticker_type
64
68
  path = ticker_path(type: ticker_type)
65
- params = symbol ? { symbol: symbol } : {}
69
+ params = if symbol
70
+ { symbols: symbol }
71
+ elsif symbols
72
+ { symbols: symbols.to_s.delete(' ') }
73
+ else
74
+ {}
75
+ end
66
76
  Request.send!(api_key_type: :read_info, path: path, params: params,
67
77
  api_key: api_key, api_secret_key: api_secret_key)
68
78
  end
@@ -77,6 +87,13 @@ module Binance
77
87
  Request.send!(api_key_type: :read_info, path: "/api/v1/trades", params: params,
78
88
  api_key: api_key, api_secret_key: api_secret_key)
79
89
  end
90
+
91
+ def avg!(symbol: nil, api_key: nil, api_secret_key: nil)
92
+ raise Error.new(message: "symbol is required") unless symbol
93
+ params = { symbol: symbol }
94
+ Request.send!(api_key_type: :read_info, path: "/api/v3/avgPrice", params: params,
95
+ api_key: api_key, api_secret_key: api_secret_key)
96
+ end
80
97
 
81
98
  private
82
99
 
@@ -3,7 +3,9 @@ module Binance
3
3
  class Error < StandardError; end
4
4
 
5
5
  def initialize(on_open: nil, on_close: nil)
6
- super "wss://stream.binance.com:9443/stream", nil, ping: 180
6
+ wss_uri = ENV['BINANCE_TEST_NET_ENABLE'] ? "wss://testnet.binance.vision/stream" : "wss://stream.binance.com:9443/stream"
7
+
8
+ super wss_uri, nil, ping: 180
7
9
 
8
10
  @request_id_inc = 0
9
11
  @user_stream_handlers = {}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: binance-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.6
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Peterson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-09 00:00:00.000000000 Z
11
+ date: 2025-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codecov
@@ -234,8 +234,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
234
  - !ruby/object:Gem::Version
235
235
  version: '0'
236
236
  requirements: []
237
- rubygems_version: 3.1.6
237
+ rubygems_version: 3.4.10
238
238
  signing_key:
239
239
  specification_version: 4
240
- summary: binance-ruby-1.3.6
240
+ summary: binance-ruby-1.4.0
241
241
  test_files: []