Skip to content

Commit

Permalink
adds colored output and fixes missing gemfile error
Browse files Browse the repository at this point in the history
  • Loading branch information
hstove committed Apr 5, 2014
1 parent 65e49eb commit 774c6f5
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
4 changes: 3 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
PATH
remote: .
specs:
rbtc_arbitrage (2.0.2)
rbtc_arbitrage (2.1.0)
activemodel (>= 3.1)
activesupport (>= 3.1)
btce (= 0.2.4)
coinbase (= 1.2.6)
faraday (= 0.8.8)
pony
tco (= 0.1.0)
thor

PATH
Expand Down Expand Up @@ -136,6 +137,7 @@ GEM
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
slop (3.4.7)
tco (0.1.0)
term-ansicolor (1.2.2)
tins (~> 0.8)
thor (0.18.1)
Expand Down
6 changes: 5 additions & 1 deletion lib/rbtc_arbitrage.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
require 'bundler'
Bundler.require(:default)
Dir.chdir("#{File.dirname(__FILE__)}/../") do
Bundler.require(:default)
end
require 'bitstamp'
require 'thor'
require_relative 'rbtc_arbitrage/campbx.rb'
require 'btce'
require 'coinbase'
require 'pony'
require 'tco'
require_relative 'rbtc_arbitrage/client.rb'
Dir["#{File.dirname(__FILE__)}/rbtc_arbitrage/trader/*.rb"].each { |f| require(f) }
Dir["#{File.dirname(__FILE__)}/rbtc_arbitrage/**/*.rb"].each { |f| require(f) }
Expand Down
25 changes: 18 additions & 7 deletions lib/rbtc_arbitrage/trader/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,32 @@ def logger
def log_info
lower_ex = @buy_client.exchange.to_s.capitalize
higher_ex = @sell_client.exchange.to_s.capitalize
logger.info "#{lower_ex}: $#{buyer[:price].round(2)}"
logger.info "#{higher_ex}: $#{seller[:price].round(2)}"
logger.info "buying #{@options[:volume]} btc from #{lower_ex} for $#{@paid.round(2)}"
logger.info "selling #{@options[:volume]} btc on #{higher_ex} for $#{@received.round(2)}"
logger.info "#{lower_ex}: $#{color(buyer[:price].round(2))}"
logger.info "#{higher_ex}: $#{color(seller[:price].round(2))}"
logger.info log_string("buying", lower_ex, @paid)
logger.info log_string("selling", lower_ex, @received)

log_profit
end

private

def log_string action, exchange, amount
message = "#{action} #{color @options[:volume]} "
message << "btc at #{exchange} for $"
message << color(amount.round(2))
end

def color message
message.to_s.fg("#D5EC28").bg("#000")
end

def log_profit
profit_msg = "profit: $#{(@received - @paid).round(2)} (#{@percent.round(2)}%)"
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 #{cutoff}%."
profit_msg << " of #{color(cutoff)}%."
end
logger.info profit_msg
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rbtc_arbitrage/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module RbtcArbitrage
VERSION = "2.0.2"
VERSION = "2.1.0"
end
1 change: 1 addition & 0 deletions rbtc_arbitrage.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ Gem::Specification.new do |spec|
spec.add_dependency "btce", '0.2.4'
spec.add_dependency "coinbase", '1.2.6'
spec.add_dependency "pony"
spec.add_dependency "tco", "0.1.0"
end

0 comments on commit 774c6f5

Please sign in to comment.