binance 0.4.3 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/binance/client/rest.rb +21 -96
- data/lib/binance/client/rest/clients.rb +54 -0
- data/lib/binance/client/rest/endpoints.rb +40 -0
- data/lib/binance/client/rest/methods.rb +104 -0
- data/lib/binance/client/rest/sign_request_middleware.rb +2 -2
- data/lib/binance/version.rb +1 -1
- metadata +6 -7
- data/lib/binance/client/rest/account_api.rb +0 -192
- data/lib/binance/client/rest/api_endpoints.rb +0 -38
- data/lib/binance/client/rest/public_api.rb +0 -149
- data/lib/binance/client/rest/withdraw_api.rb +0 -83
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7fcb362280e04bbc111de254eb77f58fd346e2e5c26d636f087d6b103d5102f9
|
4
|
+
data.tar.gz: 8e541c5ffc985e1d6b969cc71efe4830f387e3055f08252c9d8bab2aff217cdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9018d7c13dd2c2b3dd9d622c230084a36b8c3cf02f4439bb6aa40d46f0e7ee7f5c734b2b6b12ce6263bab566a3b54fd5244b8e81f758977eabb190a2387a1d4
|
7
|
+
data.tar.gz: 101101bcb98d3dbb6782a7dafc9b072216aa7def8468843b0f1ee0b5a3ee704e973b5ebfa5dc6f0e76ffe936cc2f6e5dbe9110a4c40f1abee4ec45aa6cd1ead3
|
data/lib/binance/client/rest.rb
CHANGED
@@ -1,122 +1,47 @@
|
|
1
1
|
|
2
2
|
require 'faraday'
|
3
|
-
require 'faraday_middleware'
|
4
3
|
|
5
4
|
require_relative 'rest/sign_request_middleware'
|
6
5
|
require_relative 'rest/timestamp_request_middleware'
|
7
|
-
|
8
|
-
require_relative 'rest/
|
9
|
-
require_relative 'rest/
|
10
|
-
require_relative 'rest/withdraw_api'
|
11
|
-
|
12
|
-
require_relative 'rest/api_endpoints'
|
6
|
+
require_relative 'rest/clients'
|
7
|
+
require_relative 'rest/endpoints'
|
8
|
+
require_relative 'rest/methods'
|
13
9
|
|
14
10
|
module Binance
|
15
11
|
module Client
|
16
|
-
# Public: Client with methods mirroring the Binance REST APIs
|
17
12
|
class REST
|
18
|
-
# Public: String base url for REST client to use
|
19
13
|
BASE_URL = 'https://api.binance.com'.freeze
|
20
14
|
|
21
|
-
include PublicAPI
|
22
|
-
include AccountAPI
|
23
|
-
include WithdrawAPI
|
24
|
-
|
25
|
-
# Public: Initialize a REST Client
|
26
|
-
#
|
27
|
-
# :api_key - The String API key to authenticate (Default = '').
|
28
|
-
#
|
29
|
-
# :secret_key - The String secret key to authenticate (Default = '').
|
30
|
-
#
|
31
|
-
# :adapter - The Faraday::Adapter to be used for the client
|
32
|
-
# (Default = Faraday.default_adapter).
|
33
15
|
def initialize(api_key: '', secret_key: '',
|
34
16
|
adapter: Faraday.default_adapter)
|
35
|
-
@
|
36
|
-
|
37
|
-
@
|
38
|
-
|
39
|
-
@
|
40
|
-
|
41
|
-
@library[:signed] = signed_client api_key, secret_key, adapter
|
42
|
-
# Endpoint requires an api_key and secret_key - for the Withdraw API
|
43
|
-
@library[:withdraw] = withdraw_client api_key, secret_key, adapter
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
def public_client(adapter)
|
50
|
-
Faraday.new(url: "#{BASE_URL}/api") do |conn|
|
51
|
-
conn.request :json
|
52
|
-
conn.response :json, content_type: /\bjson$/
|
53
|
-
conn.adapter adapter
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def signed_client(api_key, secret_key, adapter)
|
58
|
-
Faraday.new(url: "#{BASE_URL}/api") do |conn|
|
59
|
-
conn.request :json
|
60
|
-
conn.response :json, content_type: /\bjson$/
|
61
|
-
conn.headers['X-MBX-APIKEY'] = api_key
|
62
|
-
conn.use TimestampRequestMiddleware
|
63
|
-
conn.use SignRequestMiddleware, secret_key
|
64
|
-
conn.adapter adapter
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def withdraw_client(api_key, secret_key, adapter)
|
69
|
-
Faraday.new(url: "#{BASE_URL}/wapi") do |conn|
|
70
|
-
conn.request :url_encoded
|
71
|
-
conn.response :json, content_type: /\bjson$/
|
72
|
-
conn.headers['X-MBX-APIKEY'] = api_key
|
73
|
-
conn.use TimestampRequestMiddleware
|
74
|
-
conn.use SignRequestMiddleware, secret_key
|
75
|
-
conn.adapter adapter
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def verified_client(api_key, adapter)
|
80
|
-
Faraday.new(url: "#{BASE_URL}/api") do |conn|
|
81
|
-
conn.response :json, content_type: /\bjson$/
|
82
|
-
conn.headers['X-MBX-APIKEY'] = api_key
|
83
|
-
conn.adapter adapter
|
84
|
-
end
|
17
|
+
@clients = {}
|
18
|
+
@clients[:public] = public_client adapter
|
19
|
+
@clients[:verified] = verified_client api_key, adapter
|
20
|
+
@clients[:signed] = signed_client api_key, secret_key, adapter
|
21
|
+
@clients[:withdraw] = withdraw_client api_key, secret_key, adapter
|
22
|
+
@clients[:public_withdraw] = public_withdraw_client adapter
|
85
23
|
end
|
86
24
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
# from.
|
95
|
-
#
|
96
|
-
# options - The Hash which hosts various REST query params. (Default = {})
|
97
|
-
# Each endpoint will have their own required and optional
|
98
|
-
# params.
|
99
|
-
def request(api, method, endpoint, options = {})
|
100
|
-
response = @library[api].send(method) do |req|
|
101
|
-
req.url API_ENDPOINTS[endpoint]
|
102
|
-
req.params.merge! options
|
25
|
+
METHODS.each do |method|
|
26
|
+
define_method(method[:name]) do |options = {}|
|
27
|
+
response = @clients[method[:client]].send(method[:action]) do |req|
|
28
|
+
req.url ENDPOINTS[method[:endpoint]]
|
29
|
+
req.params.merge! options.map { |k, v| [camelize(k.to_s), v] }.to_h
|
30
|
+
end
|
31
|
+
response.body
|
103
32
|
end
|
104
|
-
|
105
|
-
response.body
|
106
33
|
end
|
107
34
|
|
108
|
-
# Internal: Append key-value pair to REST query string
|
109
|
-
#
|
110
|
-
# query - The String of the existing request query url.
|
111
|
-
#
|
112
|
-
# key - The String that represents the param type.
|
113
|
-
#
|
114
|
-
# value - The String that represents the param value.
|
115
35
|
def self.add_query_param(query, key, value)
|
116
36
|
query = query.to_s
|
117
37
|
query << '&' unless query.empty?
|
118
38
|
query << "#{Faraday::Utils.escape key}=#{Faraday::Utils.escape value}"
|
119
39
|
end
|
40
|
+
|
41
|
+
def camelize(str)
|
42
|
+
str.split('_')
|
43
|
+
.map.with_index { |word, i| i.zero? ? word : word.capitalize }.join
|
44
|
+
end
|
120
45
|
end
|
121
46
|
end
|
122
47
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
|
2
|
+
require 'faraday_middleware'
|
3
|
+
|
4
|
+
module Binance
|
5
|
+
module Client
|
6
|
+
class REST
|
7
|
+
def public_client(adapter)
|
8
|
+
Faraday.new(url: "#{BASE_URL}/api") do |conn|
|
9
|
+
conn.request :json
|
10
|
+
conn.response :json, content_type: /\bjson$/
|
11
|
+
conn.adapter adapter
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def verified_client(api_key, adapter)
|
16
|
+
Faraday.new(url: "#{BASE_URL}/api") do |conn|
|
17
|
+
conn.response :json, content_type: /\bjson$/
|
18
|
+
conn.headers['X-MBX-APIKEY'] = api_key
|
19
|
+
conn.adapter adapter
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def signed_client(api_key, secret_key, adapter)
|
24
|
+
Faraday.new(url: "#{BASE_URL}/api") do |conn|
|
25
|
+
conn.request :json
|
26
|
+
conn.response :json, content_type: /\bjson$/
|
27
|
+
conn.headers['X-MBX-APIKEY'] = api_key
|
28
|
+
conn.use TimestampRequestMiddleware
|
29
|
+
conn.use SignRequestMiddleware, secret_key
|
30
|
+
conn.adapter adapter
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def public_withdraw_client(adapter)
|
35
|
+
Faraday.new(url: "#{BASE_URL}/wapi") do |conn|
|
36
|
+
conn.request :json
|
37
|
+
conn.response :json, content_type: /\bjson$/
|
38
|
+
conn.adapter adapter
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def withdraw_client(api_key, secret_key, adapter)
|
43
|
+
Faraday.new(url: "#{BASE_URL}/wapi") do |conn|
|
44
|
+
conn.request :url_encoded
|
45
|
+
conn.response :json, content_type: /\bjson$/
|
46
|
+
conn.headers['X-MBX-APIKEY'] = api_key
|
47
|
+
conn.use TimestampRequestMiddleware
|
48
|
+
conn.use SignRequestMiddleware, secret_key
|
49
|
+
conn.adapter adapter
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
module Binance
|
3
|
+
module Client
|
4
|
+
class REST
|
5
|
+
ENDPOINTS = {
|
6
|
+
# Public API Endpoints
|
7
|
+
ping: 'v1/ping',
|
8
|
+
time: 'v1/time',
|
9
|
+
exchange_info: 'v1/exchangeInfo',
|
10
|
+
products: '/exchange/public/products',
|
11
|
+
depth: 'v1/depth',
|
12
|
+
trades: 'v1/trades',
|
13
|
+
historical_trades: 'v1/historicalTrades',
|
14
|
+
agg_trades: 'v1/aggTrades',
|
15
|
+
klines: 'v1/klines',
|
16
|
+
twenty_four_hour: 'v1/ticker/24hr',
|
17
|
+
price: 'v3/ticker/price',
|
18
|
+
book_ticker: 'v3/ticker/bookTicker',
|
19
|
+
|
20
|
+
# Account API Endpoints
|
21
|
+
order: 'v3/order',
|
22
|
+
test_order: 'v3/order/test',
|
23
|
+
open_orders: 'v3/openOrders',
|
24
|
+
all_orders: 'v3/allOrders',
|
25
|
+
account: 'v3/account',
|
26
|
+
my_trades: 'v3/myTrades',
|
27
|
+
user_data_stream: 'v1/userDataStream',
|
28
|
+
|
29
|
+
# Withdraw API Endpoints
|
30
|
+
withdraw: 'v3/withdraw.html',
|
31
|
+
deposit_history: 'v3/depositHistory.html',
|
32
|
+
withdraw_history: 'v3/withdrawHistory.html',
|
33
|
+
deposit_address: 'v3/depositAddress.html',
|
34
|
+
account_status: 'v3/accountStatus.html',
|
35
|
+
system_status: 'v3/systemStatus.html',
|
36
|
+
withdraw_fee: 'v3/withdrawFee.html'
|
37
|
+
}.freeze
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
|
2
|
+
module Binance
|
3
|
+
module Client
|
4
|
+
class REST
|
5
|
+
METHODS = [
|
6
|
+
# Public API Methods
|
7
|
+
# #ping
|
8
|
+
{ name: :ping, client: :public,
|
9
|
+
action: :get, endpoint: :ping },
|
10
|
+
# #time
|
11
|
+
{ name: :time, client: :public,
|
12
|
+
action: :get, endpoint: :time },
|
13
|
+
# #exchange_info
|
14
|
+
{ name: :exchange_info, client: :public,
|
15
|
+
action: :get, endpoint: :exchange_info },
|
16
|
+
# #products
|
17
|
+
{ name: :products, client: :public,
|
18
|
+
action: :get, endpoint: :products },
|
19
|
+
# #depth
|
20
|
+
{ name: :depth, client: :public,
|
21
|
+
action: :get, endpoint: :depth },
|
22
|
+
# #trades
|
23
|
+
{ name: :trades, client: :public,
|
24
|
+
action: :get, endpoint: :trades },
|
25
|
+
# #historical_trades
|
26
|
+
{ name: :historical_trades, client: :verified,
|
27
|
+
action: :get, endpoint: :historical_trades },
|
28
|
+
# #agg_trades
|
29
|
+
{ name: :agg_trades, client: :public,
|
30
|
+
action: :get, endpoint: :agg_trades },
|
31
|
+
# #klines
|
32
|
+
{ name: :klines, client: :public,
|
33
|
+
action: :get, endpoint: :klines },
|
34
|
+
# #twenty_four_hour
|
35
|
+
{ name: :twenty_four_hour, client: :public,
|
36
|
+
action: :get, endpoint: :twenty_four_hour },
|
37
|
+
# #price
|
38
|
+
{ name: :price, client: :public,
|
39
|
+
action: :get, endpoint: :price },
|
40
|
+
# #book_ticker
|
41
|
+
{ name: :book_ticker, client: :public,
|
42
|
+
action: :get, endpoint: :book_ticker },
|
43
|
+
|
44
|
+
# Account API Methods
|
45
|
+
# #create_order!
|
46
|
+
{ name: :create_order!, client: :signed,
|
47
|
+
action: :post, endpoint: :order },
|
48
|
+
# #create_test_order
|
49
|
+
{ name: :create_test_order, client: :signed,
|
50
|
+
action: :post, endpoint: :test_order },
|
51
|
+
# #query_order
|
52
|
+
{ name: :query_order, client: :signed,
|
53
|
+
action: :get, endpoint: :order },
|
54
|
+
# #cancel_order!
|
55
|
+
{ name: :cancel_order!, client: :signed,
|
56
|
+
action: :delete, endpoint: :order },
|
57
|
+
# #open_orders
|
58
|
+
{ name: :open_orders, client: :signed,
|
59
|
+
action: :get, endpoint: :open_orders },
|
60
|
+
# #all_orders
|
61
|
+
{ name: :all_orders, client: :signed,
|
62
|
+
action: :get, endpoint: :all_orders },
|
63
|
+
# #account_info
|
64
|
+
{ name: :account_info, client: :signed,
|
65
|
+
action: :get, endpoint: :account_info },
|
66
|
+
# #my_trades
|
67
|
+
{ name: :my_trades, client: :signed,
|
68
|
+
action: :get, endpoint: :my_trades },
|
69
|
+
# #listen_key
|
70
|
+
{ name: :listen_key, client: :verified,
|
71
|
+
action: :post, endpoint: :user_data_stream },
|
72
|
+
# #keep_alive_stream!
|
73
|
+
{ name: :keep_alive_stream!, client: :verified,
|
74
|
+
action: :put, endpoint: :user_data_stream },
|
75
|
+
# #close_stream!
|
76
|
+
{ name: :close_stream!, client: :verified,
|
77
|
+
action: :delete, endpoint: :user_data_stream },
|
78
|
+
|
79
|
+
# Withdraw API Methods
|
80
|
+
# #withdraw!
|
81
|
+
{ name: :withdraw!, client: :withdraw,
|
82
|
+
action: :post, endpoint: :withdraw },
|
83
|
+
# #deposit_history
|
84
|
+
{ name: :deposit_history, client: :withdraw,
|
85
|
+
action: :get, endpoint: :deposit_history },
|
86
|
+
# #withdraw_history
|
87
|
+
{ name: :withdraw_history, client: :withdraw,
|
88
|
+
action: :get, endpoint: :withdraw_history },
|
89
|
+
# #deposit_address
|
90
|
+
{ name: :deposit_address, client: :withdraw,
|
91
|
+
action: :get, endpoint: :deposit_address },
|
92
|
+
# #account_status
|
93
|
+
{ name: :account_status, client: :withdraw,
|
94
|
+
action: :get, endpoint: :account_status },
|
95
|
+
# #system_status
|
96
|
+
{ name: :system_status, client: :public_withdraw,
|
97
|
+
action: :get, endpoint: :system_status },
|
98
|
+
# #withdraw_fee
|
99
|
+
{ name: :withdraw_fee, client: :withdraw,
|
100
|
+
action: :get, endpoint: :withdraw_fee }
|
101
|
+
].freeze
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -5,10 +5,10 @@ module Binance
|
|
5
5
|
# Sign the query string using HMAC(sha-256) and appends to query string
|
6
6
|
SignRequestMiddleware = Struct.new(:app, :secret_key) do
|
7
7
|
def call(env)
|
8
|
-
|
8
|
+
hash = OpenSSL::HMAC.hexdigest(
|
9
9
|
OpenSSL::Digest.new('sha256'), secret_key, env.url.query
|
10
10
|
)
|
11
|
-
env.url.query = REST.add_query_param(env.url.query, 'signature',
|
11
|
+
env.url.query = REST.add_query_param(env.url.query, 'signature', hash)
|
12
12
|
|
13
13
|
app.call env
|
14
14
|
end
|
data/lib/binance/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: binance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0
|
4
|
+
version: '1.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charles Ray Shisler III
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -105,12 +105,11 @@ files:
|
|
105
105
|
- bin/setup
|
106
106
|
- lib/binance.rb
|
107
107
|
- lib/binance/client/rest.rb
|
108
|
-
- lib/binance/client/rest/
|
109
|
-
- lib/binance/client/rest/
|
110
|
-
- lib/binance/client/rest/
|
108
|
+
- lib/binance/client/rest/clients.rb
|
109
|
+
- lib/binance/client/rest/endpoints.rb
|
110
|
+
- lib/binance/client/rest/methods.rb
|
111
111
|
- lib/binance/client/rest/sign_request_middleware.rb
|
112
112
|
- lib/binance/client/rest/timestamp_request_middleware.rb
|
113
|
-
- lib/binance/client/rest/withdraw_api.rb
|
114
113
|
- lib/binance/client/websocket.rb
|
115
114
|
- lib/binance/version.rb
|
116
115
|
homepage: https://github.com/craysiii/binance
|
@@ -133,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
132
|
version: '0'
|
134
133
|
requirements: []
|
135
134
|
rubyforge_project:
|
136
|
-
rubygems_version: 2.
|
135
|
+
rubygems_version: 2.7.3
|
137
136
|
signing_key:
|
138
137
|
specification_version: 4
|
139
138
|
summary: API Wrapper for the Binance cryptocurrency exchange.
|
@@ -1,192 +0,0 @@
|
|
1
|
-
|
2
|
-
module Binance
|
3
|
-
module Client
|
4
|
-
class REST
|
5
|
-
# Public: A module containing all of the Account API endpoints
|
6
|
-
module AccountAPI
|
7
|
-
# Public: Create a new order on the specified symbol for the
|
8
|
-
# authenticated account
|
9
|
-
#
|
10
|
-
# options - The Hash which hosts various REST query params.
|
11
|
-
# :symbol - The String of which trading pair to create the
|
12
|
-
# order on.
|
13
|
-
# :side - The String determining which side to create the
|
14
|
-
# order on.
|
15
|
-
# :type - The String determining what type of order it is.
|
16
|
-
# :timeInForce - The String determining what the time in force is
|
17
|
-
# (optional).
|
18
|
-
# :quantity - The String determining the amount of assets to
|
19
|
-
# purchase.
|
20
|
-
# :price - The String determining what price to purchase at
|
21
|
-
# (optional).
|
22
|
-
# :newClientOrderId - The String which uniquely identifies this order
|
23
|
-
# (optional).
|
24
|
-
# :stopPrice - The String determining which price to stop at
|
25
|
-
# (optional).
|
26
|
-
# :icebergQty - The String determining the amount of assets to
|
27
|
-
# show on the order book (optional).
|
28
|
-
# :newOrderRespType - The String which sets the type of response to
|
29
|
-
# receive (optional).
|
30
|
-
# :recvWindow - The Number of how long a request is valid for
|
31
|
-
# in milliseconds (optional).
|
32
|
-
#
|
33
|
-
# Returns a Hash of the request response
|
34
|
-
def create_order(options)
|
35
|
-
request :signed, :post, :order, options
|
36
|
-
end
|
37
|
-
|
38
|
-
# Public: Create a test order on the specified symbol for the
|
39
|
-
# authenticated account
|
40
|
-
#
|
41
|
-
# options - The Hash which hosts various REST query params.
|
42
|
-
# :symbol - The String of which trading pair to create the
|
43
|
-
# order on.
|
44
|
-
# :side - The String determining which side to create the
|
45
|
-
# order on.
|
46
|
-
# :type - The String determining what type of order it is.
|
47
|
-
# :timeInForce - The String determining what the time in force is
|
48
|
-
# (optional).
|
49
|
-
# :quantity - The String determining the amount of assets to
|
50
|
-
# purchase.
|
51
|
-
# :price - The String determining what price to purchase at
|
52
|
-
# (optional).
|
53
|
-
# :newClientOrderId - The String which uniquely identifies this order
|
54
|
-
# (optional).
|
55
|
-
# :stopPrice - The String determining which price to stop at
|
56
|
-
# (optional).
|
57
|
-
# :icebergQty - The String determining the amount of assets to
|
58
|
-
# show on the order book (optional).
|
59
|
-
# :newOrderRespType - The String which sets the type of response to
|
60
|
-
# receive (optional).
|
61
|
-
# :recvWindow - The Number of how long a request is valid for
|
62
|
-
# in milliseconds (optional).
|
63
|
-
#
|
64
|
-
# Returns a Hash of the request response
|
65
|
-
def create_test_order(options)
|
66
|
-
request :signed, :post, :order_test, options
|
67
|
-
end
|
68
|
-
|
69
|
-
# Public: Query an orders status on the specified symbol for the
|
70
|
-
# authenticated account. One must send either an :orderId or
|
71
|
-
# :origOrderId, but not both.
|
72
|
-
#
|
73
|
-
# options - The Hash which hosts various REST query params.
|
74
|
-
# :symbol - The String of which trading pair to query from
|
75
|
-
# (optional).
|
76
|
-
# :orderId - The String determining which order to query
|
77
|
-
# (optional).
|
78
|
-
# :origClientOrderId - The String determining which order to cancel
|
79
|
-
# (optional).
|
80
|
-
# :recvWindow - The Number of how long a request is valid for
|
81
|
-
# in milliseconds (optional).
|
82
|
-
#
|
83
|
-
# Returns a Hash of the request response
|
84
|
-
def query_order(options)
|
85
|
-
request :signed, :get, :order, options
|
86
|
-
end
|
87
|
-
|
88
|
-
# Public: Cancel the order specified for the authenticated account.
|
89
|
-
# One must send either an :orderId or :origOrderId, but not both.
|
90
|
-
#
|
91
|
-
# options - The Hash which hosts various REST query params.
|
92
|
-
# :symbol - The String of which trading pair to delete from
|
93
|
-
# (optional).
|
94
|
-
# :orderId - The String determining which order to cancel
|
95
|
-
# (optional).
|
96
|
-
# :origClientOrderId - The String determining which order to cancel
|
97
|
-
# (optional).
|
98
|
-
# :newClientOrderId - The String used in uniquely identifying the
|
99
|
-
# cancel order (optional).
|
100
|
-
# :recvWindow - The Number of how long a request is valid for
|
101
|
-
# in milliseconds (optional).
|
102
|
-
#
|
103
|
-
# Returns a Hash with the request response
|
104
|
-
def cancel_order(options)
|
105
|
-
request :signed, :delete, :order, options
|
106
|
-
end
|
107
|
-
|
108
|
-
# Public: Retrieve open orders for the authenticated account
|
109
|
-
#
|
110
|
-
# options - The Hash which hosts various REST query params.
|
111
|
-
# :symbol - The String of which trading pair to retrieve
|
112
|
-
# (optional).
|
113
|
-
# :recvWindow - The Number of how long a request is valid for in
|
114
|
-
# milliseconds (optional).
|
115
|
-
#
|
116
|
-
# Returns a Hash with the request response
|
117
|
-
def open_orders(options = {})
|
118
|
-
request :signed, :get, :openOrders, options
|
119
|
-
end
|
120
|
-
|
121
|
-
# Public: Retrieve all orders of the specified symbol for the
|
122
|
-
# authenticated account
|
123
|
-
#
|
124
|
-
# options - The Hash which hosts various REST query params.
|
125
|
-
# :symbol - The String of which trading pair to retrieve.
|
126
|
-
# :orderId - The String determining which order to start the data
|
127
|
-
# from (optional).
|
128
|
-
# :limit - The Number of how many trades to request (optional).
|
129
|
-
# :recvWindow - The Number of how long a request is valid for in
|
130
|
-
# milliseconds (optional).
|
131
|
-
#
|
132
|
-
# Returns a Hash with the request response
|
133
|
-
def all_orders(options)
|
134
|
-
request :signed, :get, :allOrders, options
|
135
|
-
end
|
136
|
-
|
137
|
-
# Public: Retrieve account information for the authenticated account
|
138
|
-
#
|
139
|
-
# options - The Hash which hosts various REST query params.
|
140
|
-
# :recvWindow - The Number of how long a request is valid for in
|
141
|
-
# milliseconds (optional).
|
142
|
-
#
|
143
|
-
# Returns a Hash with the request response
|
144
|
-
def account_info(options = {})
|
145
|
-
request :signed, :get, :account, options
|
146
|
-
end
|
147
|
-
|
148
|
-
# Public: Retrieve trade data of the specified symbol for the
|
149
|
-
# authenticated account
|
150
|
-
#
|
151
|
-
# options - The Hash which hosts various REST query params.
|
152
|
-
# :symbol - The String of which trading pair to retrieve.
|
153
|
-
# :limit - The Number of how many trades to request (optional).
|
154
|
-
# :fromId - The String of which trade ID to fetch from (optional).
|
155
|
-
# :recvWindow - The Number of how long a request is valid for in
|
156
|
-
# milliseconds (optional).
|
157
|
-
#
|
158
|
-
# Returns a Hash with the request response
|
159
|
-
def account_trade_list(options)
|
160
|
-
request :signed, :get, :myTrades, options
|
161
|
-
end
|
162
|
-
|
163
|
-
# Public: Retrieve the listen key for the given api key
|
164
|
-
#
|
165
|
-
# Returns a Hash with the request response
|
166
|
-
def listen_key
|
167
|
-
request :verified, :post, :userDataStream
|
168
|
-
end
|
169
|
-
|
170
|
-
# Public: Ping the server to keep User Data stream alive
|
171
|
-
#
|
172
|
-
# options - The Hash which hosts various REST query params.
|
173
|
-
# :listen_key - The String of which stream to keep alive
|
174
|
-
#
|
175
|
-
# Returns a Hash with the request response
|
176
|
-
def keep_stream_alive(options)
|
177
|
-
request :verified, :put, :userDataStream, options
|
178
|
-
end
|
179
|
-
|
180
|
-
# Public: Close the User Data stream associated with the listen key
|
181
|
-
#
|
182
|
-
# options - The Hash which hosts various REST query params.
|
183
|
-
# :listen_key - The String of which stream to close
|
184
|
-
#
|
185
|
-
# Returns a Hash with the request response
|
186
|
-
def close_stream(options)
|
187
|
-
request :verified, :delete, :userDataStream, options
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|
191
|
-
end
|
192
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
|
2
|
-
module Binance
|
3
|
-
module Client
|
4
|
-
class REST
|
5
|
-
API_ENDPOINTS = {
|
6
|
-
# Public API Endpoints
|
7
|
-
ping: 'v1/ping',
|
8
|
-
time: 'v1/time',
|
9
|
-
exchangeInfo: 'v1/exchangeInfo',
|
10
|
-
products: '/exchange/public/products',
|
11
|
-
depth: 'v1/depth',
|
12
|
-
trades: 'v1/trades',
|
13
|
-
historicalTrades: 'v1/historicalTrades',
|
14
|
-
aggTrades: 'v1/aggTrades',
|
15
|
-
klines: 'v1/klines',
|
16
|
-
twenty_four_hour: 'v1/ticker/24hr',
|
17
|
-
price: 'v3/ticker/price',
|
18
|
-
bookTicker: 'v3/ticker/bookTicker',
|
19
|
-
|
20
|
-
# Account API Endpoints
|
21
|
-
order: 'v3/order',
|
22
|
-
order_test: 'v3/order/test',
|
23
|
-
openOrders: 'v3/openOrders',
|
24
|
-
allOrders: 'v3/allOrders',
|
25
|
-
account: 'v3/account',
|
26
|
-
myTrades: 'v3/myTrades',
|
27
|
-
userDataStream: 'v1/userDataStream',
|
28
|
-
|
29
|
-
# Withdraw API Endpoints
|
30
|
-
withdraw: 'v3/withdraw.html',
|
31
|
-
depositHistory: 'v3/depositHistory.html',
|
32
|
-
withdrawHistory: 'v3/withdrawHistory.html',
|
33
|
-
depositAddress: 'v3/depositAddress.html',
|
34
|
-
accountStatus: 'v3/accountStatus.html'
|
35
|
-
}.freeze
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,149 +0,0 @@
|
|
1
|
-
|
2
|
-
module Binance
|
3
|
-
module Client
|
4
|
-
class REST
|
5
|
-
# Public: A Module containing all of the Public API endpoints
|
6
|
-
module PublicAPI
|
7
|
-
# Public: Ping the server to test connectivity
|
8
|
-
#
|
9
|
-
# Returns a Hash with the request response
|
10
|
-
def ping
|
11
|
-
request :public, :get, :ping
|
12
|
-
end
|
13
|
-
|
14
|
-
# Public: Retrieve the server time in milliseconds
|
15
|
-
#
|
16
|
-
# Returns a Hash with the request response
|
17
|
-
def time
|
18
|
-
request :public, :get, :time
|
19
|
-
end
|
20
|
-
|
21
|
-
# Public: Retrieve current exchange trading rules and symbol information
|
22
|
-
#
|
23
|
-
# Returns a Hash with the request response
|
24
|
-
def exchange_info
|
25
|
-
request :public, :get, :exchangeInfo
|
26
|
-
end
|
27
|
-
|
28
|
-
# Public: Retrieve current exchange asset information. This is an
|
29
|
-
# undocumented endpoint.
|
30
|
-
#
|
31
|
-
# Returns a Hash with the request response
|
32
|
-
def products
|
33
|
-
request :public, :get, :products
|
34
|
-
end
|
35
|
-
|
36
|
-
# Public: Retrieve depth information for the specified symbol
|
37
|
-
#
|
38
|
-
# options - The Hash which hosts various REST query params.
|
39
|
-
# :symbol - The String of which trading pair to retrieve.
|
40
|
-
# :limit - The Number of how many updates to request (optional).
|
41
|
-
#
|
42
|
-
# Returns a Hash with the request response
|
43
|
-
def depth(options)
|
44
|
-
request :public, :get, :depth, options
|
45
|
-
end
|
46
|
-
|
47
|
-
# Public: Retrieve recent trades for the specified symbol
|
48
|
-
#
|
49
|
-
# options - The Hash which hosts various REST query params.
|
50
|
-
# :symbol - The String of which trading pair to retrieve.
|
51
|
-
# :limit - The Number of how many trades to request (optional).
|
52
|
-
#
|
53
|
-
# Returns a Hash with the request response
|
54
|
-
def trades(options)
|
55
|
-
request :public, :get, :trades, options
|
56
|
-
end
|
57
|
-
|
58
|
-
# Public: Retrieve old trade data for the specified symbol
|
59
|
-
#
|
60
|
-
# options - The Hash which hosts various REST query params.
|
61
|
-
# :symbol - The String of which trading pair to retrieve.
|
62
|
-
# :limit - The Number of how many trades to request (optional).
|
63
|
-
# :fromId - The String of which trade ID to fetch from (optional).
|
64
|
-
#
|
65
|
-
# Returns a Hash with the request response
|
66
|
-
def historical_trades(options)
|
67
|
-
request :verified, :get, :historicalTrades, options
|
68
|
-
end
|
69
|
-
|
70
|
-
# Public: Retrieve aggregate trade data for the specified symbol
|
71
|
-
#
|
72
|
-
# options - The Hash which hosts various REST query params.
|
73
|
-
# :symbol - The String of which trading pair to retrieve.
|
74
|
-
# :fromId - The String of which trade ID to fetch from (optional).
|
75
|
-
# :startTime - The Timestamp of when to get trades from in
|
76
|
-
# milliseconds (optional).
|
77
|
-
# :endTime - The Timestamp of when to get trades until in
|
78
|
-
# milliseconds (optional).
|
79
|
-
# :limit - The Number of how many trades to request (optional).
|
80
|
-
#
|
81
|
-
# Returns a Hash with the request response
|
82
|
-
def agg_trades(options)
|
83
|
-
request :public, :get, :aggTrades, options
|
84
|
-
end
|
85
|
-
|
86
|
-
# Public: Retrieve kline data for the specified symbol
|
87
|
-
#
|
88
|
-
# options - The Hash which hosts various REST query params.
|
89
|
-
# :symbol - The String of which trading pair to retrieve.
|
90
|
-
# :interval - The String of which interval to retrieve (optional).
|
91
|
-
# :fromId - The String of which trade ID to fetch from (optional).
|
92
|
-
# :startTime - The Timestamp of when to get trades from in
|
93
|
-
# milliseconds (optional).
|
94
|
-
# :endTime - The Timestamp of when to get trades until in
|
95
|
-
# milliseconds (optional).
|
96
|
-
# :limit - The Number of how many trades to request (optional).
|
97
|
-
#
|
98
|
-
# Returns a Hash with the request response
|
99
|
-
def klines(options)
|
100
|
-
request :public, :get, :klines, options
|
101
|
-
end
|
102
|
-
|
103
|
-
# Public: Retrieve 24 hour ticker price data
|
104
|
-
#
|
105
|
-
# options - The Hash which hosts various REST query params.
|
106
|
-
# :symbol - The String of which trading pair to retrieve (optional).
|
107
|
-
#
|
108
|
-
# Returns a Hash with the request response
|
109
|
-
def twenty_four_hour(options)
|
110
|
-
request :public, :get, :twenty_four_hour, options
|
111
|
-
end
|
112
|
-
|
113
|
-
# Public: Retrieve price ticker data for the specified symbol
|
114
|
-
#
|
115
|
-
# options - The Hash which hosts various REST query params.
|
116
|
-
# :symbol - The String of which trading pair to retrieve (optional).
|
117
|
-
#
|
118
|
-
# Returns a Hash with the request response
|
119
|
-
def price(options)
|
120
|
-
request :public, :get, :price, options
|
121
|
-
end
|
122
|
-
|
123
|
-
# Public: Retrieve all price ticker data
|
124
|
-
#
|
125
|
-
# Returns a Hash with the request response
|
126
|
-
def all_prices
|
127
|
-
request :public, :get, :price
|
128
|
-
end
|
129
|
-
|
130
|
-
# Public: Retrieve best price per quantity on the order book
|
131
|
-
#
|
132
|
-
# options - The Hash which hosts various REST query params.
|
133
|
-
# :symbol - The String of which trading pair to retrieve (optional).
|
134
|
-
#
|
135
|
-
# Returns a Hash with the request response
|
136
|
-
def book_ticker(options)
|
137
|
-
request :public, :get, :bookTicker, options
|
138
|
-
end
|
139
|
-
|
140
|
-
# Public: Retrieve all book ticker data for all symbols
|
141
|
-
#
|
142
|
-
# Returns a Hash with the request response
|
143
|
-
def all_book_tickers
|
144
|
-
request :public, :get, :bookTicker
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
|
2
|
-
module Binance
|
3
|
-
module Client
|
4
|
-
class REST
|
5
|
-
# Public: A Module containing all of the Withdraw API endpoints
|
6
|
-
module WithdrawAPI
|
7
|
-
# Public: Withdraw the specified asset to the given address using
|
8
|
-
# the authenticated account
|
9
|
-
#
|
10
|
-
# options - The Hash which hosts various REST query params.
|
11
|
-
# :asset - The String of which asset to withdraw.
|
12
|
-
# :address - The String of where to send the asset to.
|
13
|
-
# :addressTag - The String secondary address identifier (optional).
|
14
|
-
# :amount - The String decimal value of how much to withdraw.
|
15
|
-
# :name - The String description of the address
|
16
|
-
# :recvWindow - The Number of how long a request is valid for in
|
17
|
-
# milliseconds (optional).
|
18
|
-
#
|
19
|
-
# Returns a Hash with the request response
|
20
|
-
def withdraw(options)
|
21
|
-
request :withdraw, :post, :withdraw, options
|
22
|
-
end
|
23
|
-
|
24
|
-
# Public: Retrieve the deposit history for the authenticated account
|
25
|
-
#
|
26
|
-
# options - The Hash which hosts various REST query params.
|
27
|
-
# :asset - The String of which asset to retrieve (optional).
|
28
|
-
# :status - The Number of which status to retrieve (optional).
|
29
|
-
# :startTime - The Timestamp of when to start the history in
|
30
|
-
# milliseconds (optional).
|
31
|
-
# :endTime - The Timestamp of when to end the history in
|
32
|
-
# milliseconds (optional).
|
33
|
-
# :recvWindow - The Number of how long a request is valid for in
|
34
|
-
# milliseconds (optional).
|
35
|
-
#
|
36
|
-
# Returns a Hash with the request response
|
37
|
-
def deposit_history(options = {})
|
38
|
-
request :withdraw, :get, :depositHistory, options
|
39
|
-
end
|
40
|
-
|
41
|
-
# Public: Retrieve the withdraw history for the authenticated account
|
42
|
-
#
|
43
|
-
# options - The Hash which hosts various REST query params.
|
44
|
-
# :asset - The String of which asset to retrieve (optional).
|
45
|
-
# :status - The Number of which status to retrieve (optional).
|
46
|
-
# :startTime - The Timestamp of when to start the history in
|
47
|
-
# milliseconds (optional).
|
48
|
-
# :endTime - The Timestamp of when to end the history in
|
49
|
-
# milliseconds (optional).
|
50
|
-
# :recvWindow - The Number of how long a request is valid for in
|
51
|
-
# milliseconds (optional).
|
52
|
-
#
|
53
|
-
# Returns a Hash with the request response
|
54
|
-
def withdraw_history(options = {})
|
55
|
-
request :withdraw, :get, :withdrawHistory, options
|
56
|
-
end
|
57
|
-
|
58
|
-
# Public: Retrieve the deposit address for a specific asset
|
59
|
-
#
|
60
|
-
# options - The Hash which hosts various REST query params.
|
61
|
-
# :asset - The String of which asset to retrieve (optional).
|
62
|
-
# :recvWindow - The Number of how long a request is valid for in
|
63
|
-
# milliseconds (optional).
|
64
|
-
#
|
65
|
-
# Returns a Hash with the request response
|
66
|
-
def deposit_address(options)
|
67
|
-
request :withdraw, :get, :depositAddress, options
|
68
|
-
end
|
69
|
-
|
70
|
-
# Public: Retrieve current account status
|
71
|
-
#
|
72
|
-
# options - The Hash which hosts various REST query params.
|
73
|
-
# :recvWindow - The Number of how long a request is valid for in
|
74
|
-
# milliseconds (optional).
|
75
|
-
#
|
76
|
-
# Returns a Hash with the request response
|
77
|
-
def account_status(options)
|
78
|
-
request :withdraw, :get, :accountStatus, options
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|