Sha256: 754d0ec4450083d61d8d0ed1d66f3f19f9308d13ac5b74831e5f53e96f7b869b
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
class Bitcoin::OrderBook attr_accessor :side, :price, :size, :timestamp, :limit, :symbol def display_details puts <<-DOC #{@symbol} #{@side.upcase} Order: #{@price} Quantity: #{@size} #{@timestamp} DOC end def self.new_from_object(object) o = Bitcoin::OrderBook.new o.size = object['size'].to_f o.side = object[:side] o.price = object['price'].to_f o.timestamp = Time.parse(object['timestamp']) o.limit = object['limit'] o.symbol = object[:symbol] o end def self.all(symbol_name) data = JSON.parse RestClient.get "#{Bitcoin::BASE}/public/orderbook/#{symbol_name}?limit=0" ask_orders = data['ask'] bid_orders = data['bid'] ask_orders.each{ |order| order[:side] = 'ask' order['timestamp'] = data['timestamp'] order[:symbol] = symbol_name } bid_orders.each{ |order| order[:side] = 'bid' order['timestamp'] = data['timestamp'] order[:symbol] = symbol_name } [ask_orders, bid_orders].flatten!.map{|order| Bitcoin::OrderBook.new_from_object(order) } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bitcoin-api-0.1.1 | lib/bitcoin/order_book.rb |