Skip to content

Commit

Permalink
improves trader#log_info
Browse files Browse the repository at this point in the history
  • Loading branch information
hstove committed Mar 23, 2014
1 parent 5b1ebd3 commit ef5910a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/rbtc_arbitrage/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class CLI < Thor
option :cutoff, type: :numeric, default: 2, desc: "The minimum profit level required to execute a trade."
option :volume, type: :numeric, default: 0.01, desc: "The amount of bitcoins to trade per transaction."
option :verbose, type: :boolean, default: true, desc: "Whether you wish to log information."
option :buyer, type: :string, default: "campbx"
option :seller, type: :string, default: "bitstamp"
option :buyer, type: :string, default: "bitstamp"
option :seller, type: :string, default: "campbx"
option :repeat, type: :numeric, default: nil
option :notify, type: :boolean, default: false
def trade
Expand Down
8 changes: 7 additions & 1 deletion lib/rbtc_arbitrage/trader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,13 @@ def log_info
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 "profit: $#{(@received - @paid).round(2)} (#{@percent.round(2)}%)"

profit_msg = "profit: $#{(@received - @paid).round(2)} (#{@percent.round(2)}%)"
if cutoff = @options[:cutoff]
profit_msg << " is #{@percent < cutoff ? 'below' : 'above'} cutoff"
profit_msg << " of #{cutoff}%."
end
logger.info profit_msg
end

def get_balance
Expand Down

0 comments on commit ef5910a

Please sign in to comment.