binance-ruby 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/binance-ruby.rb +2 -0
- data/lib/binance/api/margin.rb +43 -0
- data/lib/binance/api/margin/account.rb +32 -0
- data/lib/binance/api/margin/order.rb +1 -1
- data/lib/binance/api/request.rb +1 -1
- data/lib/binance/api/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70b267cd8a07a02d51173391f07ec6df6b1ff5f11c7cc93a7abf5389ac9ee2f8
|
4
|
+
data.tar.gz: 75e99c55e95c0627051893e286c48111e1b216fd9b497bca9795a8dedf89486b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3892c1aa7a081f5e3effabdfac508a29df012d77670c094fa88c8cd134bdd1b9d84b5651a2cb70c24f94f9d604bb9c269de747f6ba5a29b2b2b538b6c8ed365b
|
7
|
+
data.tar.gz: 97d38f76d7a7d98ba141ec8c09abfd5700cf65852e34055e5c875138d3751d0d7f80b4bc028b5878f91e0b1f1b936f2516af37c680e8b94accc19c12c66b357e
|
data/lib/binance-ruby.rb
CHANGED
@@ -7,6 +7,8 @@ require "binance/api/account"
|
|
7
7
|
require "binance/api/configuration"
|
8
8
|
require "binance/api/data_stream"
|
9
9
|
require "binance/api/error"
|
10
|
+
require "binance/api/margin"
|
11
|
+
require "binance/api/margin/account"
|
10
12
|
require "binance/api/margin/order"
|
11
13
|
require "binance/api/order"
|
12
14
|
require "binance/api/request"
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Binance
|
2
|
+
module Api
|
3
|
+
module Margin
|
4
|
+
class << self
|
5
|
+
# Your Margin Wallet balance determines the amount of funds you can borrow,
|
6
|
+
# following a fixed rate of 5:1 (5x).
|
7
|
+
def borrow!(asset: nil, amount: nil, recvWindow: nil)
|
8
|
+
timestamp = Configuration.timestamp
|
9
|
+
params = {
|
10
|
+
asset: asset, amount: amount, recvWindow: recvWindow, timestamp: timestamp,
|
11
|
+
}.delete_if { |_, value| value.nil? }
|
12
|
+
ensure_required_keys!(params: params)
|
13
|
+
path = "/sapi/v1/margin/loan"
|
14
|
+
Request.send!(api_key_type: :trading, method: :post, path: path,
|
15
|
+
params: params, security_type: :margin, tld: Configuration.tld)
|
16
|
+
end
|
17
|
+
|
18
|
+
def repay!(asset: nil, isIsolated: nil, amount: nil, recvWindow: nil)
|
19
|
+
timestamp = Configuration.timestamp
|
20
|
+
params = {
|
21
|
+
asset: asset, amount: amount, recvWindow: recvWindow, timestamp: timestamp,
|
22
|
+
}.delete_if { |_, value| value.nil? }
|
23
|
+
ensure_required_keys!(params: params)
|
24
|
+
path = "/sapi/v1/margin/repay"
|
25
|
+
Request.send!(api_key_type: :trading, method: :post, path: path,
|
26
|
+
params: params, security_type: :margin, tld: Configuration.tld)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def ensure_required_keys!(params:)
|
32
|
+
keys = required_margin_keys.dup
|
33
|
+
missing_keys = keys.select { |key| params[key].nil? }
|
34
|
+
raise Error.new(message: "required keys are missing: #{missing_keys.join(", ")}") unless missing_keys.empty?
|
35
|
+
end
|
36
|
+
|
37
|
+
def required_margin_keys
|
38
|
+
[:asset, :amount, :timestamp].freeze
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Binance
|
2
|
+
module Api
|
3
|
+
module Margin
|
4
|
+
class Account
|
5
|
+
class << self
|
6
|
+
def transfer!(asset: nil, amount: nil, type: nil, recvWindow: nil)
|
7
|
+
timestamp = Configuration.timestamp
|
8
|
+
params = {
|
9
|
+
asset: asset, amount: amount, type: type, recvWindow: recvWindow, timestamp: timestamp,
|
10
|
+
}.delete_if { |_, value| value.nil? }
|
11
|
+
ensure_required_create_keys!(params: params)
|
12
|
+
path = "/sapi/v1/margin/transfer"
|
13
|
+
Request.send!(api_key_type: :trading, method: :post, path: path,
|
14
|
+
params: params, security_type: :margin, tld: Configuration.tld)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def ensure_required_create_keys!(params:)
|
20
|
+
keys = required_create_keys.dup
|
21
|
+
missing_keys = keys.select { |key| params[key].nil? }
|
22
|
+
raise Error.new(message: "required keys are missing: #{missing_keys.join(", ")}") unless missing_keys.empty?
|
23
|
+
end
|
24
|
+
|
25
|
+
def required_create_keys
|
26
|
+
[:asset, :amount, :type, :timestamp].freeze
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -18,7 +18,7 @@ module Binance
|
|
18
18
|
ensure_required_create_keys!(params: params)
|
19
19
|
path = "/sapi/v1/margin/order"
|
20
20
|
Request.send!(api_key_type: :trading, method: :post, path: path,
|
21
|
-
params: params, security_type: :
|
21
|
+
params: params, security_type: :margin, tld: Configuration.tld)
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
data/lib/binance/api/request.rb
CHANGED
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: 0.6.
|
4
|
+
version: 0.6.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-01-
|
11
|
+
date: 2021-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: codecov
|
@@ -177,6 +177,8 @@ files:
|
|
177
177
|
- lib/binance/api/configuration.rb
|
178
178
|
- lib/binance/api/data_stream.rb
|
179
179
|
- lib/binance/api/error.rb
|
180
|
+
- lib/binance/api/margin.rb
|
181
|
+
- lib/binance/api/margin/account.rb
|
180
182
|
- lib/binance/api/margin/order.rb
|
181
183
|
- lib/binance/api/order.rb
|
182
184
|
- lib/binance/api/request.rb
|
@@ -204,5 +206,5 @@ requirements: []
|
|
204
206
|
rubygems_version: 3.0.8
|
205
207
|
signing_key:
|
206
208
|
specification_version: 4
|
207
|
-
summary: binance-ruby-0.6.
|
209
|
+
summary: binance-ruby-0.6.2
|
208
210
|
test_files: []
|