Module: Binance::Api
- Defined in:
- lib/binance/api.rb,
lib/binance/api/error.rb,
lib/binance/api/order.rb,
lib/binance/api/account.rb,
lib/binance/api/request.rb,
lib/binance/api/version.rb,
lib/binance/api/data_stream.rb,
lib/binance/api/margin/order.rb,
lib/binance/api/configuration.rb
Defined Under Namespace
Modules: Margin
Classes: Account, Configuration, DataStream, Error, Order, Request
Constant Summary
collapse
- VERSION =
"0.6.1"
Class Method Summary
collapse
-
.candlesticks!(endTime: nil, interval: nil, limit: 500, startTime: nil, symbol: nil) ⇒ Object
Valid limits:[5, 10, 20, 50, 100, 500, 1000].
-
.compressed_aggregate_trades!(endTime: nil, fromId: nil, limit: 500, startTime: nil, symbol: nil) ⇒ Object
-
.depth!(symbol: nil, limit: 100) ⇒ Object
-
.exchange_info! ⇒ Object
-
.historical_trades!(symbol: nil, limit: 500, fromId: nil) ⇒ Object
-
.info!(recvWindow: nil) ⇒ Object
-
.ping! ⇒ Object
-
.ticker!(symbol: nil, type: nil) ⇒ Object
-
.time! ⇒ Object
-
.trades!(symbol: nil, limit: 500) ⇒ Object
Class Method Details
.candlesticks!(endTime: nil, interval: nil, limit: 500, startTime: nil, symbol: nil) ⇒ Object
Valid limits:[5, 10, 20, 50, 100, 500, 1000]
5
6
7
8
9
10
|
# File 'lib/binance/api.rb', line 5
def candlesticks!(endTime: nil, interval: nil, limit: 500, startTime: nil, symbol: nil)
raise Error.new(message: "interval is required") unless interval
raise Error.new(message: "symbol is required") unless symbol
params = { endTime: endTime, interval: interval, limit: limit, startTime: startTime, symbol: symbol }
Request.send!(api_key_type: :read_info, path: "/api/v1/klines", params: params)
end
|
.compressed_aggregate_trades!(endTime: nil, fromId: nil, limit: 500, startTime: nil, symbol: nil) ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/binance/api.rb', line 12
def compressed_aggregate_trades!(endTime: nil, fromId: nil, limit: 500, startTime: nil, symbol: nil)
raise Error.new(message: "symbol is required") unless symbol
params = {
endTime: endTime, fromId: fromId, limit: limit, startTime: startTime, symbol: symbol,
}.delete_if { |key, value| value.nil? }
Request.send!(api_key_type: :read_info, path: "/api/v1/aggTrades", params: params)
end
|
.depth!(symbol: nil, limit: 100) ⇒ Object
20
21
22
23
24
|
# File 'lib/binance/api.rb', line 20
def depth!(symbol: nil, limit: 100)
raise Error.new(message: "symbol is required") unless symbol
params = { limit: limit, symbol: symbol }
Request.send!(api_key_type: :read_info, path: "/api/v1/depth", params: params)
end
|
.exchange_info! ⇒ Object
26
27
28
|
# File 'lib/binance/api.rb', line 26
def exchange_info!
Request.send!(api_key_type: :read_info, path: "/api/v1/exchangeInfo")
end
|
.historical_trades!(symbol: nil, limit: 500, fromId: nil) ⇒ Object
30
31
32
33
34
|
# File 'lib/binance/api.rb', line 30
def historical_trades!(symbol: nil, limit: 500, fromId: nil)
raise Error.new(message: "symbol is required") unless symbol
params = { fromId: fromId, limit: limit, symbol: symbol }
Request.send!(api_key_type: :read_info, path: "/api/v1/historicalTrades", params: params, security_type: :market_data)
end
|
.info!(recvWindow: nil) ⇒ Object
36
37
38
39
40
|
# File 'lib/binance/api.rb', line 36
def info!(recvWindow: nil)
timestamp = Configuration.timestamp
params = { recvWindow: recvWindow, timestamp: timestamp }.delete_if { |key, value| value.nil? }
Request.send!(api_key_type: :read_info, path: "/api/v3/account", params: params, security_type: :user_data)
end
|
.ping! ⇒ Object
42
43
44
|
# File 'lib/binance/api.rb', line 42
def ping!
Request.send!(path: "/api/v1/ping")
end
|
.ticker!(symbol: nil, type: nil) ⇒ Object
46
47
48
49
50
51
52
53
|
# File 'lib/binance/api.rb', line 46
def ticker!(symbol: nil, type: nil)
ticker_type = type&.to_sym
error_message = "type must be one of: #{ticker_types.join(", ")}. #{type} was provided."
raise Error.new(message: error_message) unless ticker_types.include? ticker_type
path = ticker_path(type: ticker_type)
params = symbol ? { symbol: symbol } : {}
Request.send!(api_key_type: :read_info, path: path, params: params)
end
|
.time! ⇒ Object
55
56
57
|
# File 'lib/binance/api.rb', line 55
def time!
Request.send!(path: "/api/v1/time")
end
|
.trades!(symbol: nil, limit: 500) ⇒ Object
59
60
61
62
63
|
# File 'lib/binance/api.rb', line 59
def trades!(symbol: nil, limit: 500)
raise Error.new(message: "symbol is required") unless symbol
params = { limit: limit, symbol: symbol }
Request.send!(api_key_type: :read_info, path: "/api/v1/trades", params: params)
end
|