Sha256: 0755ab577f82970e023361c0c6217275fb8b93b39bfa689593d1780eda6e7081

Contents?: true

Size: 965 Bytes

Versions: 3

Compression:

Stored size: 965 Bytes

Contents

# YahooFinance Module for YahooFinance gem
module YahooFinance
  # FinanceUtils Module
  module FinanceUtils
    def self.included(base)
      base.extend(self)
    end

    MARKETS = OpenStruct.new(
      us: OpenStruct.new(
        nasdaq: OpenStruct.new(
          url: "http://www.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=nasdaq&render=download"),
        nyse: OpenStruct.new(
          url: "http://www.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=nyse&render=download"),
        amex: OpenStruct.new(
          url: "http://www.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=amex&render=download")))

    def symbols_by_market(country, market)
      symbols = []
      return symbols unless MARKETS[country][market]
      CSV.foreach(open(MARKETS[country][market].url)) do |row|
        next if row.first == "Symbol"
        symbols.push(row.first.gsub(" ", ""))
      end
      symbols
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
yahoo-finance-1.2.0 lib/yahoo-finance/finance-utils.rb
yahoo-finance-1.1.0 lib/yahoo-finance/finance-utils.rb
yahoo-finance-1.0.0 lib/yahoo-finance/finance-utils.rb