Class: StockIndex

Inherits:
Object
  • Object
show all
Defined in:
lib/stock_index/market.rb,
lib/stock_index/indices.rb,
lib/stock_index/version.rb,
lib/stock_index/component.rb,
lib/stock_index/bsym_search.rb,
lib/stock_index/stock_index.rb,
lib/stock_index/scrapers/base_scraper.rb

Defined Under Namespace

Classes: BaseScraper, BsymSearch, Component, Market

Constant Summary collapse

INDICES =
{
  '^DJI' => {
    name: 'DOW JONES INDUSTRIAL AVERAGE',
    url: 'https://en.wikipedia.org/wiki/Dow_Jones_Industrial_Average'
  },
  '^GSPC' => {
    name: 'S&P 500',
    url: 'https://en.wikipedia.org/wiki/List_of_S%26P_500_companies'
  },
  '^NDX' => {
    name: 'NASDAQ 100',
    url: 'https://en.wikipedia.org/wiki/NASDAQ-100'
  },
  '^N225' => {
    name: 'NIKKEI 225',
    url: 'http://indexes.nikkei.co.jp/en/nkave/index/component?idx=nk225',
    wikipedia_url: 'https://en.wikipedia.org/wiki/Nikkei_225'
  },
  '^STOXX50E' => {
    name: 'EURO STOXX 50',
    url: 'http://www.stoxx.com/indices/index_information.html?symbol=SX5E'
  },
  '^FTSE' => {
    name: 'FTSE 100',
    url: 'http://www.londonstockexchange.com/exchange/prices-and-markets/stocks/indices/summary/summary-indices-constituents.html?index=UKX',
    wikipedia_url: 'https://en.wikipedia.org/wiki/FTSE_100_Index#Current_constituents'
  }
}
VERSION =
"0.8.7"

Instance Method Summary collapse

Constructor Details

#initialize(symbol) ⇒ StockIndex

Returns a new instance of StockIndex.



3
4
5
# File 'lib/stock_index/stock_index.rb', line 3

def initialize(symbol)
  @symbol = symbol
end

Instance Method Details

#componentsObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/stock_index/stock_index.rb', line 7

def components
  case @symbol
    when '^DJI'
      DjiScraper.new.scrape
    when '^GSPC'
      SP500Scraper.new.scrape
    when '^NDX'
      NasdaqScraper.new.scrape
    when '^N225'
      NikkeiScraper.new.scrape
    when '^FTSE'
      FtseScraper.new.scrape
    else
      []
  end
end