Search code examples
rubyyahoo-apiyahoo-finance

How do I lookup Industry by Symbol on Yahoo using ruby?


I am trying to get company information for a given symbol, and I have gotten quotes data using a wonderful 'yahoo-finance' gem, but now I need to get company's industry information, and can't find a way.

Any ideas?


Solution

  • Just add :industry to the list of fields you want returned. available_fields gives you the full list. E.g.,

    require 'yahoo_finance'
    stocks = YahooFinance::Stock.new(['AAPL'], [:industry, :sector])
    # use stocks.available_fields to search for the fields that you want
    results = stocks.fetch; nil
    results['AAPL'][:industry]
    # "Electronic Equipment"
    results['AAPL'][:sector]
    # "Consumer Goods"