SEC

<img src=“https://travis-ci.org/reinventinghorses/sec.png” />

Retrieve XBRL information from the U.S. Securities and Exchange Commission.

Installation

Add this line to your application’s Gemfile:

gem 'sec'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sec

Usage

To retrieve an index of all XBRL filings for March 2012:

> response = Sec::Reader.get_monthly_index(2012, 3)

The response is an RSS document, with each filing in response[‘item’]

> response['rss']['channel']['item'].count
=> 4195

From there, you can retrieve an individual file:

> response = Sec::Reader.get_xbrl_file("http://www.sec.gov/Archives/edgar/data/840715/000084071512000011/clro-20111231.xml")
> puts response.body
> <?xml version='1.0' encoding='iso-8859-1'?>
> ...

The entries of type “edgar:description”=>“XBRL INSTANCE DOCUMENT” can be parsed by xbrlware-ruby19 for financial facts:

> require 'xbrlware-ruby19'

> ins = Xbrlware.ins(<xbrl_instance_file_path>) # Initialize XBRL instance
> items = ins.item("ProfitLoss") # Fetch all "ProfitLoss" financial fact
> items.each do |item|
>   puts item.value # Print value of each "ProfitLoss" item
> end

Thanks

Many thanks are owed to the following for me to be able to release my first gem:

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

Licensing

The SEC gem is released under the MIT License.