class Flashboy::Bitfinex

Public Class Methods

parse_cursor(params) click to toggle source
# File lib/flashboy/bitfinex.rb, line 10
def self.parse_cursor(params)
  { start: params[:start] }
end

Private Instance Methods

formatted_pair(pair) click to toggle source
Calls superclass method
# File lib/flashboy/bitfinex.rb, line 16
def formatted_pair(pair)
  currency, base = super(pair)
  "#{currency}#{base}".upcase
end
parse_order_book(order, pair) click to toggle source
# File lib/flashboy/bitfinex.rb, line 43
def parse_order_book(order, pair)
  {
    bids: (order[:bids] || []).map{|order| { price: order[:price], amount: order[:amount] } },
    asks: (order[:asks] || []).map{|order| { price: order[:price], amount: order[:amount] } }
  }
end
parse_quote(quote, pair) click to toggle source
# File lib/flashboy/bitfinex.rb, line 33
def parse_quote(quote, pair)
  {
    bid: quote[:bid],
    last: quote[:last_price],
    ask: quote[:ask],
    volume: quote[:volume],
    timestamp: quote[:timestamp]
  }
end
parse_trades(trades, exchange, pair) click to toggle source
# File lib/flashboy/bitfinex.rb, line 21
def parse_trades(trades, exchange, pair)
  [*trades].map do |trade|
    {
      global_id: "#{exchange.key}-#{trade[:tid]}",
      type: trade[:type],
      price: trade[:price],
      amount: trade[:amount],
      executed_at: trade[:timestamp]
    }
  end
end