Class: EconDataReader::Nasdaq

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/econ_data_reader/nasdaq.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(series, options = {}) ⇒ Nasdaq

Returns a new instance of Nasdaq.



25
26
27
28
# File 'lib/econ_data_reader/nasdaq.rb', line 25

def initialize(series, options={})
  @api_key = options[:nasdaq_api_key] || EconDataReader::Nasdaq.nasdaq_api_key
  @tag = series
end

Class Attribute Details

.nasdaq_api_keyObject

Returns the value of attribute nasdaq_api_key.



22
23
24
# File 'lib/econ_data_reader/nasdaq.rb', line 22

def nasdaq_api_key
  @nasdaq_api_key
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



14
15
16
# File 'lib/econ_data_reader/nasdaq.rb', line 14

def api_key
  @api_key
end

#tagObject (readonly)

debug_output $stdout



13
14
15
# File 'lib/econ_data_reader/nasdaq.rb', line 13

def tag
  @tag
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



16
17
18
19
# File 'lib/econ_data_reader/nasdaq.rb', line 16

def self.configure
  yield self
  true
end

Instance Method Details

#fetch(start: nil, fin: nil) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/econ_data_reader/nasdaq.rb', line 30

def fetch(start: nil, fin: nil)
  dta = observations({  }).parsed_response
  trans_dta = dta.transpose
  df = Polars::DataFrame.new({})

  s = trans_dta[0][1..-1].dup 
  s.map!{|t| t.to_date }
  df['Timestamps'] = Polars::Series.new(s)
  
  (1..trans_dta.length-1).to_a.each do |i|
    s = trans_dta[i][1..-1].dup
    s.map!{|t| t.to_f }
    df[dta[0][i]] = Polars::Series.new(s)
  end

  Polars::Config.set_tbl_cols(-1)
  Polars::Config.set_tbl_rows(-1)
  df
end