class Flashboy::Kraken
Public Class Methods
parse_cursor(params)
click to toggle source
# File lib/flashboy/kraken.rb, line 10 def self.parse_cursor(params) { since: params[:since] } end
Private Instance Methods
formatted_pair(pair)
click to toggle source
Calls superclass method
Flashboy::Exchange#formatted_pair
# File lib/flashboy/kraken.rb, line 16 def formatted_pair(pair) currency, base = super(pair).map { |curr| curr.upcase == 'BTC' ? 'XBT' : curr } "#{currency}#{base}".upcase end
parse_order_book(order, pair)
click to toggle source
# File lib/flashboy/kraken.rb, line 49 def parse_order_book(order, pair) data = order[:result].values.first { bids: data[:bids].map{|(p,a,t)| { price: p, amount: a } }, asks: data[:asks].map{|(p,a,t)| { price: p, amount: a } } } end
parse_quote(quote, pair)
click to toggle source
# File lib/flashboy/kraken.rb, line 38 def parse_quote(quote, pair) data = quote[:result].values.first { bid: (data[:b] || []).first, last: (data[:c] || []).first, ask: (data[:a] || []).first, volume: (data[:v] || []).first, timestamp: nil } end
parse_trades(trades, exchange, pair)
click to toggle source
# File lib/flashboy/kraken.rb, line 21 def parse_trades(trades, exchange, pair) last_id = trades[:result][:last] pair_id = trades[:result].keys.first trades = trades[:result][pair_id] [*trades].map do |trade| price, amount, time, type = trade { global_id: "#{exchange.key}-#{time}-#{last_id}", type: type == 'b' ? 'buy' : 'sell', price: price, amount: amount, executed_at: time } end end