public function __construct($exchange = false) { if (!$exchange) { $exchange = Exchange::getLast(); } $this->current_exchange = $exchange; $this->curtime = strtotime($exchange->dtm); $this->balance = Status::getParam('balance'); $this->balance_btc = Status::getParam('balance_btc'); $this->total_income = 0; $this->buy_imp_dif = 0.005; // Шаг при анализе покупки 5% //150; $this->sell_imp_dif = 0.007; // Шаг при анализе продажи 7% $this->order_cnt = 0; // Периоды анализа графика для покупки и продажи (в сек.) $this->buy_periods = array(15 * 60, 30 * 60, 60 * 60, 2 * 60 * 60, 6 * 60 * 60, 24 * 60 * 60, 36 * 60 * 60); $this->sell_periods = array(60 * 60, 2 * 60 * 60, 6 * 60 * 60, 24 * 60 * 60, 36 * 60 * 60); $this->api = APIProvider::get_Instance(); self::$self = $this; }
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(); }
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)); }