Sha256: d3efbdfbfad2364e5d0a322c37a4f071b6462f3a4047f53ebde85ae4c0c88b5d
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
namespace :iro do desc 'watch stocks' task watch_stocks: :environment do while true begin Timeout::timeout( 10 ) do TDA::Api.get_quotes Iro::Stock.active.map(&:ticker).join(",") end rescue Exception => e puts! e, 'Error in iro:watch_stocks' # Wco::Exceptionist.notify(e, 'Error in iro:watch_stocks') end sleep Iro::Stock::SLEEP_TIME_SECONDS end end desc 'alerts' task alerts: :environment do print 'iro:alerts' while true Iro::Alert.active.each do |alert| # price = Iro::Stock.latest( alert.ticker ).price price = Tda::Api.get_quote( alert.symbol ).last if alert.direction == Iro::Alert::DIRECTION_ABOVE && price >= alert.strike || alert.direction == Iro::Alert::DIRECTION_BELOW && price <= alert.strike Iro::AlertMailer.stock_alert( alert ).deliver_later alert.update_attributes({ status: Iro::Alert::STATUS_INACTIVE }) print '^' end end print '.' sleep Iro::Alert::SLEEP_TIME_SECONDS end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
iron_warbler-2.0.7.6 | lib/tasks/iro_tasks.rake |
iron_warbler-2.0.7.5 | lib/tasks/iro_tasks.rake |