//Rate of change
function GetVal($v1, $v2)
{
if ($v2 == 0) {
return;
}
return log($v1/$v2)*10000;
}
function GetValM($v1, $v2, $v3, $v4)
{
$v1 = $v1 * $v3;
$v2 = $v2 * $v4;
if ($v2 == 0) {
return;
}
return log($v1/$v2)*10000;
}
function GetValD($v1, $v2, $v3, $v4)
{
if ($v3 == 0 || $v4 == 0) {
return;
}
$v1 = $v1 / $v3;
$v2 = $v2 / $v4;
if ($v2 == 0) {
return;
}
return log($v1/$v2)*10000;
}
//$v1 is the current price, $v2 is the price of the starting point
$EURUSD = GetVal($v1['EURUSD'],$v2['EURUSD']);
$USDJPY = GetVal($v1['USDJPY'],$v2['USDJPY']);
$USDCHF = GetVal($v1['USDCHF'],$v2['USDCHF']);
$GBPUSD = GetVal($v1['GBPUSD'],$v2['GBPUSD']);
$AUDUSD = GetVal($v1['AUDUSD'],$v2['AUDUSD']);
$USDCAD = GetVal($v1['USDCAD'],$v2['USDCAD']);
$NZDUSD = GetVal($v1['NZDUSD'],$v2['NZDUSD']);
$EURJPY = GetValM($v1['EURUSD'],$v2['EURUSD'],$v1['USDJPY'],$v2['USDJPY']);
$EURCHF = GetValM($v1['EURUSD'],$v2['EURUSD'],$v1['USDCHF'],$v2['USDCHF']);
$EURGBP = GetValD($v1['EURUSD'],$v2['EURUSD'],$v1['GBPUSD'],$v2['GBPUSD']);
$CHFJPY = GetValD($v1['USDJPY'],$v2['USDJPY'],$v1['USDCHF'],$v2['USDCHF']);
$GBPCHF = GetValM($v1['GBPUSD'],$v2['GBPUSD'],$v1['USDCHF'],$v2['USDCHF']);
$GBPJPY = GetValM($v1['GBPUSD'],$v2['GBPUSD'],$v1['USDJPY'],$v2['USDJPY']);
$AUDCHF = GetValM($v1['AUDUSD'],$v2['AUDUSD'],$v1['USDCHF'],$v2['USDCHF']);
$AUDJPY = GetValM($v1['AUDUSD'],$v2['AUDUSD'],$v1['USDJPY'],$v2['USDJPY']);
$AUDCAD = GetValM($v1['AUDUSD'],$v2['AUDUSD'],$v1['USDCAD'],$v2['USDCAD']);
$EURCAD = GetValM($v1['EURUSD'],$v2['EURUSD'],$v1['USDCAD'],$v2['USDCAD']);
$GBPCAD = GetValM($v1['GBPUSD'],$v2['GBPUSD'],$v1['USDCAD'],$v2['USDCAD']);
$GBPAUD = GetValD($v1['GBPUSD'],$v2['GBPUSD'],$v1['AUDUSD'],$v2['AUDUSD']);
$EURAUD = GetValD($v1['EURUSD'],$v2['EURUSD'],$v1['AUDUSD'],$v2['AUDUSD']);
$CADCHF = GetValD($v1['USDCHF'],$v2['USDCHF'],$v1['USDCAD'],$v2['USDCAD']);
$CADJPY = GetValD($v1['USDJPY'],$v2['USDJPY'],$v1['USDCAD'],$v2['USDCAD']);
$AUDNZD = GetValD($v1['AUDUSD'],$v2['AUDUSD'],$v1['NZDUSD'],$v2['NZDUSD']);
$EURNZD = GetValD($v1['EURUSD'],$v2['EURUSD'],$v1['NZDUSD'],$v2['NZDUSD']);
$GBPNZD = GetValD($v1['GBPUSD'],$v2['GBPUSD'],$v1['NZDUSD'],$v2['NZDUSD']);
$NZDCAD = GetValM($v1['NZDUSD'],$v2['NZDUSD'],$v1['USDCAD'],$v2['USDCAD']);
$NZDCHF = GetValM($v1['NZDUSD'],$v2['NZDUSD'],$v1['USDCHF'],$v2['USDCHF']);
$NZDJPY = GetValM($v1['NZDUSD'],$v2['NZDUSD'],$v1['USDJPY'],$v2['USDJPY']);
//Calculate the value of each currency
$Pairs = 7;
$EUR = ($EURUSD+$EURJPY+$EURCHF+$EURGBP+$EURAUD+$EURCAD+$EURNZD)/$Pairs;
$USD = (-$EURUSD+$USDJPY+$USDCHF-$GBPUSD-$AUDUSD+$USDCAD-$NZDUSD)/$Pairs;
$JPY = (-$EURJPY-$USDJPY-$CHFJPY-$GBPJPY-$AUDJPY-$CADJPY-$NZDJPY)/$Pairs;
$CHF = (-$EURCHF-$USDCHF+$CHFJPY-$GBPCHF-$AUDCHF-$CADCHF-$NZDCHF)/$Pairs;
$GBP = (-$EURGBP+$GBPUSD+$GBPCHF+$GBPJPY+$GBPAUD+$GBPCAD+$GBPNZD)/$Pairs;
$AUD = (-$EURAUD+$AUDUSD+$AUDJPY+$AUDCHF-$GBPAUD+$AUDCAD+$AUDNZD)/$Pairs;
$CAD = (-$EURCAD-$USDCAD+$CADJPY+$CADCHF-$GBPCAD-$AUDCAD-$NZDCAD)/$Pairs;
$NZD = (-$EURNZD+$NZDUSD+$NZDJPY+$NZDCHF-$GBPNZD+$NZDCAD-$AUDNZD)/$Pairs;