binance-ruby 0.7 → 1.1.2
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 +4 -4
- data/lib/binance/api/configuration.rb +2 -3
- data/lib/binance/api/error.rb +90 -0
- data/lib/binance/api/order.rb +3 -3
- data/lib/binance/api/request.rb +2 -2
- data/lib/binance/api/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0b8a2d2b8699dd1ab11f5c4927f492f1083178f6c490b2f128bec3e17519142
|
4
|
+
data.tar.gz: d0f3a90df602d2218abb7a479ee239b25c45a3c556350cd1a044d0fff2e1d123
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e79efbfe09d9046dbec1de668d00e34811170eb5fa323f4b1999bc5586f960d9f7790093e753b861f6c2b7cf0af687cb3b12f3afa020a99d67426930dbec331
|
7
|
+
data.tar.gz: 16cfb386ab4ea3bfd87067b3cffbeca50145b7108453bff5edf95b84a1fe90a0f2a7caf21e8927b233624c86263f7fe8c6df3f691d10b4fffa628f20445d5089
|
@@ -9,9 +9,8 @@ module Binance
|
|
9
9
|
:trading_api_key, :withdrawals_api_key
|
10
10
|
|
11
11
|
def api_key(type: nil)
|
12
|
-
raise Error.new(message: "invalid
|
13
|
-
instance_api_key(type: type) || ENV["BINANCE_#{type.to_s.humanize.upcase}_API_KEY"] ||
|
14
|
-
instance_api_key || ENV["BINANCE_API_KEY"]
|
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"]
|
15
14
|
end
|
16
15
|
|
17
16
|
def tld
|
data/lib/binance/api/error.rb
CHANGED
@@ -8,6 +8,54 @@ module Binance
|
|
8
8
|
def is_error_response?(response:)
|
9
9
|
response.code >= 400
|
10
10
|
end
|
11
|
+
|
12
|
+
# https://github.com/binance/binance-spot-api-docs/blob/master/errors.md
|
13
|
+
def localized(message)
|
14
|
+
code = message.to_s.match(/\d+/).to_s.to_i
|
15
|
+
case code
|
16
|
+
when 1000 then Unknown
|
17
|
+
when 1001 then Disconnected
|
18
|
+
when 1002 then Unauthorized
|
19
|
+
when 1003 then TooManyRequests
|
20
|
+
when 1006 then UnexpectedResponse
|
21
|
+
when 1007 then Timeout
|
22
|
+
when 1013 then InvalidQuantity
|
23
|
+
when 1014 then UnknownOrderComposition
|
24
|
+
when 1015 then TooManyOrders
|
25
|
+
when 1016 then ServiceShuttingDown
|
26
|
+
when 1020 then UnsupportedOperation
|
27
|
+
when 1021 then InvalidTimestamp
|
28
|
+
when 1022 then InvalidSignature
|
29
|
+
when 1100 then IllegalChars
|
30
|
+
when 1101 then TooManyParameters
|
31
|
+
when 1102 then MandatoryParamEmptyOrMalformed
|
32
|
+
when 1103 then UnknownParam
|
33
|
+
when 1104 then UnreadParameters
|
34
|
+
when 1105 then ParamEmpty
|
35
|
+
when 1106 then ParamNotRequired
|
36
|
+
when 1111 then BadPrecision
|
37
|
+
when 1112 then NoDepth
|
38
|
+
when 1114 then TIFNotRequired
|
39
|
+
when 1115 then InvalidTIF
|
40
|
+
when 1116 then InvalidOrderType
|
41
|
+
when 1117 then InvalidSide
|
42
|
+
when 1118 then EmptyNewCLOrderId
|
43
|
+
when 1119 then EmptyOrgCLOrderId
|
44
|
+
when 1120 then BadInterval
|
45
|
+
when 1121 then BadSymbol
|
46
|
+
when 1125 then InvalidListenKey
|
47
|
+
when 1127 then IntervalTooLarge
|
48
|
+
when 1128 then OptionalParamsBadCombo
|
49
|
+
when 1130 then InvalidParameter
|
50
|
+
when 2010 then NewOrderRejected
|
51
|
+
when 2011 then CancelOrderRejected
|
52
|
+
when 2013 then NoSuchOrder
|
53
|
+
when 2014 then BadAPIKeyFormat
|
54
|
+
when 2015 then RejectedAPIKey
|
55
|
+
when 2016 then NoTradingWindow
|
56
|
+
else Binance::Api::Error
|
57
|
+
end
|
58
|
+
end
|
11
59
|
end
|
12
60
|
|
13
61
|
def initialize(code: nil, json: {}, message: nil, symbol: nil)
|
@@ -19,6 +67,7 @@ module Binance
|
|
19
67
|
def inspect
|
20
68
|
message = ""
|
21
69
|
message += "(#{code}) " unless code.nil?
|
70
|
+
message += "@#{symbol} " unless symbol.nil?
|
22
71
|
message += "#{msg}" unless msg.nil?
|
23
72
|
end
|
24
73
|
|
@@ -29,6 +78,47 @@ module Binance
|
|
29
78
|
def to_s
|
30
79
|
inspect
|
31
80
|
end
|
81
|
+
|
82
|
+
class Unknown < Error; end
|
83
|
+
class Disconnected < Error; end
|
84
|
+
class Unauthorized < Error; end
|
85
|
+
class TooManyRequests < Error; end
|
86
|
+
class UnexpectedResponse < Error; end
|
87
|
+
class Timeout < Error; end
|
88
|
+
class InvalidQuantity < Error; end
|
89
|
+
class UnknownOrderComposition < Error; end
|
90
|
+
class TooManyOrders < Error; end
|
91
|
+
class ServiceShuttingDown < Error; end
|
92
|
+
class UnsupportedOperation < Error; end
|
93
|
+
class InvalidTimestamp < Error; end
|
94
|
+
class InvalidSignature < Error; end
|
95
|
+
class IllegalChars < Error; end
|
96
|
+
class TooManyParameters < Error; end
|
97
|
+
class MandatoryParamEmptyOrMalformed < Error; end
|
98
|
+
class UnknownParam < Error; end
|
99
|
+
class UnreadParameters < Error; end
|
100
|
+
class ParamEmpty < Error; end
|
101
|
+
class ParamNotRequired < Error; end
|
102
|
+
class BadPrecision < Error; end
|
103
|
+
class NoDepth < Error; end
|
104
|
+
class TIFNotRequired < Error; end
|
105
|
+
class InvalidTIF < Error; end
|
106
|
+
class InvalidOrderType < Error; end
|
107
|
+
class InvalidSide < Error; end
|
108
|
+
class EmptyNewCLOrderId < Error; end
|
109
|
+
class EmptyOrgCLOrderId < Error; end
|
110
|
+
class BadInterval < Error; end
|
111
|
+
class BadSymbol < Error; end
|
112
|
+
class InvalidListenKey < Error; end
|
113
|
+
class IntervalTooLarge < Error; end
|
114
|
+
class OptionalParamsBadCombo < Error; end
|
115
|
+
class InvalidParameter < Error; end
|
116
|
+
class NewOrderRejected < Error; end
|
117
|
+
class CancelOrderRejected < Error; end
|
118
|
+
class NoSuchOrder < Error; end
|
119
|
+
class BadAPIKeyFormat < Error; end
|
120
|
+
class RejectedAPIKey < Error; end
|
121
|
+
class NoTradingWindow < Error; end
|
32
122
|
end
|
33
123
|
end
|
34
124
|
end
|
data/lib/binance/api/order.rb
CHANGED
@@ -37,12 +37,12 @@ module Binance
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def create!(icebergQuantity: nil, newClientOrderId: nil, newOrderResponseType: nil,
|
40
|
-
price: nil, quantity: nil, recvWindow: nil, stopPrice: nil, symbol: nil,
|
40
|
+
price: nil, quantity: nil, quoteOrderQty: nil, recvWindow: nil, stopPrice: nil, symbol: nil,
|
41
41
|
side: nil, type: nil, timeInForce: nil, test: false, api_key: nil, api_secret_key: nil)
|
42
42
|
timestamp = Configuration.timestamp
|
43
43
|
params = {
|
44
44
|
icebergQty: icebergQuantity, newClientOrderId: newClientOrderId,
|
45
|
-
newOrderRespType: newOrderResponseType, price: price, quantity: quantity,
|
45
|
+
newOrderRespType: newOrderResponseType, price: price, quantity: quantity, quoteOrderQty: quoteOrderQty,
|
46
46
|
recvWindow: recvWindow, stopPrice: stopPrice, symbol: symbol, side: side,
|
47
47
|
type: type, timeInForce: timeInForce, timestamp: timestamp,
|
48
48
|
}.delete_if { |key, value| value.nil? }
|
@@ -92,7 +92,7 @@ module Binance
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def required_create_keys
|
95
|
-
[:symbol, :side, :type, :
|
95
|
+
[:symbol, :side, :type, :timestamp].freeze
|
96
96
|
end
|
97
97
|
end
|
98
98
|
end
|
data/lib/binance/api/request.rb
CHANGED
@@ -3,7 +3,7 @@ module Binance
|
|
3
3
|
class Request
|
4
4
|
include HTTParty
|
5
5
|
class << self
|
6
|
-
def send!(api_key_type: :none, headers: {}, method: :get, path: "/", params: {}, security_type: :none, tld:
|
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
8
|
self.base_uri "https://api.binance.#{tld}"
|
9
9
|
|
@@ -44,7 +44,7 @@ module Binance
|
|
44
44
|
# binance 500 errors are html format
|
45
45
|
raise Error.new(message: error)
|
46
46
|
end
|
47
|
-
raise Error.new(json: json) if Error.is_error_response?(response: response)
|
47
|
+
raise Error.localized(json[:code]).new(json: json) if Error.is_error_response?(response: response)
|
48
48
|
json
|
49
49
|
end
|
50
50
|
|
data/lib/binance/api/version.rb
CHANGED
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:
|
4
|
+
version: 1.1.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-
|
11
|
+
date: 2021-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: codecov
|
@@ -203,8 +203,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
203
|
- !ruby/object:Gem::Version
|
204
204
|
version: '0'
|
205
205
|
requirements: []
|
206
|
-
rubygems_version: 3.
|
206
|
+
rubygems_version: 3.1.6
|
207
207
|
signing_key:
|
208
208
|
specification_version: 4
|
209
|
-
summary: binance-ruby-
|
209
|
+
summary: binance-ruby-1.1.2
|
210
210
|
test_files: []
|