Forex - Historic Foreign Exchange Rates from Open Exchange Rates
1.2
use Forex; my $oxr = new Forex( 'APP_ID' => $app_id, 'BASE' => 'USD'); #__fetch and initialize daily rates from $from_date to $to_date in yyyy-mm-dd $oxr->get_rates_from ( $from_date, $to_date ); #___ fetches rates for $date (yyyy-mm-dd) $oxr->get_rates( $date ); #___ fetches reates for today $oxr->get_rates(); #___ gives AUD on 2012-09-01 in USD Base currency $usd = $oxr->get_rate_of ( 'AUD', '2012-09-01' ); if ($Forex::OXR::LASTERROR ) { print "\n Something went wrong" , $oxr->last_error_message(); }
returns new Forex object with defaults values for OXR_HOME = 'http://openexchangerates.org', API_HOOK = 'api', APP_ID = 'temp-e091fc14b3884a516d6cc2c299a', BASE = 'USD'
my $oxe = new Forex::OXR( OXR_HOME => 'https://openexchangerates.org', API_HOOK => 'api', APP_ID => 'temp-e091fc14b3884a516d6cc2c299a', BASE => 'AUD');
This method returns forex rate for $currency on $date in USD, $date should be in yyyy-mm-dd format. This method looks for currency rates in $obj->{ CURRENCIES } array.Which is filled by get_rates or get_rates_from() methods
yyyy-mm-dd
get_rates
get_rates_from()
my $AUD = $oxr->get_rate_of( 'AUD' , '2012-09-10' );
downloads and fills in values for all currencies in the $obj->{CURRENCIES} hash for $from_date - $to_date both dates should be in yyyy-mm-dd formate
downloads and fills in values for all currencies in the $obj->{CURRENCIES} hash for given $day $day should be in yyyy-mm-dd formate if $day is skipped , it uses todays date,
$day
todays date
this method downloads and initializes all currency symbols from openexchangerates site. this method should be run before either get_rates or get_rates_from
get_rates_from
sets BASE currency so that succeeding request will request the rates with base currency as specified by $BASE_CURRENCY. if the parameter is omitted it return the current BASE_CURRENCY value;
Note: you will have to flush the $CURRENCIES hash if you change the BASE currency. with flush_values()
flush_values()
sets OXR_HOME parameter to $OXR_HOME value , if the parameter is omitted it returns the current value of the OXR_HOME. OXR_HOME value should cuntaion "http://" .
Note: you could you it to change the default "http://" to "https://" if you have enterprise APP_ID
sets app_id for all succeeding requests. return current app_id if the parameter is omitted.
returns all the currencies in the currencies hash
returns last error object as returned by Open Exchange Rates API
returns last error message
on errors module sets $LASTERROR global variable which can be accessed by $Forex::LASTERROR. And error message can be accessed via last_error_message() or last_error()
please submit known issues or bugs to mail4bhavin@yahoo.com
Bhavin Patel <mail4bhavin@gmail.com
This Software is free to use , licensed under:
The Artistic License 2.0 (GPL Compatible)
To install Forex, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Forex
CPAN shell
perl -MCPAN -e shell install Forex
For more information on module installation, please visit the detailed CPAN module installation guide.