Sha256: 5cad95573bfca2251b225c87e65adf630b860466e8206669caf3b2a597af73f6

Contents?: true

Size: 814 Bytes

Versions: 2

Compression:

Stored size: 814 Bytes

Contents

class StockIndex

  class BsymSearch

    require 'csv'

    EXCEPTIONS = {
      'BIDU' => {name: 'BAIDU INC', bbgid: 'BBG000QXWHD1'},
      'LVNTA' => {name: 'LIBERTY VENTURES', bbgid: 'BBG0038K9G41'},
      'VIP' => {name: 'VIMPELCOM LTD', bbgid: 'BBG000QCW561'},
      'VOD' => {name: 'VODAFONE GROUP PLC', bbgid: 'BBG000C4R6H6'}
    }

    class << self

      def find(symbol, pricing_source)
        return {name: EXCEPTIONS[symbol][:name], bbgid: EXCEPTIONS[symbol][:bbgid]} if EXCEPTIONS.keys.include? symbol
        CSV.foreach(files(pricing_source)) do |row|
          return {name: row[1], bbgid: row[2]} if row[0] == symbol
        end
      end

      def files(pricing_source)
        File.expand_path("../../bsym/#{pricing_source.upcase}.csv", File.dirname(__FILE__))
      end

    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stock_index-0.8.3 lib/stock_index/bsym_search.rb
stock_index-0.8.2 lib/stock_index/bsym_search.rb