Skip to content

dpisarewski/oanda_exchange

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OandaExchange

API for OANDA exchange webservices

Installation

Add this line to your application's Gemfile:

gem 'oanda_exchange', :git => "git://github.com/dpisarewski/oanda_exchange.git"

And then execute:

bundle install

Usage

  1. Copy oanda_api.yml into rails config directrory

  2. Insert your client_id from your OANDA subscription

  3. Use Oanda.exchange(base_currency, options) method to convert currency

Examples:

Oanda.exchange(:usd, :to => :eur)
Oanda.exchange(:eur, :to => :usd, :date => Date.new(2010, 1, 1), :days => 14, :amount => 200, :interbank => 2)

To use exchange with ruby money(http://money.rubyforge.org/) add into your application configuration:

Money.default_bank = OandaBank.new

To obtain a hash with all supported currencies use

Oanda.currencies

To avoid API calls to OANDA in test environment you can use predefined stubs:

OandaExchange::Stubs.stub!(options)

options can be :currencies and :rates. :currencies should be a hash that is returned by Oanda.currencies. Default value for :currencies is {"USD" => "US Dollar", "EUR" => "Euro"}

:rates should be a hash that is used for currency conversion by Oanda.exchange. Default value for rates is {"USD" => 1, "others" => 1.5}

For example

OandaExchange::Stubs.stub! :currencies => {"USD" => "US Dollar",
                                           "CAD" => "Canadian Dollar",
                                           "RUB" => "Russian Rouble"},
                           :rates =>      {"CAD" => 0.7, "RUB" => 0.03}

About

API to interact with OANDA Exchange webservices

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages