Binya

The Ruby wrapper for the Fed

Download .zip Download .tar.gz View on GitHub

Binya

Binya is a Ruby library for parsing information from Federal Reserve sites. Its initial utility is to parse a listing of speeches, testimony and other comments by Federal Open Market Committee participants and return Ruby objects. It also provides details about the FOMC participants via a YAML file that can be loaded.

Binya is named for Binyamin Applebaum, a Washington correspondent for The New York Times.

Binya is tested under Ruby 1.9.3.

Installation

Add this line to your application's Gemfile:

gem 'binya'

And then execute:

$ bundle

Or install it yourself as:

$ gem install binya

Usage

Binya pulls information from the Federal Reserve Bank of St. Louis, which has a site that tracks members of the Federal Open Market Committee and public remarks they make. The FOMC participants are stored in a YAML file within the gem and can be loaded like so:

require 'rubygems'
require 'binya'

participants = Binya::Participant.load_all
puts participants.first
=> <Binya::Participant:0x007f987b924e90 @fomc_id=2, @name="Ben S. Bernanke", @title="Chairman, Board of Governors", @term_start=#<Date: 2006-02-01 ((2453768j,0s,0n),+0s,2299161j)>, @term_end=nil, @rss_url="http://www.stlouisfed.org/fomcspeak/xml/fomcspeak-bernanke-2-feed.xml", @img_url="http://www.stlouisfed.org/fomcspeak/Participants/bernanke_ben.jpg", @fomc_name="Chairman Bernanke">

The fomc_id corresponds to the number used in FOMC URLs like this one for Ben S. Bernanke. The fomc_name is how each participant appears in the HTML listings of remarks.

Individual participants in the FOMC have their own RSS feeds that contain similar information to the HTML remark lists, but the RSS feeds puts the "type", "where" and "what" columns from the HTML lists into a single attribute. Still, Binya has methods that you can use to load all FOMC participant RSS feeds or individual participant feeds if those fit your needs better:

# pulls from rss feeds of FOMC participants - this puts type, location and title into a single field
latest_from_rss = Binya::Remarks.latest
# grabs a single participant and pulls his/her RSS feed
participants = Binya::Participants.load_all
ben = participants.detect{|p| p.fomc_name == 'Chairman Bernanke'}
ben.latest_remarks

Because the St. Louis Fed site uses Javascript postbacks for pagination, Binya includes local HTML versions of the remarks listings that can be loaded to have remarks objects back to August 2010. Binya also is capable of scraping the latest "front page" of remarks listings, which is ordered by date descending:

# scrapes locally-stored HTML files
results = Binya::Remarks.fetch_previous
puts results.size
=> 275

# scrapes http://www.stlouisfed.org/fomcspeak/date.aspx
results = Binya::Remarks.fetch_html
puts results.first
=> <Binya::Remarks:0x007f987b8f2dc8 @date=#<Date: 2013-07-02 ((2456476j,0s,0n),+0s,2299161j)>, @time=2013-07-02 17:45:00 -0400, @participant="Jerome H. Powell", @participant_id=22, @type="Speech", @location="The University Club, New York, N.Y.", @title="International Financial Regulatory ReformĀ ", @url="http://www.federalreserve.gov/newsevents/speech/powell20130702a.htm">

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request