Beispiel #1
0
 public static function show()
 {
     parent::show();
     $taskP = TASK_PATH . $_GET['task'] . '/data/';
     $tableF = $taskP . $_GET['table'];
     $infoF = $taskP . $_GET['info'];
     $detail = array(ucfirst($_GET['task']), ucfirst($_GET['table']));
     //echo $tableF;
     $table = Task::ReadTable($tableF);
     //var_dump($table);
     $header = array();
     $footer = array();
     $i = 0;
     foreach ($table[0] as $k => $v) {
         $header[] = $k;
         $footer[] = '$' . chr(65 + $i++);
     }
     //echo $infoF;
     $info = BaseFile::getFileContent($infoF);
     $info = $info ? explode("\r\n", $info) : array();
     self::setTitle($detail[1] . ' - ' . $detail[0]);
     self::$smarty->assign('historyUrl', Url::getBasePhp('History'));
     self::$smarty->assign('favoriteUrl', Url::getBasePhp('Favorite'));
     self::$smarty->assign('detail', $detail);
     self::$smarty->assign('info', $info);
     self::$smarty->assign('header', $header);
     self::$smarty->assign('footer', $footer);
     self::$smarty->assign('table', $table);
     self::$smarty->display('Sheet.tpl');
 }
Beispiel #2
0
 public static function show()
 {
     parent::show();
     self::setTitle('History');
     self::$smarty->assign('historyUrl', Url::getBasePhp('History'));
     self::$smarty->assign('favoriteUrl', Url::getBasePhp('Favorite'));
     self::$smarty->display('History.tpl');
 }
Beispiel #3
0
 public static function show()
 {
     parent::show();
     $button = array(array('Search'), array('Pick'), array('Dig'), array('Prove'), array('Evaluate'));
     for ($i = 0; $i < sizeof($button); $i++) {
         $button[$i][] = Url::getBasePhp($button[$i][0]);
     }
     self::setTitle('ForeShadow (Alpha)');
     self::$smarty->assign('button', $button);
     self::$smarty->display('Index.tpl');
 }
Beispiel #4
0
 public static function show()
 {
     parent::show();
     $allRefer = Refer::getAll();
     for ($i = 0; $i < sizeof($allRefer); $i++) {
         $allRefer[$i]['url'] = Url::getBasePhp('Stock') . '?code=' . $allRefer[$i]["code"];
     }
     self::setTitle('Stock List -- ForeShadow (Alpha)');
     self::$smarty->assign('refer', $allRefer);
     self::$smarty->display('Search.tpl');
 }
 public static function calcRange($start, $end, $n)
 {
     $resultFile = self::$thisTaskDataPath . $start . '_' . $end . '_' . $n . '_Good.Table.txt';
     $limiter = 2;
     $stockList = Refer::getStock();
     $stockData = array();
     foreach ($stockList as $stkL) {
         //if (--$limiter < 0 ) break;
         $stkT = array('name' => '', 'code' => '', 'MaxRange' => 0, 'DayNum' => 0);
         $stkT['name'] = '<a target="_blank" href="' . Url::getBasePhp('Chart') . '?code=' . $stkL['code'] . '">' . '<span class="fore-stock-name">' . $stkL['name'] . '</span>' . '<span class="fore-stock-spell displaynone">' . $stkL['spell'] . '</span></a>';
         $stkT['code'] = '<span class="fore-stock-code">' . $stkL['code'] . '</span>';
         $dd = new DayData($stkL['code'], 'before');
         if (!$dd->prepareData()) {
             continue;
         }
         $day = $dd->getDayPeriod($start, $end, $n - 1);
         //var_dump($day);
         if (!$day) {
             continue;
         }
         $MaxRange = -2;
         for ($i = 0; $i < $n / 2; $i++) {
             $daySlice = array_slice($day, $i, $n);
             if (!$daySlice) {
                 continue;
             }
             $dMax = LogicOperation::highValue($daySlice, 'close');
             $dMin = $daySlice[0]['close'];
             $dR = ceil(($dMax - $dMin) / $dMin * 100) / 100;
             $MaxRange = $MaxRange < $dR ? $dR : $MaxRange;
         }
         $stkT['MaxRange'] = $MaxRange;
         $stkT['DayNum'] = sizeof($day);
         $tdd = new ThsDoctorData($stkL['code']);
         $t = $tdd->prepareData() ? $tdd->getDayPeriod($start, $end) : array();
         //message_score
         $stkT['message_score_max'] = LogicOperation::highValue($t, 'message_score');
         $stkT['message_score_min'] = LogicOperation::lowValue($t, 'message_score');
         $stkT['message_score_dis'] = $stkT['message_score_max'] - $stkT['message_score_min'];
         //basic_score
         $stkT['basic_score_max'] = LogicOperation::highValue($t, 'basic_score');
         $stkT['basic_score_min'] = LogicOperation::lowValue($t, 'basic_score');
         //total_score
         $stkT['total_score_max'] = LogicOperation::highValue($t, 'total_score');
         $stkT['total_score_min'] = LogicOperation::lowValue($t, 'total_score');
         //var_dump($stkT);
         $stockData[] = $stkT;
     }
     parent::putTable($resultFile, $stockData);
 }
