public function trades()
 {
     if (!$this->requestAPI("trades", "public")) {
         return $this->render(array('json' => array('success' => 0, 'now' => time(), 'error' => "Too many requests from your IP. Try after some time.")));
     }
     $updates = new UpdatesController();
     $upBU = $updates->Rates('BTC', 'USD');
     $jdecBU = json_decode($upBU->body[0]);
     //print_r($jdecBU)		;
     $upBG = $updates->Rates('BTC', 'GBP');
     $jdecBG = json_decode($upBG->body[1]);
     //print_r($jdecBG)		;
     $upBE = $updates->Rates('BTC', 'EUR');
     $jdecBE = json_decode($upBE->body[2]);
     $upXU = $updates->Rates('XGC', 'USD');
     $jdecXU = json_decode($upBE->body[3]);
     $upXE = $updates->Rates('XGC', 'EUR');
     $jdecXE = json_decode($upBE->body[4]);
     $upXG = $updates->Rates('XGC', 'GBP');
     $jdecXG = json_decode($upBE->body[5]);
     $upBX = $updates->Rates('BTC', 'XGC');
     $jdecBX = json_decode($upBE->body[6]);
     //print_r($jdecBE)		;
     return $this->render(array('json' => array('success' => 1, 'now' => gmdate(time()), 'result' => array(array('Low' => number_format($jdecBU->Low, 2), 'High' => number_format($jdecBU->High, 2), 'Last' => number_format($jdecBU->Last, 2), 'Volume' => array(number_format($jdecBU->VolumeFirst, 2) . " BTC", number_format($jdecBU->VolumeSecond, 2) . " USD"), 'FirstUnit' => 'BTC', 'SecondUnit' => 'USD'), array('Low' => number_format($jdecBG->Low, 2), 'High' => number_format($jdecBG->High, 2), 'Last' => number_format($jdecBG->Last, 2), 'Volume' => array(number_format($jdecBG->VolumeFirst, 2) . " BTC", number_format($jdecBG->VolumeSecond, 2) . " GBP"), 'FirstUnit' => 'BTC', 'SecondUnit' => 'GBP'), array('Low' => number_format($jdecBE->Low, 2), 'High' => number_format($jdecBE->High, 2), 'Last' => number_format($jdecBE->Last, 2), 'Volume' => array(number_format($jdecBE->VolumeFirst, 2) . " BTC", number_format($jdecBE->VolumeSecond, 2) . " EUR"), 'FirstUnit' => 'BTC', 'SecondUnit' => 'EUR'), array('Low' => number_format($jdecXU->Low, 2), 'High' => number_format($jdecXU->High, 2), 'Last' => number_format($jdecXU->Last, 2), 'Volume' => array(number_format($jdecXU->VolumeFirst, 2) . " XGC", number_format($jdecXU->VolumeSecond, 2) . " USD"), 'FirstUnit' => 'XGC', 'SecondUnit' => 'USD'), array('Low' => number_format($jdecXG->Low, 2), 'High' => number_format($jdecXG->High, 2), 'Last' => number_format($jdecXG->Last, 2), 'Volume' => array(number_format($jdecXG->VolumeFirst, 2) . " XGC", number_format($jdecXG->VolumeSecond, 2) . " GBP"), 'FirstUnit' => 'XGC', 'SecondUnit' => 'GBP'), array('Low' => number_format($jdecXE->Low, 2), 'High' => number_format($jdecXE->High, 2), 'Last' => number_format($jdecXE->Last, 2), 'Volume' => array(number_format($jdecXE->VolumeFirst, 2) . " XGC", number_format($jdecXE->VolumeSecond, 2) . " EUR"), 'FirstUnit' => 'XGC', 'SecondUnit' => 'EUR'), array('Low' => number_format($jdecBX->Low, 2), 'High' => number_format($jdecBX->High, 2), 'Last' => number_format($jdecBX->Last, 2), 'Volume' => array(number_format($jdecBX->VolumeFirst, 2) . " BTC", number_format($jdecBX->VolumeSecond, 2) . " XGC"), 'FirstUnit' => 'BTC', 'SecondUnit' => 'XGC')))));
 }
Example #2
0
 public function SetGraph($first_curr, $second_curr)
 {
     $updates = new UpdatesController();
     $values = $updates->OHLC($first_curr, $second_curr);
     $datay = array();
     $days = array();
     $datav = array();
     $alts = array();
     $targ = array();
     if (count($values['result']) <= 1) {
         $datay = array(0, 0, 0, 0, 0, 0, 0, 0);
         $datav = array(0, 0);
         $days = array('N', 'N');
     }
     $i = 0;
     foreach ($values['result'] as $result) {
         array_push($datay, $result['Open']);
         array_push($datay, $result['High']);
         array_push($datay, $result['Low']);
         array_push($datay, $result['Close']);
         array_push($datav, $result['Volume']);
         array_push($alts, $result['Volume']);
         array_push($targ, "#");
         if ($i % 2) {
             array_push($days, $result['_id']['day'] . "/" . $result['_id']['month'] . "\n " . $result['_id']['hour'] . "h");
         } else {
             array_push($days, "");
         }
         $i++;
     }
     $graph = new Graph(750, 300);
     $stock_color_list = array('pos_lcolor' => '#555555', 'pos_color' => '#5555ee', 'neg_lcolor' => '#555555', 'neg_color' => '#ee5555');
     $color_list = array('#cc0055', '#00cc55');
     $graph->SetScale("textlin");
     $graph->SetFrame(true);
     $graph->yaxis->HideTicks(true);
     $graph->SetColor('#00fff');
     $graph->tabtitle->Set($first_curr . " / " . $second_curr . " - Volume");
     $p1 = new StockPlot($datay);
     $p1->SetCenter();
     $p1->SetWidth(6);
     $p1->SetColor($stock_color_list['pos_lcolor'], $stock_color_list['pos_color'], $stock_color_list['neg_lcolor'], $stock_color_list['neg_color']);
     $p1->HideEndLines(false);
     $p1->SetCSIMTargets($targ, $alts);
     $p1->SetLegend($first_curr . " / " . $second_curr);
     $gb = new BarPlot($datav);
     $gb->SetCSIMTargets($targ, $alts);
     $gb->SetFillColor('#ffffdd');
     $gb->SetWidth(6);
     $gb->SetLegend('Volume');
     $graph->xaxis->SetTickLabels($days);
     $graph->SetY2Scale('lin');
     $graph->y2scale->SetAutoMin(min($datav) - 0.01);
     $graph->y2scale->SetAutoMax(max($datav) + 1);
     $graph->y2axis->HideTicks(true);
     $graph->Add($p1);
     $graph->AddY2($gb);
     $graph->SetMargin(50, 50, 50, 30);
     $graph->legend->SetFrameWeight(0);
     $graph->legend->SetShadow(false);
     $graph->legend->SetFillColor('#aaaaaa@0.7');
     $graph->legend->SetLineSpacing(8);
     $graph->legend->SetMarkAbsSize(8);
     $graph->legend->SetVColMargin(10);
     $graph->legend->SetHColMargin(15);
     $graph->legend->SetLeftMargin(15);
     $graph->legend->SetPos(0.08, 0.09);
     $image = $graph->Stroke(_IMG_HANDLER);
     $fileName = LITHIUM_APP_PATH . '/webroot/documents/' . $first_curr . "_" . $second_curr . ".png";
     $graph->img->Stream($fileName);
 }