class Iro::Alert
def self.active
def self.active where( status: STATUS_ACTIVE ) end
def self.directions_list
def self.directions_list [ nil, DIRECTION_ABOVE, DIRECTION_BELOW ] end
def do_run
def do_run alert = self begin price = Tda::Stock.get_quote( alert.symbol )&.last return if !price if ( alert.direction == alert.class::DIRECTION_ABOVE && price >= alert.strike ) || ( alert.direction == alert.class::DIRECTION_BELOW && price <= alert.strike ) if Rails.env.production? Iro::AlertMailer.stock_alert( alert.id.to_s ).deliver_later else Iro::AlertMailer.stock_alert( alert.id.to_s ).deliver_now end alert.update({ status: alert.class::STATUS_INACTIVE }) print '^' end rescue => err puts! err, 'err' ::ExceptionNotifier.notify_exception( err, data: { alert: alert } ) end end