Class: Binance::SDK::Klines

Inherits:
Object
  • Object
show all
Defined in:
lib/binance/sdk/klines.rb

Class Method Summary collapse

Class Method Details

.data(symbol, interval = '5m', start_time = nil, end_time = nil, limit = nil, recvWindow: 5000, force_float: false) ⇒ Object

[

[
  1499040000000,      // Open time
  "0.01634790",       // Open
  "0.80000000",       // High
  "0.01575800",       // Low
  "0.01577100",       // Close
  "148976.11427815",  // Volume
  1499644799999,      // Close time
  "2434.19055334",    // Quote asset volume
  308,                // Number of trades
  "1756.87402397",    // Taker buy base asset volume
  "28.46694368",      // Taker buy quote asset volume
  "17928899.62484339" // Ignore.
]

]



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/binance/sdk/klines.rb', line 21

def data(symbol, interval = '5m', start_time = nil, end_time = nil, limit = nil, recvWindow: 5000, force_float: false)
  timestamp = Configuration.timestamp

  params = {
    recvWindow: recvWindow,
    timestamp: timestamp,
    symbol: symbol,
    interval: interval,
    startTime: start_time,
    endTime: end_time,
    limit: limit
  }

  response = Request.send!(
    api_key_type: :read_info, path: Endpoints.fetch(:klines),
    params: params.delete_if { |key, value| value.nil? },
    security_type: :user_data, api_key: Configuration.api_key, api_secret_key: Configuration.secret_key
  )

  force_float ? response.map! { |i| i.map(&:to_f) } : response
end