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>
//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>