Sha256: 27701690be7fcabd5fba0d678c76423f0051df8cd253e250eba05e69f1347bb4
Contents?: true
Size: 969 Bytes
Versions: 4
Compression:
Stored size: 969 Bytes
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 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 end end sleep Iro::Alert::SLEEP_TIME_SECONDS end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
iron_warbler-2.0.7.4 | lib/tasks/iro_tasks.rake |
iron_warbler-2.0.7.3 | lib/tasks/iro_tasks.rake |
iron_warbler-2.0.7.2 | lib/tasks/iro_tasks.rake |
iron_warbler-2.0.7.1 | lib/tasks/iro_tasks.rake |