binance-ruby 1.2.9 → 1.3.2

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: c692f93f4037603a5ccdeacd096c7f83f7c3b4c212555e62a30b7ac8ba0f8245
4
- data.tar.gz: 75cbbf7c87f7557ff078e29ae479b28530f50b3d26c22baa75ed69d99c5c1d72
3
+ metadata.gz: e4de51ede5570a5a06e9b4fa6714e7924eea9c161b6d369bfd017b7221221c5f
4
+ data.tar.gz: ba35f9071516ac5a1454c381fc1b04519b44f858f06389365aef938c759922ed
5
5
  SHA512:
6
- metadata.gz: bb3354015ac4a66d64c334e7a64b2e86885f0b8bfbe3ee527f5a6059f882dae6e5b4adc729da862d71f6ce12ffa696cb769ea6414938c29f7c0ed390216f0312
7
- data.tar.gz: efcdd0c9c5d5c0e411fbd04de3a87dce49b047b6cb633c3f8af4a7becbeede5bda76a8a244d2e94ca2980a9c3e97f0601973c10401aa0f0d69cfa71359e7a6f8
6
+ metadata.gz: 0cc40f3549aa3e01c58b83092ff681fa5e53a66bfdf0f03debdf9c506ac8d99d8345cdccc268101a0a14b8a2dc252fc160506000206089b4f58604e939a67de3
7
+ data.tar.gz: a96ce7998043da556176f95cba44029e50af747c77b1e739e1c0c51010b5dc1601e76cb0f598da5167872a7c7321ee2d1b77a65d6b264990e2d86d9a26312d7d
@@ -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
@@ -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.2.9"
3
+ VERSION = "1.3.2"
4
4
  end
5
5
  end
@@ -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
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.2.9
4
+ version: 1.3.2
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-03 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.2.9
240
+ summary: binance-ruby-1.3.2
241
241
  test_files: []