Beispiel #6
0
 public static function show()
 {
     parent::show();
     $stockInfo = array();
     $stockInfo["code"] = $_GET["code"];
     $i = Refer::searchCode($stockInfo["code"]);
     if (!$i) {
         exit(0);
     }
     $stockInfo["name"] = $i['name'];
     $stockInfo["spell"] = $i['spell'];
     $stockInfo["period"] = null;
     /*
      *
     $stockInfo["period"] = array('start'=>strtotime("Thu May 28 00:00:00 +0800 2015")*1000,
         'end'=>strtotime("Mon Dec 23 00:00:00 +0800 2015")*1000);
     */
     $stockInfo["right"] = "before";
     $gd = new GbbqData($stockInfo["code"]);
     $gbbq = $gd->getGbbqLabel();
     $stockInfo['gbbq'] = $gbbq;
     $dd = new DdeData($stockInfo["code"]);
     $dde = $dd->getDdeData();
     $stockInfo['dde'] = $dde;
     $tdd = new ThsDoctorData($stockInfo["code"]);
     $ths = $tdd->getThsDoctorData();
     $stockInfo['ths'] = $ths;
     $ld = new LhbData($stockInfo["code"]);
     $lhb = $ld->getLhbData();
     $stockInfo['lhb'] = $lhb;
     $rd = new RateData($stockInfo["code"]);
     $rate = RateData::filterBuy($rd->getRateData());
     $stockInfo['rate'] = $rate;
     $stockInfo['day'] = array();
     $typeRight = array("normal", "before", "after");
     foreach ($typeRight as $aTypeRight) {
         $dd = new DayData($stockInfo["code"], $aTypeRight);
         if ($dd->prepareData()) {
             $stockInfo['day'][$aTypeRight] = $dd->getStockData();
         } else {
             $stockInfo['day'][$aTypeRight] = null;
         }
     }
     self::setTitle($stockInfo['name'] . '(' . $stockInfo['code'] . ') - Stock -- ForeShadow (Alpha)');
     self::$smarty->assign('historyUrl', Url::getBasePhp('History'));
     self::$smarty->assign('favoriteUrl', Url::getBasePhp('Favorite'));
     self::$smarty->assign('rawData', json_encode($stockInfo));
     self::$smarty->display('Chart.tpl');
 }
 public static function addInfo()
 {
     $importFile = self::$thisTaskDataPath . '20151200-21Good.List.txt';
     $exportFile = self::$thisTaskDataPath . '20151200-21Good.Table.txt';
     $stockList = parent::ReadList($importFile);
     $stockList = CommonInfo::CodeArray2ReferArray($stockList);
     $stockTable = array();
     $pre = '2015-11-00';
     $start = '2015-12-00';
     $end = '2015-12-21';
     foreach ($stockList as $stkL) {
         $stkT = array();
         $stkT['name'] = '<a target="_blank" href="' . Url::getBasePhp('Stock') . '?code=' . $stkL['code'] . '">' . '<span class="fore-stock-name">' . $stkL['name'] . '</span>' . '<span class="fore-stock-spell displaynone">' . $stkL['spell'] . '</span></a>';
         $stkT['code'] = '<span class="fore-stock-code">' . $stkL['code'] . '</span>';
         //以上为标准的  索引
         $tdd = new ThsDoctorData($stkL['code']);
         $t = $tdd->prepareData() ? $tdd->getDayPeriod($start, $end) : array();
         //total_score
         $stkT['total_score_max'] = LogicOperation::highValue($t, 'total_score');
         $stkT['total_score_min'] = LogicOperation::lowValue($t, 'total_score');
         //message_score
         $stkT['message_score_max'] = LogicOperation::highValue($t, 'message_score');
         $stkT['message_score_min'] = LogicOperation::lowValue($t, 'message_score');
         //trade_score
         $stkT['trade_score_max'] = LogicOperation::highValue($t, 'trade_score');
         $stkT['trade_score_min'] = LogicOperation::lowValue($t, 'trade_score');
         //basic_score
         $stkT['basic_score_max'] = LogicOperation::highValue($t, 'basic_score');
         $stkT['basic_score_min'] = LogicOperation::lowValue($t, 'basic_score');
         //评级买入次数
         $rd = new RateData($stkL['code']);
         $t = $rd->prepareData() ? $rd->getDayPeriod($pre, $end) : array();
         $t = $rd->filterBuy($t);
         $stkT['rate_buy_num'] = $t ? sizeof($t) : 0;
         //龙虎榜次数
         $ld = new LhbData($stkL['code']);
         $t = $ld->prepareData() ? $ld->getDayPeriod($start, $end) : array();
         $stkT['lhb_num'] = $t ? sizeof($t) : 0;
         $stockTable[] = $stkT;
     }
     parent::putTable($exportFile, $stockTable);
 }
 public static function getPurposeList()
 {
     $purpose = array();
     if (($d1 = opendir(TASK_PATH)) == false) {
         return $purpose;
     }
     while (($d2 = readdir($d1)) !== false) {
         if (!is_dir(TASK_PATH . $d2) || $d2 == "." || $d2 == "..") {
             continue;
         }
         $p = TASK_PATH . $d2 . "/";
         $f = $p . "SUMMARY.txt";
         if (!file_exists($f)) {
             continue;
         }
         $sd = TableFile::getAllData($f);
         if (!$sd) {
             continue;
         }
         $l = array();
         foreach ($sd as $d) {
             if ($d['aim'] != self::$aim) {
                 continue;
             }
             $f = $p . 'data/' . $d['table'];
             if (file_exists($f)) {
                 $l[] = array('table' => $d['table'], 'info' => $d['info'], 'url' => Url::getBasePhp('Sheet') . '?task=' . $d2 . '&table=' . $d['table'] . '&info=' . $d['info']);
             }
         }
         if ($l) {
             $f = $p . "README.txt";
             $re = array();
             if (file_exists($f)) {
                 $re = BaseFile::getFileContent($f);
                 $re = explode("\r\n", $re);
             }
             $purpose[ucfirst($d2)] = array('readme' => $re, 'list' => $l);
         }
     }
     return $purpose;
 }
 public static function calcMessJump()
 {
     $resultFile = self::$thisTaskDataPath . 'Pick_MessJump.Table.txt';
     $limiter = 10;
     $stockList = Refer::getStock();
     $stockData = array();
     foreach ($stockList as $stkL) {
         //if (--$limiter < 0 ) break;
         $stkT = array();
         $tdd = new ThsDoctorData($stkL['code']);
         if (!$tdd->prepareData()) {
             continue;
         }
         $ths_2 = $tdd->getLastPeriod(1, true, 2);
         if (!$ths_2) {
             continue;
         }
         //var_dump($ths_2);
         $ths_x = $tdd->getLastPeriod(40, true, 10);
         if (!$ths_x) {
             continue;
         }
         //var_dump($ths_x);
         if ($ths_2[1]['message_score'] - $ths_2[0]['message_score'] <= 0) {
             continue;
         }
         $stkT['name'] = '<a target="_blank" href="' . Url::getBasePhp('Chart') . '?code=' . $stkL['code'] . '">' . '<span class="fore-stock-name">' . $stkL['name'] . '</span>' . '<span class="fore-stock-spell displaynone">' . $stkL['spell'] . '</span></a>';
         $stkT['code'] = '<span class="fore-stock-code">' . $stkL['code'] . '</span>';
         //message_score in yesterday and today
         $stkT['mess_score_yesterday'] = $ths_2[0]['message_score'];
         $stkT['mess_score_today'] = $ths_2[1]['message_score'];
         $stkT['mess_score_change'] = $ths_2[1]['message_score'] - $ths_2[0]['message_score'];
         //message_score in 40 days
         $stkT['mess_score_max_40d'] = LogicOperation::highValue($ths_x, 'message_score');
         $stkT['mess_score_min_40d'] = LogicOperation::lowValue($ths_x, 'message_score');
         $stockData[] = $stkT;
     }
     parent::putTable($resultFile, $stockData);
 }
 public static function calcV2P($start, $end)
 {
     $resultFile = self::$thisTaskDataPath . $start . '_' . $end . '_Vol2Price.Table.txt';
     $limiter = 200;
     $stockList = Refer::getStock();
     $stockData = array();
     foreach ($stockList as $stkL) {
         //if (--$limiter < 0 ) break;
         $stkT = array();
         $stkT['name'] = '<a target="_blank" href="' . Url::getBasePhp('Chart') . '?code=' . $stkL['code'] . '">' . '<span class="fore-stock-name">' . $stkL['name'] . '</span>' . '<span class="fore-stock-spell displaynone">' . $stkL['spell'] . '</span></a>';
         $stkT['code'] = '<span class="fore-stock-code">' . $stkL['code'] . '</span>';
         $dd = new DayData($stkL['code'], 'before');
         if (!$dd->prepareData()) {
             continue;
         }
         $day = $dd->getDayPeriod($start, $end, 3);
         if (!$day) {
             continue;
         }
         //var_dump($day);
         $s_day = 0;
         $s_V2P = 0;
         for ($i = 2; $i < count($day); $i++) {
             //处理当日涨跌停
             $is_zt = ($day[$i]["high"] - $day[$i - 1]["close"]) / $day[$i - 1]["close"];
             $is_dt = ($day[$i - 1]["close"] - $day[$i]["low"]) / $day[$i - 1]["close"];
             $valid_vol = $day[$i]["volume"] / $day[$i - 1]["volume"];
             //涨跌停 并且 量小于0.3 不参与计算
             if (($is_zt > 1.09 || $is_dt < 0.9) && $valid_vol < 0.3) {
                 continue;
             }
             //处理前日涨跌停
             $is_zt = ($day[$i - 1]["high"] - $day[$i - 2]["close"]) / $day[$i - 2]["close"];
             $is_dt = ($day[$i - 2]["close"] - $day[$i - 1]["low"]) / $day[$i - 2]["close"];
             $valid_vol = $day[$i - 1]["volume"] / $day[$i - 2]["volume"];
             //涨跌停 并且 量小于0.3 不参与计算
             if (($is_zt > 1.09 || $is_dt < 0.9) && $valid_vol < 0.3) {
                 continue;
             }
             //处理量太小不值得计算
             $k1 = ($day[$i]["volume"] - $day[$i - 1]["volume"]) / $day[$i - 1]["volume"] * 100;
             $k2 = ($day[$i]["volume"] - $day[$i - 2]["volume"]) / $day[$i - 2]["volume"] * 100;
             if (abs($k1) < 20 && abs($k2) < 20) {
                 continue;
             }
             //计算V2P公式
             //计算量相关
             $q2 = ($day[$i]["volume"] - $day[$i - 1]["volume"]) / $day[$i - 1]["volume"] * 100;
             if ($q2 < -100) {
                 $q2 = -100;
             }
             if ($q2 > 100) {
                 $q2 = 100;
             }
             //计算价格相关
             $chg = $day[$i]["chg"] * 100;
             $q1 = $chg;
             if ($chg > 60) {
                 $q1 = 16;
             }
             if ($chg <= 60 && $chg > 30) {
                 $q1 = ($chg - 30) / 15 + 13;
             }
             if ($chg <= 30 && $chg > 10) {
                 $q1 = ($chg - 10) / 7 + 10;
             }
             if ($chg < -60) {
                 $q1 = -16;
             }
             if ($chg >= -60 && $chg < -30) {
                 $q1 = ($chg + 30) / 15 - 13;
             }
             if ($chg >= -30 && $chg < -10) {
                 $q1 = ($chg + 10) / 7 - 10;
             }
             $q1 = $q1 > 0 ? ceil($q1 + 100) : ceil($q1 - 100);
             $V2P = $q1 * $q2;
             if ($chg <= 10 && $chg >= -10) {
                 $V2P = abs(110 * $q2);
             }
             // 统计
             $s_day++;
             $s_V2P += $V2P;
         }
         $stkT['Vol2Price'] = $s_day ? ceil($s_V2P / $s_day) : 0;
         $stkT['ValidDayNum'] = $s_day;
         $stkT['TotalDayNum'] = count($day);
         $stockData[] = $stkT;
     }
     parent::putTable($resultFile, $stockData);
 }