/**
  * Загружает ряды в класс по идентификатору котировки
  *
  * @param int   $stockId   идентификатор котировки
  * @param int   $type      тип сравнения (1 - красный, 2 - синий)
  * @param array $dateRange периуд для расчета
  *                         ```php
  *                         [
  *                         'min' => 'yyyy-mm-dd'
  *                         'max' => 'yyyy-mm-dd'
  *                         ]
  *                         ```
  *
  * @return static
  * @throws \cs\web\Exception
  */
 public static function initStock($stockId, $type, $dateRange = null)
 {
     $where = null;
     if ($dateRange) {
         $where = ['between', 'date', $dateRange['min'], $dateRange['max']];
     }
     $kurs = StockKurs::query(['stock_id' => $stockId])->select(['`date`, `kurs` as `value`'])->orderBy(['date' => SORT_ASC]);
     if ($where) {
         $kurs->where($where);
     }
     $kurs = $kurs->all();
     $class = null;
     switch ($type) {
         case 1:
             $rows = StockPrognosisRed::query(['stock_id' => $stockId])->select(['`date`, `delta` as `value`'])->orderBy(['date' => SORT_ASC]);
             if ($where) {
                 $rows->where($where);
             }
             $class = \app\service\CalculatingProbability::initRows($kurs, $rows->all());
             break;
         case 2:
             $rows = StockPrognosisBlue::query(['stock_id' => $stockId])->select(['`date`, `delta` as `value`'])->orderBy(['date' => SORT_ASC]);
             if ($where) {
                 $rows->where($where);
             }
             $class = \app\service\CalculatingProbability::initRows($kurs, $rows->all());
             break;
         default:
             throw new \cs\web\Exception('Не верный тип $dateRange');
     }
     return $class;
 }
 public function actionCalc()
 {
     $blue = CalculatingProbability::initStock(1, 2);
     $red = CalculatingProbability::initStock(1, 1);
     VarDumper::dump([$blue->calc(), $red->calc()]);
 }