PhillyFrbAsDataframe
Up to date remote economic data access for ruby, using Polars dataframes.
This package will fetch economic and financial information from the Federal Reserve Bank of Philadelphia, and return the results as a Polars dataframe. For details regarding the data available from the Philadelphia FRB, see https://www.philadelphiafed.org/surveys-and-data . This gem exposes the Partisan Conflict Index (see https://www.philadelphiafed.org/surveys-and-data/macroeconomic-data/partisan-conflict-index) and the Survey of Professional Forecasters (see https://www.philadelphiafed.org/-/media/frbp/assets/surveys-and-data/survey-of-professional-forecasters/spf-documentation.pdf).
Requirements
- Ruby >= 3.3
- polars-df 0.27.1
Installation
Add this line to your application's Gemfile:
gem 'philly_frb_as_dataframe'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install philly_frb_as_dataframe
Usage
3.3.6 :001 > PhillyFrbAsDataframe::PartisanConflict.new.fetch
=>
shape: (522, 2)
and
3.3.6 :001 > a = PhillyFrbAsDataframe::SurveyProfForecasters.new
=> #<PhillyFrbAsDataframe::SurveyProfForecasters:0x0000000106e18640>
3.3.6 :002 > a.fetch
=>
shape: (223, 308)
Testing
Tests use minitest with mocked XLSX files and WebMock for network requests. Run tests with:
bundle exec rake test
No GitHub Actions or CI workflows are configured for this project.
Development
After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.
Testing
This gem includes a comprehensive test suite using Minitest. Tests use webmock to stub HTTP requests, ensuring no live network calls are made during testing.
To run the test suite:
bundle install
bundle exec rake test
The test suite covers:
PartisanConflict#fetch- fetching and parsing partisan conflict index dataSurveyProfForecasters#fetch- fetching and parsing survey of professional forecasters data- Date filtering with
startandfinparameters - DataFrame structure and column validation
All HTTP requests are mocked using webmock with xlsx fixtures stored in test/fixtures/.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/philly_frb_as_dataframe. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the PhillyFrbAsDataframe project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.