class Bitcoin::Candle

Attributes

close[RW]
interval[RW]
max[RW]
min[RW]
open[RW]
timestamp[RW]
volume[RW]
volumeQuote[RW]

Public Class Methods

all(symbol) click to toggle source
# File lib/bitcoin/candle.rb, line 28
def self.all(symbol)
  data = JSON.parse(RestClient.get("#{Bitcoin::BASE}/public/candles/#{symbol}?limit=1000"))
  data.map{ |candle|
    Bitcoin::Candle.new_from_object(candle)
  }
end
new_from_object(object) click to toggle source
# File lib/bitcoin/candle.rb, line 15
def self.new_from_object(object)
  c = Bitcoin::Candle.new
  c.timestamp = Time.parse(object['timestamp'])
  c.open = object['open']
  c.close = object['close']
  c.min = object['min']
  c.max = object['max']
  c.volume = object['volume']
  c.volumeQuote = object['volumeQuote']
  #puts "candle retreived ()"
  c
end
new_from_range(symbol_name, timestamps, interval = '30M') click to toggle source

returns array of candles between two datetimes

# File lib/bitcoin/candle.rb, line 36
def self.new_from_range(symbol_name, timestamps, interval = '30M')
  url = "#{Bitcoin::BASE}/public/candles/#{symbol_name}?limit=1000&sort=DESC"
  params = "&from=#{timestamps[0]}&till=#{timestamps[1]}&period=#{interval}"
  params = params.gsub(':', '%3A')
  data = JSON.parse RestClient.get("#{url}#{params}")
  data.map { |e| Bitcoin::Candle.new_from_object(e) }
end

Public Instance Methods

display_details() click to toggle source
# File lib/bitcoin/candle.rb, line 5
  def display_details
    puts <<-DOC
    #{@timestamp}
    Open: #{@open} || Close: #{@close}
    Min: #{@min} || Max: #{@max}
    Volume: #{@volume} || Volume Quote: #{@volumeQuote}

    DOC
  end