binance-ruby 1.3 → 1.3.4

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: 190868ad61fe8c03e60269a1e9162094fafe2691fa6845dc46cbf0bf7a456c65
4
- data.tar.gz: 35a0ec5120e37a65aef818fa1ddf2c7a4954a3f94fe32579e119cc4596a3a0e3
3
+ metadata.gz: b1538fd29aec53baa74e41f42d6dac10aca400ac6bbeddc3f275ac6e48eb0f70
4
+ data.tar.gz: 491b2a45f6f0cf654385f07a63f393e6447c05af101024d1c89fabc84264c24b
5
5
  SHA512:
6
- metadata.gz: 4aa2390fffc1850125cf4dcd6beb35c54e4b182bd0d2e0fa88a9fae9f41290440d05f4bf4b8279d43bed7fd4d5239a5f7eb7121014b47d0392da570a4f3ca496
7
- data.tar.gz: 66b7b1a9ce5f209dd7dfcceac63751cf24856a0f4e6c8a66bd8a4b9fba7cc56729d840b0d22e4a8e79457efcf42ac506b474bcaa00ece5896e8b6139b9996d3f
6
+ metadata.gz: 26b02e56210133ebe2528a3284e34ed57038ec6494f6d9d837d90752b256b51bf4bf9710f3a9bf28cb7a22932aed9b5413e84afc37afa5f1afe22bc1a5f4efff
7
+ data.tar.gz: d3c72b582249aae0a5ce27cf736867fc46077cf41870d01d7cd1d289d505af916d76c62c51d8e11496ed015ec88495b2a7b50c5bad0c84b2c0fa65985d59fd80
@@ -2,7 +2,7 @@ module Binance
2
2
  module Api
3
3
  class Account
4
4
  class << self
5
- def fees!(recvWindow: 5000, api_key: nil, api_secret_key: nil)
5
+ def fees!(recvWindow: nil, api_key: nil, api_secret_key: nil)
6
6
  timestamp = Configuration.timestamp
7
7
  params = { recvWindow: recvWindow, timestamp: timestamp }
8
8
  Request.send!(api_key_type: :read_info, path: "/wapi/v3/assetDetail.html",
@@ -10,7 +10,7 @@ module Binance
10
10
  security_type: :user_data, api_key: api_key, api_secret_key: api_secret_key)
11
11
  end
12
12
 
13
- def info!(recvWindow: 5000, api_key: nil, api_secret_key: nil)
13
+ def info!(recvWindow: nil, api_key: nil, api_secret_key: nil)
14
14
  timestamp = Configuration.timestamp
15
15
  params = { recvWindow: recvWindow, timestamp: timestamp }
16
16
  Request.send!(api_key_type: :read_info, path: "/api/v3/account",
@@ -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.3"
3
+ VERSION = "1.3.4"
4
4
  end
5
5
  end
data/lib/binance/api.rb CHANGED
@@ -1,12 +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
- params = { recvWindow: recvWindow }
6
- Request.send!(api_key_type: :read_info, path: "/sapi/v1/capital/config/getall", params: params,
7
- api_key: api_key, api_secret_key: api_secret_key)
8
- end
9
-
10
4
  # Valid limits:[5, 10, 20, 50, 100, 500, 1000]
11
5
  def candlesticks!(endTime: nil, interval: nil, limit: 500, startTime: nil, symbol: nil, api_key: nil, api_secret_key: nil)
12
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,4 +1,4 @@
1
- require "active_support/core_ext/string"
1
+ require "active_support"
2
2
  require "awrence"
3
3
  require "httparty"
4
4
  require "faye/websocket"
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'
4
+ version: 1.3.4
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-04 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
240
+ summary: binance-ruby-1.3.4
241
241
  test_files: []