class WavesRubyClient::OrderBook
Orderbook for a pair of assets
Attributes
asks[RW]
asset1[RW]
asset2[RW]
bids[RW]
Public Class Methods
btc_waves()
click to toggle source
# File lib/waves_ruby_client/order_book.rb, line 6 def self.btc_waves new(WavesRubyClient::Asset.waves, WavesRubyClient::Asset.btc) end
new(asset1, asset2)
click to toggle source
# File lib/waves_ruby_client/order_book.rb, line 12 def initialize(asset1, asset2) self.asset1 = asset1 self.asset2 = asset2 self.bids = self.asks = [] end
Public Instance Methods
refresh()
click to toggle source
# File lib/waves_ruby_client/order_book.rb, line 18 def refresh order_book = WavesRubyClient::Api.instance.call_matcher( "/orderbook/#{asset1.url_id}/#{asset2.url_id}" ) self.asks = order_book['asks'].map { |order| scale(order) } self.bids = order_book['bids'].map { |order| scale(order) } end
Private Instance Methods
scale(order)
click to toggle source
# File lib/waves_ruby_client/order_book.rb, line 28 def scale(order) { price: order['price'].to_f / WavesRubyClient::NUMBER_MULTIPLIKATOR, amount: order['amount'].to_f / WavesRubyClient::NUMBER_MULTIPLIKATOR } end