public static function updateDoctor() { self::$log->debugLog("Begin Update Ths Doctor"); //$i = 2; $list = Refer::getStock(); foreach ($list as $item) { //if (--$i < 0 ) break; if ('sz300033' == $item['code']) { continue; } $numCode = substr($item['code'], 2); $url = "http://doctor.10jqka.com.cn/" . $numCode . '/'; self::$log->debugLog($item['name'], $item['code'], $url); $html = ThsDoctorKeeper::fetchSingleThsDoctor($url, $numCode); if ($html) { self::$log->debugLog($item['name'], $item['code'], "Fetch ThsDoctor Success"); $now = ThsDoctorKeeper::parseThsDoctorHtml($html); if ($now) { $tdd = new ThsDoctorData($item['code']); $last = $tdd->getThsDoctorData(); //print_r($last); if ($last) { $updata = ThsDoctorKeeper::mergeThsDoctorUpdate($last, $now); ThsDoctorKeeper::addThsDoctor($tdd->getDataFile(), $updata); } else { $updata = $now; ThsDoctorKeeper::putThsDoctor($tdd->getDataFile(), $updata); } self::$log->noticeLog($item['name'], $item['code'], "Update ThsDoctor Success"); } else { self::$log->errorLog($item['name'], $item['code'], "Parse ThsDoctor Failed"); self::$tmp->putTmpContent('thsdoctor.duty.failed', join(":", $item) . "|", FILE_APPEND); } $now = ThsDoctorKeeper::parseThsDoctorMesHtml($html); if ($now) { $tdmd = new ThsDoctorMesData($item['code']); $last = $tdmd->getThsDoctorMesData(); //print_r($last); if ($last) { $updata = ThsDoctorKeeper::mergeThsDoctorMesUpdate($last, $now); ThsDoctorKeeper::addThsDoctor($tdmd->getDataFile(), $updata); } else { $updata = $now; ThsDoctorKeeper::putThsDoctor($tdmd->getDataFile(), $updata); } self::$log->noticeLog($item['name'], $item['code'], "Update ThsDoctorMes Success"); } else { self::$log->errorLog($item['name'], $item['code'], "Parse ThsDoctorMes Failed"); } } else { self::$log->errorLog($item['name'], $item['code'], "Fetch ThsDoctor Failed"); self::$tmp->putTmpContent('thsdoctor.duty.failed', join(":", $item) . "|", FILE_APPEND); } } self::$log->debugLog("Finish Update Ths Doctor"); }
public static function testThsDoctorData() { $td = new ThsDoctorData('sz300313'); $rows = $td->getThsDoctorData(); $columns = array_keys($rows[0]); for ($i = 0; $i < sizeof($columns); $i++) { $t = str_replace('_', ' ', $columns[$i]); $columns[$i] = array('title' => $t, 'data' => $columns[$i]); } echo json_encode(array('columns' => $columns, 'rows' => $rows)); }
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); }
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 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); }