Sha256: 117282c31a11528d67ae3b504d48ff8a024b6377d3406b2ace0b7501012598c2
Contents?: true
Size: 963 Bytes
Versions: 46
Compression:
Stored size: 963 Bytes
Contents
class ::YahooStockwatcher # For: https://query1.finance.yahoo.com/v7/finance/chart/qqq?interval=1d&indicators=quote def watch_once stocks = Ish::StockWatch.where( :notification_type => :EMAIL ) # puts! stocks.map(&:ticker), "Watching these stocks" stocks.each do |stock| # puts! stock.ticker, 'ticker' r = HTTParty.get "https://query1.finance.yahoo.com/v7/finance/chart/#{stock.ticker}?interval=1d&indicators=quote", timeout: 10 r = JSON.parse( r.body ).deep_symbolize_keys r = r[:chart][:result][0][:meta][:regularMarketPrice] if stock.direction == :ABOVE && r >= stock.price || stock.direction == :BELOW && r <= stock.price IshManager::ApplicationMailer.stock_alert( stock ).deliver ## actions ## exit the position # stock.stock_actions.where( :is_active => true ).each do |action| # # @TODO: actions # end end end end end
Version data entries
46 entries across 46 versions & 1 rubygems