app/models/iro/alert.rb in iron_warbler-2.0.7.18 vs app/models/iro/alert.rb in iron_warbler-2.0.7.19
- old
+ new
@@ -33,10 +33,11 @@
validates :strike, presence: true
def do_run
alert = self
begin
- price = Tda::Stock.get_quote( alert.symbol ).last
+ 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 )
Iro::AlertMailer.stock_alert( alert.id.to_s ).deliver_later