class CryptoTicker::BTCe
BTC-e tickers for various crypto-currencies and retrieval methods
Public Class Methods
depth(base, quote='')
click to toggle source
# File lib/crypto_ticker.rb, line 138 def depth(base, quote='') pair = CryptoTicker::makepair(base, quote) if @@valid_pairs.include?( pair ) "https://btc-e.com/api/2/#{pair.to_sym}/depth" end end
info(json)
click to toggle source
# File lib/crypto_ticker.rb, line 155 def info(json) hash = JSON.parse(json) info = {} # TODO: recursively process Arrays, Hashes, Strings, Fixnums... if hash.has_key?('ticker') hash['ticker'].keys.each do |key| val = hash['ticker'][key] info[key.to_sym] = val.send(@@ret_fcns[@@ret_types[key]]) end end info end
last(json)
click to toggle source
Accepts JSON retrieved from the appropriate BTC-e ticker URL, returns last trade amount (denominated in counter currency) as a float. eg: BTC/USD ticker will return amount in USD
NMC/BTC ticker will return amount in BTC
# File lib/crypto_ticker.rb, line 149 def last(json) hash = JSON.parse(json) hash['ticker']['last'].to_d end
ticker(base, quote='')
click to toggle source
# File lib/crypto_ticker.rb, line 124 def ticker(base, quote='') pair = CryptoTicker::makepair(base, quote) if @@valid_pairs.include?( pair ) "https://btc-e.com/api/2/#{pair.to_sym}/ticker" end end
trades(base, quote='')
click to toggle source
# File lib/crypto_ticker.rb, line 131 def trades(base, quote='') pair = CryptoTicker::makepair(base, quote) if @@valid_pairs.include?( pair ) "https://btc-e.com/api/2/#{pair.to_sym}/trades" end end