module RbtcArbitrage::TraderHelpers::Logger

Public Instance Methods

log_info() click to toggle source
# File lib/rbtc_arbitrage/trader/logger.rb, line 8
def log_info
  lower_ex = @buy_client.exchange.to_s.capitalize
  higher_ex = @sell_client.exchange.to_s.capitalize
  logger.info "#{lower_ex} (Ask): $#{color(buyer[:price].round(2))}"
  logger.info "#{higher_ex} (Bid): $#{color(seller[:price].round(2))}"
  logger.info log_string("buying", lower_ex, @paid)
  logger.info log_string("selling", higher_ex, @received)

  log_profit
end
logger() click to toggle source
# File lib/rbtc_arbitrage/trader/logger.rb, line 4
def logger
  @options[:logger]
end

Private Instance Methods

color(message) click to toggle source
# File lib/rbtc_arbitrage/trader/logger.rb, line 27
def color message
  message.to_s.fg("#D5EC28").bg("#000")
end
log_profit() click to toggle source
# File lib/rbtc_arbitrage/trader/logger.rb, line 31
def log_profit
  profit_msg = "profit: $#{color (@received - @paid).round(2)}"
  profit_msg << " (#{color(@percent.round(2))}%)"
  if cutoff = @options[:cutoff]
    profit_msg << " is #{@percent < cutoff ? 'below' : 'above'} cutoff"
    profit_msg << " of #{color(cutoff)}%."
  end
  logger.info profit_msg
end
log_string(action, exchange, amount) click to toggle source
# File lib/rbtc_arbitrage/trader/logger.rb, line 21
def log_string action, exchange, amount
  message = "#{action} #{color @options[:volume]} "
  message << "btc at #{exchange} for $"
  message << color(amount.round(2))
end