Class: BTCT::BtceAPI

Inherits:
Object
  • Object
show all
Defined in:
lib/btct/btce.rb

Instance Method Summary collapse

Instance Method Details

#nameObject



8
9
10
# File 'lib/btct/btce.rb', line 8

def name
  "BTC-E"
end

#tickerObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/btct/btce.rb', line 19

def ticker
  ticker = JSON.parse open("https://btc-e.com/api/2/btc_usd/ticker/").read
  ticker = ticker["ticker"]
  Ticker.new(
    :last     => ticker["last"   ].to_f,
    :volume   => ticker["vol_cur"].to_f,
    :high     => ticker["high"   ].to_f,
    :low      => ticker["low"    ].to_f,
    :time     => DateTime.strptime(ticker["updated"].to_s, '%s'),
    :exchange => name
  )
end

#topObject



12
13
14
15
16
17
# File 'lib/btct/btce.rb', line 12

def top
  ob = JSON.parse open("https://btc-e.com/api/2/btc_usd/depth").read
  bid = ob["bids"].sort { |x, y| x[0].to_f <=> y [0].to_f }.last
  ask = ob["asks"].sort { |x, y| x[0].to_f <=> y [0].to_f }.first
  return Quote.new(bid[0], bid[1], name), Quote.new(ask[0], ask[1], name)
end