econ_data_reader 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd40e506a630506881b817b2a6eef015be0b85acedf9a1269c44441943e58682
4
- data.tar.gz: 81015938f3f2714f53a22546e5a3be84ce0cfce261250952f465e9489ac75a42
3
+ metadata.gz: c39231152157e0dc59a738be8287486fbd3459892ae02cf00e6b1d4b9f50075c
4
+ data.tar.gz: 54fce78785df4142f8de8789d26433a24bbf4b5301bb3ceb5470ea2f7707c16d
5
5
  SHA512:
6
- metadata.gz: 4bfc0cedf1204ef2e0eb802fe5ee96e438bb418e024e80fe2b23a133a47a2c97acca9ddc4cd7a12690047573d94cdf53e139dfa9abcb47fd6d04f5fee9a09359
7
- data.tar.gz: 790e705c3890cc020033fea4e50d2e55f3554c5d55ba9092a8ff408ff4d6c8c8a41619603327bc6f0dabd99f3910fbfdd957fb53a81c7a673c37da21e3e34208
6
+ metadata.gz: a487dfd3da7a84be980d7c9c7546cd861a0d1d6763c1d9a1c891c5d3d2e14ad985124d82916c6db4295b0075d88c486d620596a9d247291c28b88d316c45d8f3
7
+ data.tar.gz: cf9ee4f7aa4c9683e161b91aa7f46c8344a6b90a9990330b10c09b30d7a7e1d597ada8b636da7bbfe52328fc192ed5f6cdc765aaf072eb9cbd4a6d40a339e820
@@ -1,3 +1,4 @@
1
+ require 'polars-df'
1
2
  require 'httparty'
2
3
 
3
4
  module EconDataReader
@@ -1,3 +1,4 @@
1
+ require 'polars-df'
1
2
  require 'httparty'
2
3
 
3
4
  module EconDataReader
@@ -1,10 +1,10 @@
1
+ require 'polars-df'
1
2
  require 'httparty'
2
3
  require 'csv'
3
4
 
4
5
  module EconDataReader
5
6
  class Fred
6
7
  # Get data for the given name from the St. Louis FED (FRED).
7
- extend ActiveSupport::Concern
8
8
 
9
9
  include ::HTTParty
10
10
  attr_reader :tag
@@ -24,7 +24,7 @@ module EconDataReader
24
24
  end
25
25
 
26
26
  def fetch(start: nil, fin: nil, interval: '1d')
27
- data = _fetch_data(tag, interval)
27
+ data = _fetch_data(interval)
28
28
  i = interval[0..-2].to_i
29
29
 
30
30
  begin
@@ -43,19 +43,22 @@ module EconDataReader
43
43
 
44
44
  private
45
45
 
46
- def _url(n, i = 'd');
47
- "https://api.stlouisfed.org/fred/series/observations?series_id=#{n}&api_key=#{@api_key}&frequency=#{i}"
46
+ def _url(n, i = 'm');
47
+ "https://api.stlouisfed.org/fred/series/observations?series_id=#{n}&api_key=#{@api_key}#{i != 'd' ? "&frequency=#{i}" : ''}"
48
48
  end
49
49
 
50
50
 
51
- def _fetch_data(nm, interval)
51
+ def _fetch_data(interval)
52
52
  # Utility to fetch data
53
53
  i = interval.strip[-1]
54
+ nm = tag
54
55
  resp = nil
56
+
55
57
  if nm == 'SP500' && i == 'm'
56
58
  resp = sp500
57
59
  else
58
- resp = self.class.get(_url(nm, interval[-1])).parsed_response['observations']['observation'] #.map{|a| a.join(',')}.join("\n")
60
+ resp = self.class.get(_url(nm, interval[-1]))
61
+ resp = resp.parsed_response['observations']['observation'] #.map{|a| a.join(',')}.join("\n")
59
62
  resp = "date, #{nm}\n" + resp.map{|r| "#{r['date']},#{r['value']}" }.join("\n")
60
63
  end
61
64
  data = CSV.parse(resp, headers: true, header_converters: :symbol, converters: [:date, :float])
@@ -1,3 +1,4 @@
1
+ require 'polars-df'
1
2
  require 'httparty'
2
3
 
3
4
  module EconDataReader
@@ -1,3 +1,3 @@
1
1
  module EconDataReader
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -4,6 +4,7 @@ require 'econ_data_reader/bank_of_canada'
4
4
  require 'econ_data_reader/bls'
5
5
  require 'econ_data_reader/fred'
6
6
  require 'econ_data_reader/nasdaq'
7
+ require 'econ_data_reader/sahm'
7
8
 
8
9
  directory = File.expand_path(File.dirname(__FILE__))
9
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: econ_data_reader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bill McKinnon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-17 00:00:00.000000000 Z
11
+ date: 2024-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: polars-df