Class: BTCT::CoinbaseAPI
- Inherits:
-
Object
- Object
- BTCT::CoinbaseAPI
- Defined in:
- lib/btct/coinbase.rb
Instance Method Summary collapse
Instance Method Details
#name ⇒ Object
7 8 9 |
# File 'lib/btct/coinbase.rb', line 7 def name "Coinbase" end |
#ticker ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/btct/coinbase.rb', line 18 def ticker ticker = JSON.parse open("https://api.exchange.coinbase.com/products/BTC-USD/ticker").read Ticker.new( :last => ticker["price"].to_f, :volume => ticker["volume"].to_f, :high => 0.0, :low => 0.0, :time => DateTime.now.new_offset(0), :exchange => name ) end |
#top ⇒ Object
11 12 13 14 15 16 |
# File 'lib/btct/coinbase.rb', line 11 def top top = JSON.parse open("https://api.exchange.coinbase.com/products/BTC-USD/book").read bid = top["bids"][0] ask = top["asks"][0] return Quote.new(bid[0].to_f, bid[1].to_f, name), Quote.new(ask[0].to_f, ask[1].to_f, name) end |