Ejemplo n.º 1
0
 public function __construct()
 {
     //Инициализируем переменные
     $this->fee = 0.2 / 100;
     // Комиссия за операцию
     $this->imp_div = 1 / 100;
     // Процент при котором считать подъем/падение = 1%
     //$this->buy_sum = 350; // Покупать на 300 руб.
     $this->buy_value = 0.01;
     // Сколько покупать
     $this->buystep_n = 5;
     // Смотрим по ... блоков
     $this->sellstep_n = 4;
     // Смотрим по ... блоков
     $this->analize_period = 60 * 60 * 1;
     // Период за который анализируем график (6 часов)
     $this->min_income = 10;
     // Мин. доход
     $this->balance = Status::getParam('balance');
     $this->balance_btc = Status::getParam('balance_btc');
     $this->order_cnt = 0;
     $this->bought = Buy::model()->with('sell')->findAll();
     $this->total_income = Sell::getTotalIncome();
 }
Ejemplo n.º 2
0
 public function actionChart($type = 'btc_rur')
 {
     $buy = new Buy();
     $exch = Exchange::getAllByDt('btc_rur', '2013-12-16', '2014-01-06');
     $data_buy = array();
     $data_sell = array();
     foreach ($exch as $item) {
         $tm = strtotime($item['dt']) * 1000 + 4 * 60 * 60 * 1000;
         $data_buy[] = array($tm, (double) $item['buy']);
         $data_sell[] = array($tm, (double) $item['sell']);
     }
     // Покупки
     $orders = Order::model()->findAll();
     $lastEx = Exchange::getLast();
     $status['total_income'] = Sell::getTotalIncome();
     $status['balance'] = Status::getParam('balance');
     $status['balance_btc'] = Status::getParam('balance_btc');
     $status['total_balance'] = $status['balance'] + $status['balance_btc'] * $lastEx->sell;
     $this->render('chart', array('data_buy' => json_encode($data_buy), 'data_sell' => json_encode($data_sell), 'orders' => $orders, 'status' => $status));
 }