if (strtotime($ir['trade_date']) >= strtotime($month9_start)) { $return_9m = $return_9m * $ir['return']; } if (strtotime($ir['trade_date']) >= strtotime($month1y_start)) { $return_1y = $return_1y * $ir['return']; } //if($inst_num == 0){ //} } $return_all_time = $port_chart_value; if ($inst_num == 0) { $series[] = ['name' => "Benchmark", 'data' => $bench_data[$i]]; } $series[] = ['name' => $instrument['instrument'], 'data' => $port_data[$i]]; $i++; $allstats = Calculators::CalcAllStats1($port_ret, $bench_ret); $tbl_rows .= '<tr> <td>' . $instrument['instrument'] . '</td> <td>' . number_format(($return_all_time - 1) * 100, 1) . '%</td> <td>' . number_format(($return_ytd - 1) * 100, 1) . '%</td> <td>' . number_format(($return_3m - 1) * 100, 1) . '%</td> <td>' . number_format(($return_6m - 1) * 100, 1) . '%</td> <td>' . number_format(($return_9m - 1) * 100, 1) . '%</td> <td>' . number_format(($return_1y - 1) * 100, 1) . '%</td> <td>' . number_format($allstats[0] * 100, 1) . '%</td> <td>' . number_format($allstats[1], 3) . '</td> <td>' . number_format($allstats[2], 3) . '</td> <td>' . number_format($allstats[4], 3) . '</td> <td>' . number_format($allstats[13], 3) . '</td> <td>' . number_format($allstats[14], 3) . '</td> <td>' . number_format($allstats[3], 3) . '</td>
public function run() { Calculators::CurrenyRatesUpdate(); }
//Trades $inst1 = Yii::app()->db->createCommand("select distinct trade_date, price from prices where instrument_id = {$instrument_id1} order by trade_date")->queryAll(true); $inst2 = Yii::app()->db->createCommand("select distinct trade_date, price from prices where instrument_id = {$instrument_id2} order by trade_date")->queryAll(true); foreach ($inst1 as $i1) { $returnTarget[] = $i1['price']; } foreach ($inst2 as $i2) { $returnBenchmark[] = $i2['price']; } ?> <div class="row-fluid"></div> <div class="span1"></div> <div class="span12"> <?php if ($inst1 & $inst2) { $allstats = Calculators::CalcAllStats1($returnTarget, $returnBenchmark); ?> <table> <tr> <td>VolTarget</td> <td><?php echo $allstats[0]; ?> </td> </tr> <tr> <td>Sharpe</td> <td><?php echo $allstats[1]; ?> </td>
} if (strtotime($pr['trade_date']) >= strtotime($month9_start)) { $return_9m = $return_9m * $pr['return']; $return_9m_bench = $return_9m_bench * $pr['benchmark_return']; } if (strtotime($pr['trade_date']) >= strtotime($month1y_start)) { $return_1y = $return_1y * $pr['return']; $return_1y_bench = $return_1y_bench * $pr['benchmark_return']; } } $return_all_time = $port_chart_value; $return_all_time_bench = $bench_chart_value; $series[] = ['name' => $port['portfolio'], 'data' => $port_data]; $series[] = ['name' => $port['portfolio'] . "-benchmark", 'data' => $bench_data]; $allstats = Calculators::CalcAllStats1($port_ret, $bench_ret); $allstats_bench = Calculators::CalcAllStats_bench($bench_ret, $bench_ret); $tbl_rows .= '<tr> <td>' . $port['portfolio'] . '</td> <td>' . number_format(($return_all_time - 1) * 100, 2) . '%</td> <td>' . number_format(($return_ytd - 1) * 100, 2) . '%</td> <td>' . number_format(($return_3m - 1) * 100, 2) . '%</td> <td>' . number_format(($return_6m - 1) * 100, 2) . '%</td> <td>' . number_format(($return_9m - 1) * 100, 2) . '%</td> <td>' . number_format(($return_1y - 1) * 100, 2) . '%</td> <td>' . number_format($allstats[0] * 100, 2) . '%</td> <td>' . number_format($allstats[1], 3) . '</td> </tr>'; $tbl_rows .= '<tr> <td>' . $port['portfolio'] . '-Benchmark</td> <td>' . number_format(($return_all_time_bench - 1) * 100, 2) . '%</td> <td>' . number_format(($return_ytd_bench - 1) * 100, 2) . '%</td>
public function actionUpdateRates() { Calculators::CurrenyRatesUpdate(); }