如何使用ruby在Yahoo上使用Symbol查找Industry by?

时间:2016-01-19 18:53:32

标签: ruby yahoo-api yahoo-finance

我正在尝试获取给定符号的公司信息,并且我使用精彩的“雅虎金融”宝石获得了报价数据,但现在我需要获取公司的行业信息,而找不到方法。 / p>

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

只需将:industry添加到要返回的字段列表中即可。 available_fields为您提供完整列表。如,

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"