Class: Ytterb::StockSymbol::MarketLoader
- Inherits:
-
Object
- Object
- Ytterb::StockSymbol::MarketLoader
- Defined in:
- lib/ytterb/stock_symbol/market_loader.rb
Instance Method Summary collapse
- #industries ⇒ Object
-
#initialize(options = {}) ⇒ MarketLoader
constructor
A new instance of MarketLoader.
- #sectors ⇒ Object
- #stock_symbols ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ MarketLoader
Returns a new instance of MarketLoader.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ytterb/stock_symbol/market_loader.rb', line 7 def initialize(={}) @stock_symbols = [] path = Util::Settings.new.get_raw_symbol_list_data_dir i=1 Dir.entries(path).select {|f| !File.directory?(f) and /companylist_[a-zA-Z]+\.csv/ =~ f }.each do |file_to_process| market = /companylist_(?<market>[a-zA-Z]+)\.csv/.match(file_to_process)[:market] Stock.builder_from_csv(File.join(path,file_to_process),market) do |stock_symbol| if [:with_feedback] print "." print "#{i}\n" if (i%80==0) i+=1 end @stock_symbols << stock_symbol end end print "\n" if [:with_feedback] end |
Instance Method Details
#industries ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/ytterb/stock_symbol/market_loader.rb', line 25 def industries return @industries if @industries @raw_industries = {} @stock_symbols.each do |stock_symbol| @raw_industries[stock_symbol.industry] = 1 end @industries = @raw_industries.keys end |
#sectors ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/ytterb/stock_symbol/market_loader.rb', line 34 def sectors return @sectors if @sectors @raw_sectors = {} @stock_symbols.each do |stock_symbol| @raw_sectors[stock_symbol.sector] = 1 end @sectors = @raw_sectors.keys end |
#stock_symbols ⇒ Object
43 44 45 |
# File 'lib/ytterb/stock_symbol/market_loader.rb', line 43 def stock_symbols @stock_symbols end |