Class: Devilicious::Formatter::Summary

Inherits:
Base
  • Object
show all
Defined in:
lib/devilicious/formatters/summary.rb

Instance Method Summary collapse

Methods inherited from Base

inherited, #to_s

Instance Method Details

#output(opportunity) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/devilicious/formatters/summary.rb', line 4

def output(opportunity)
  pair = [opportunity.order_book_1.market, " to ", opportunity.order_book_2.market, " " * 3].map(&:to_s).join
  @best_trades ||= {}
  @best_trades[pair] = opportunity

  Log.info "", timestamp: false
  @best_trades.sort_by { |_, opportunity| opportunity.profit }.each do |pair, opportunity|
    Log.info "#{pair} \t#{opportunity.profit} with #{opportunity.volume.to_f} XBT", timestamp: false
  end
end