application/controllers/Analysis.php
/**
     * Charts for symbol
     * 
     * @param string $code    Contains code of symbol
     * @param int    $periods Contains amount of periods
     * @param string $period  Contains name of period
     */
Charts for symbol

@param string $code    Contains code of symbol
@param int    $periods Contains amount of periods
@param string $period  Contains name of period
Charts for symbol @param string $code Contains code of symbol @param int $periods Contains amount of periods @param string $period Contains name of period
public function symbol($code, $periods, $period) {
        $symbol = $this->symbol_model->get_symbol_by_code($code);
        if ($symbol) {
            $end = time();
            $begin = strtotime("-$periods $period", $end);
            if ($begin) {
                if ($period == 'hour') { 
                    $values = $this->value_model->get_minute_values($symbol['id'], $begin, $end);
                } elseif ($period == 'day') { 
                    $values = $this->value_model->get_hour_values($symbol['id'], $begin, $end);
                } else { 
                    $values = $this->value_model->get_day_values($symbol['id'], $begin, $end);
                }
                $waves = $this->_getWaves($values);
                $this->_analyzeWaves($waves);
                $data = array('waves' => $waves, 'symbol' => $code, 'periods' => $periods, 'period' => $period);
                $this->load->view('header', array('title' => 'Analysis of ' . $symbol['name'] . ' (Last ' . $periods . ' ' . $period . 's)'));
                $this->load->view('table', $data);
                $this->load->view('footer');
            } else {
                show_404();
            }
        } else {
            show_404();
        }
    }
public function symbol ( $ code , $ periods , $ period ) { $ symbol = $ this -> symbol_model -> get_symbol_by_code ( $ code ) ; if ( $ symbol ) { $ end = time ( ) ; $ begin = strtotime ( " - $ periods $ period " , $ end ) ; if ( $ begin ) { if ( $ period == 'hour' ) { $ values = $ this -> value_model -> get_minute_values ( $ symbol [ 'id' ] , $ begin , $ end ) ; } elseif ( $ period == 'day' ) { $ values = $ this -> value_model -> get_hour_values ( $ symbol [ 'id' ] , $ begin , $ end ) ; } else { $ values = $ this -> value_model -> get_day_values ( $ symbol [ 'id' ] , $ begin , $ end ) ; } $ waves = $ this -> _getWaves ( $ values ) ; $ this -> _analyzeWaves ( $ waves ) ; $ data = array ( 'waves' => $ waves , 'symbol' => $ code , 'periods' => $ periods , 'period' => $ period ) ; $ this -> load -> view ( 'header' , array ( 'title' => 'Analysis of ' . $ symbol [ 'name' ] . ' (Last ' . $ periods . ' ' . $ period . 's)' ) ) ; $ this -> load -> view ( 'table' , $ data ) ; $ this -> load -> view ( 'footer' ) ; } else { show_404 ( ) ; } } else { show_404 ( ) ; } }
Charts for symbol
Charts for symbol
// interval in hours // interval in days // interval in months