0.0
No commit activity in last 3 years
No release in over 3 years
OANDA Exchange API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

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}