Ruby/Finance allows access to changing financial data, such as stock quotes and currency conversion rates.
For the foreseeable future, it is intended to be a port of Perl's Finance::Quote module.
Examples:
Currency conversion
require 'finance/currency'
Display the US Dollar ($) to Euro () conversion rate.
puts Finance::Currency::convert( 'EUR', 'USD' )
Display the British Pounds Sterling () to Icelandic Kronur conversion
rate for the amount of 32.50.
puts Finance::Currency::convert( 'ISK', 'GBP', 32.50 )
Stock quotes
require 'finance/quote'
q = Finance::Quote.new Answers will be given in the native
currency of the exchange on which
they are listed.
q = Finance::Quote.new( 'EUR' ) Answers will be given in Euros.
q.currency = 'VND' Switch to using Vietnamese Dong.
info = q.fetch( 'usa', 'CRM' ) Fetch a single quote, namely CRM.
info = q.fetch( :usa, 'EBAY', 'AMZN' ) Fetch EBAY and AMZN. Note that
a Symbol can be used instead of a
String for the exchange name.
info = q.fetch( 'usa', %w[ EBAY AMZN ] ) An Array of ticker symbols is
OK, too.
puts info['EBAY'][:price]
A block can be passed, too:
q.fetch( :usa, 'RHAT' ) { |info| puts info['RHAT'][:high] }
You can also bypass #fetch and call the exchange as a method:
q.usa( 'RHAT' ) { |info| puts info['RHAT'][:high] }
Installation:
Minero Aoki's setup.rb script is included. Extensive documentation for this script can be found at the end of this document.
Basically, however, the following should be enough to install the package:
$ ruby setup.rb config
$ ruby setup.rb setup
# ruby setup.rb install
("#" line may require root privilege)
Product's homepage