Example #1
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);
 }
Example #3
0
 public static function updateLhb()
 {
     //日志文件
     self::$log = new Log(LOG_PATH, __FILE__);
     //临时文件
     self::$tmp = new Tmp(TMP_PATH);
     self::$tmp->addTmp('lhb.duty.time', false);
     self::$log->debugLog("Begin Update Lhb");
     echo '<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title></head><body>';
     //得到上次更新时间
     $lastTime = self::$tmp->getTmpContent('lhb.duty.time');
     //校验上次更新时间
     $pattern = "/[0-9]{4}-[0-9]{2}-[0-9]{2}/";
     preg_match($pattern, $lastTime, $k);
     $lastTime = $k[0];
     $thisTime = $lastTime;
     if ($lastTime) {
         //echo $lastTime . '<br />';
         $szzs = Refer::getSH();
         $dd = new DayData($szzs['code']);
         if ($dd->prepareData()) {
             $ks = $dd->getDayPeriod($lastTime, true);
             $list = array();
             foreach ($ks as $k) {
                 $cTime = $k['time'];
                 if ($cTime > $lastTime) {
                     //echo $cTime. '<br />';
                     $url = "http://data.eastmoney.com/stock/lhb/" . $cTime . ".html";
                     self::$log->debugLog('Get Url', $url);
                     $html = LhbKeeper::fetchSinglePage($url);
                     self::$log->debugLog("Fetch Url Page Success");
                     $updata = LhbKeeper::parseLhbHtml($html, $cTime);
                     if ($updata) {
                         $list = array_merge($list, $updata);
                     }
                     $thisTime = $cTime;
                 }
             }
             //var_dump($list);
             if ($list) {
                 foreach ($list as $new) {
                     $ld = new LhbData($new[0]);
                     $data = $ld->getLhbData();
                     if (!$data) {
                         LhbKeeper::addLhb($ld->getDataFile(), array($new[1]));
                         self::$log->noticeLog("Update", $new[0], $new[1]['time'], $new[1]['reason'], "Success");
                         continue;
                     }
                     $t = end($data)['time'];
                     //echo $new[1]['time']. '>'. $t. '<br />';
                     if ($new[1]['time'] > $t) {
                         LhbKeeper::addLhb($ld->getDataFile(), array($new[1]));
                         self::$log->noticeLog("Update", $new[0], $new[1]['time'], $new[1]['reason'], "Success");
                     }
                 }
             } else {
                 self::$log->errorLog("Parse Lhb Failed");
             }
             self::$tmp->newTmpFile('lhb.duty.time');
             self::$tmp->putTmpContent('lhb.duty.time', $thisTime);
             self::$log->debugLog("Finish Update Lhb");
         } else {
             self::$log->errorLog("Get Time List Failed");
         }
     } else {
         self::$log->errorLog("Get LastTime Failed");
     }
 }