Sha256: 61a87adbbc62ba187e10784e882adb5e8f250d3799b916bd2e572453748ce6d4

Contents?: true

Size: 666 Bytes

Versions: 2

Compression:

Stored size: 666 Bytes

Contents

class SymbolParser

  def initialize(symbol)
    @symbol = symbol
  end

  def sp500_to_bsym
    case @symbol
      # BRK.B => BRK/B (Berkshire Hathaway Inc)
      # BF.B  => BF/B  (Brown-Forman Corp)
      when /(\w+)\.B/
        "#{$1}/B"
      else
        @symbol
    end
  end

  def bsym_to_cik
    case @symbol
      # BRK/B (Berkshire Hathaway Inc)
      when 'BRK/B'
        '0001067983'
      # BF/B (Brown-Forman Corp)
      when 'BF/B'
        '0000014693'
      # QVCA (Liberty Interactive Corp)
      when 'QVCA'
        '0001355096'
      # LMCK (Liberty Media Corp)
      when 'LMCK'
        '0001560385'
      else
        @symbol
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stock_index-0.7.0 lib/stock_index/symbol_parser.rb
stock_index-0.6.0 lib/stock_index/symbol_parser.rb