Skip to content

Commit

Permalink
Merge d1d206d into 5b9cef5
Browse files Browse the repository at this point in the history
  • Loading branch information
jordoh committed Apr 15, 2014
2 parents 5b9cef5 + d1d206d commit 454b08d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ PATH
faraday (= 0.8.8)
pony
rake (= 10.1.1)
stathat
tco (= 0.1.0)
thor

Expand Down Expand Up @@ -139,6 +140,7 @@ GEM
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
slop (3.4.7)
stathat (0.1.7)
tco (0.1.0)
term-ansicolor (1.2.2)
tins (~> 0.8)
Expand Down
1 change: 1 addition & 0 deletions lib/rbtc_arbitrage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
require 'coinbase'
require 'pony'
require 'tco'
require 'stathat'
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
21 changes: 15 additions & 6 deletions lib/rbtc_arbitrage/trader/notifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@ module Notifier
def notify
return false unless options[:notify]
return false unless @percent > options[:cutoff]
setup_pony

options[:logger].info "Sending email to #{ENV['SENDGRID_EMAIL']}"
Pony.mail({
body: notification,
to: ENV['SENDGRID_EMAIL'],
})
if (sendgrid_email = ENV['SENDGRID_EMAIL']).present?
setup_pony
options[:logger].info "Sending email to #{sendgrid_email}"
Pony.mail({
body: notification,
to: sendgrid_email,
})
end

if (stathat_api_key = ENV['STATHAT_API_KEY']).present?
options[:logger].info "Notifying #{ stathat_api_key } via stathat"

StatHat::SyncAPI.ez_post_value("#{@buy_client.exchange}_to_#{@sell_client.exchange}_percent", stathat_api_key, @percent)
StatHat::SyncAPI.ez_post_value("#{@buy_client.exchange}_to_#{@sell_client.exchange}_profit", stathat_api_key, @received - @paid)
end
end

def setup_pony
Expand Down
1 change: 1 addition & 0 deletions rbtc_arbitrage.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "thor"
spec.add_dependency "btce", '0.2.4'
spec.add_dependency "coinbase", '1.3.0'
spec.add_dependency "stathat"
spec.add_dependency "pony"
spec.add_dependency "tco", "0.1.0"
end

0 comments on commit 454b08d

Please sign in to comment.