class Devilicious::Formatter::Table
Public Instance Methods
output(opportunity)
click to toggle source
# File lib/devilicious/formatters/table.rb, line 4 def output(opportunity) pair = [opportunity.order_book_1.market, " to ", opportunity.order_book_2.market, " " * 4].map(&:to_s).join @best_trades ||= {} @best_trades[pair] = opportunity Log.info "", timestamp: false Log.info "PAIR \tPROFIT \tVOLUME \tBUY \tSELL \tPERCENT", timestamp: false @best_trades.sort_by { |_, opportunity| opportunity.profit }.each do |pair, opportunity| pair = pair.dup << " " * [30 - pair.size, 0].max # padding percent = sprintf("%.2f%%", opportunity.profit / opportunity.ask_offer.price * 100) Log.info [pair, opportunity.profit, opportunity.volume.to_f, opportunity.ask_offer.price, opportunity.bid_offer.price, percent].join(" \t"), timestamp: false end end