Class: BTCT::BitstampAPI
- Inherits:
-
Object
- Object
- BTCT::BitstampAPI
- Defined in:
- lib/btct/bitstamp.rb
Instance Method Summary collapse
Instance Method Details
#name ⇒ Object
9 10 11 |
# File 'lib/btct/bitstamp.rb', line 9 def name "Bitstamp" end |
#ticker ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/btct/bitstamp.rb', line 20 def ticker ticker = JSON.parse open("https://www.bitstamp.net/api/ticker/").read Ticker.new( :last => ticker["last" ].to_f, :volume => ticker["volume"].to_f, :high => ticker["high" ].to_f, :low => ticker["low" ].to_f, :time => DateTime.strptime(ticker["timestamp"], '%s'), :exchange => name ) end |
#top ⇒ Object
13 14 15 16 17 18 |
# File 'lib/btct/bitstamp.rb', line 13 def top ob = JSON.parse open("https://www.bitstamp.net/api/order_book/").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 |