Topic: Inidan Forex Rates from RBI

@joe: Kindly add RBI into the list of forex providers as appropriate using the list from my function.

At the moment, YAHOO does not provide Forex for FA.
Link: http://203.84.220.151/d/quotes.csv?s=INRLKR=X&f=sl1d1t1ba&e=.csv

ECB provides Forex rates for:

AUD
BGN
BRL
CAD
CHF
CNY
CZK
DKK
GBP
HKD
HRK
HUF
IDR
ILS
INR
ISK
JPY
KRW
MXN
MYR
NOK
NZD
PHP
PLN
RON
RUB
SEK
SGD
THB
TRY
USD
ZAR

Link: http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml

GOOGLE works for some currencies and the list of valid currencies differs between access locations.
Link: http://finance.google.com/finance/converter?a=1&from=LKR&to=INR

BLOOMBERG has issues with some currencies like LKR.

https://www.bloomberg.com/quote/LKRINR:CUR

The search for LKRINR:CUR produced no matches. Try the symbol search.

Many symbols available on the Bloomberg Professional Service are not available on Bloomberg.com. To learn more about the Bloomberg Professional Service...

Re: Inidan Forex Rates from RBI

Is there any solution for PKR as base currency?

www.boxygen.pk

Re: Inidan Forex Rates from RBI

https://free.currencyconverterapi.com/api/v5/convert?q=PHP_PKR&compact=y

This Gives Results. Can anyone suggest the Code for this

www.boxygen.pk

Re: Inidan Forex Rates from RBI

I have not tested the code. But it might work for you.

$url = 'https://free.currencyconverterapi.com/api/v5/convert?q=PHP_PKR&compact=y;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([]));
$response = curl_exec($ch); 

$res = json_decode($response); 

print_r($res); 

echo $res['PHP_PKR']->val; //this one i am not sure. it may be two dimensional array. So check with it by using print_r

Re: Inidan Forex Rates from RBI

@boxygen: the json output can be parsed into an array and then manipulated.

If some currency pairs are one way only quotients exceeding 4 digits of zeroes in the decimal places then an intermediate exchange rate can be used in the division in reverse.

6 (edited by boxygen 04/24/2018 06:43:13 pm)

Re: Inidan Forex Rates from RBI

Adding following 2 Code Components in gl/includes/db/gl_db_rates.inc Worked

at Line 163

elseif ($provider == 'CCA') //free.currencyconverterapi.com
    {
        $filename = "/api/v5/convert?q={$curr_b}_{$curr_a}&compact=y";
        $site = "free.currencyconverterapi.com";
        $proto = 'https://';

    }

and at Line 240

    elseif ($provider == 'CCA')
    {
        $rates = json_decode($contents, true);
        $val = $rates[$curr_b.'_'.$curr_a]['val'];
      }

and It works for all currencies without fail

www.boxygen.pk