binance-ruby 1.3.1 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eaed3bdcc2611924c8e1e6d361ce6e4634845da9da89a97e10c242e7367e7ea0
4
- data.tar.gz: 0ee997d53d85aa416ed36282c5646cbe088676ad17fbc81e7d0228830aebe8e2
3
+ metadata.gz: 6ae10cb9421b032971f775dec9f055dd795e99ed83f6f8725e83e3c1151e751a
4
+ data.tar.gz: 98da0f4dc796a0f7f50d4e717e0621e200fc7a9d7a8dda49aaa05e4cf5d87e39
5
5
  SHA512:
6
- metadata.gz: 9c3871752fac15616de6a866f5f9f399303bb27847fd740cd9071160c70694baa4ca8135244af491259281dde411b4ec9b3cb96809ec23e306f41b027f9cb60d
7
- data.tar.gz: 7e48535b7170dd65aa5a23bc707a7a934853e79e26b64a20db8c65e84ea0f46067b35254bab930d0eaf7d949f73832c8b6043d4b429533227ca9b2eea57abf30
6
+ metadata.gz: cdc92e1b0e1ff5a826789f1a3641d72a6f90affb57bdf43d72b539fa9a6cc8537adc9a129c1f632a7fb53680a437e65600a1aafa0ea227d637f1b9929691c404
7
+ data.tar.gz: 38091a9a534220cd234ef18ba2d2448a2eda1310e455ba88780ee6b6814aebf3a437935942ac66dc2db61bc35092945bd0f9764c047b7a66f7bbae88d885c192
@@ -10,7 +10,7 @@ module Binance
10
10
 
11
11
  def api_key(type: nil)
12
12
  raise Error.new(message: "invalid api_key type: #{type}.") unless type.nil? || api_key_types.include?(type)
13
- instance_api_key(type: type) || ENV["BINANCE_#{type.to_s.humanize.upcase}_API_KEY"] || ENV["BINANCE_API_KEY"]
13
+ instance_api_key(type: type) || ENV["BINANCE_#{type.to_s.humanize.upcase}_API_KEY"] || instance_api_key || ENV["BINANCE_API_KEY"]
14
14
  end
15
15
 
16
16
  def tld
@@ -14,7 +14,7 @@ module Binance
14
14
  end
15
15
 
16
16
  # Be careful when accessing without a symbol!
17
- def all_open!(recvWindow: nil, symbol: nil, api_key: nil, api_secret_key: nil)
17
+ def all_open!(recvWindow: 5000, symbol: nil, api_key: nil, api_secret_key: nil)
18
18
  timestamp = Configuration.timestamp
19
19
  params = { recvWindow: recvWindow, symbol: symbol, timestamp: timestamp }
20
20
  Request.send!(api_key_type: :read_info, path: "/api/v3/openOrders",
@@ -5,7 +5,8 @@ module Binance
5
5
  class << self
6
6
  def send!(api_key_type: :none, headers: {}, method: :get, path: "/", params: {}, security_type: :none, tld: Configuration.tld, api_key: nil, api_secret_key: nil)
7
7
  Configuration.validate_tld!(tld)
8
- self.base_uri "https://api.binance.#{tld}"
8
+ binance_uri = ENV['BINANCE_TEST_NET_ENABLE'] ? "https://testnet.binance.vision" : "https://api.binance.#{tld}"
9
+ self.base_uri binance_uri
9
10
 
10
11
  raise Error.new(message: "invalid security type #{security_type}") unless security_types.include?(security_type)
11
12
  all_headers = default_headers(api_key_type: api_key_type, security_type: security_type, api_key: api_key)
@@ -1,5 +1,5 @@
1
1
  module Binance
2
2
  module Api
3
- VERSION = "1.3.1"
3
+ VERSION = "1.3.5"
4
4
  end
5
5
  end
data/lib/binance/api.rb CHANGED
@@ -1,14 +1,6 @@
1
1
  module Binance
2
2
  module Api
3
3
  class << self
4
- def all_coins_info!(recvWindow: nil, api_key: nil, api_secret_key: nil)
5
- timestamp = Configuration.timestamp
6
- params = { recvWindow: recvWindow, timestamp: timestamp }
7
- Request.send!(api_key_type: :read_info, security_type: :user_data,
8
- path: "/sapi/v1/capital/config/getall", params: params,
9
- api_key: api_key, api_secret_key: api_secret_key)
10
- end
11
-
12
4
  # Valid limits:[5, 10, 20, 50, 100, 500, 1000]
13
5
  def candlesticks!(endTime: nil, interval: nil, limit: 500, startTime: nil, symbol: nil, api_key: nil, api_secret_key: nil)
14
6
  raise Error.new(message: "interval is required") unless interval
@@ -58,6 +58,26 @@ module Binance
58
58
  subscribe([listen_key])
59
59
  end
60
60
 
61
+ # stream name: <symbol>@trade
62
+ # {
63
+ # "e": "trade", // Event type
64
+ # "E": 123456789, // Event time
65
+ # "s": "BNBBTC", // Symbol
66
+ # "t": 12345, // Trade ID
67
+ # "p": "0.001", // Price
68
+ # "q": "100", // Quantity
69
+ # "b": 88, // Buyer order ID
70
+ # "a": 50, // Seller order ID
71
+ # "T": 123456785, // Trade time
72
+ # "m": true, // Is the buyer the market maker?
73
+ # "M": true // Ignore
74
+ # }
75
+ def trades!(symbols, &on_receive)
76
+ symbols_fmt = symbols.is_a?(String) ? [symbols] : symbols
77
+ @trades_handler = on_receive
78
+ subscribe(symbols_fmt.map { |s| "#{s.downcase}@trade" })
79
+ end
80
+
61
81
  private
62
82
 
63
83
  def process_data(data)
@@ -75,6 +95,8 @@ module Binance
75
95
  when :executionReport # order update
76
96
  listen_key = json[:stream]
77
97
  @user_stream_handlers[listen_key]&.call(listen_key, json[:data])
98
+ when :trade
99
+ @trades_handler&.call(json[:stream], json[:data])
78
100
  end
79
101
  end
80
102
  end
data/lib/binance-ruby.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "active_support"
1
2
  require "active_support/core_ext/string"
2
3
  require "awrence"
3
4
  require "httparty"
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.1
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Peterson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-06 00:00:00.000000000 Z
11
+ date: 2022-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codecov
@@ -237,5 +237,5 @@ requirements: []
237
237
  rubygems_version: 3.1.6
238
238
  signing_key:
239
239
  specification_version: 4
240
- summary: binance-ruby-1.3.1
240
+ summary: binance-ruby-1.3.5
241
241
  test_files: []