public static function handleQuota($data, $from = 0) { $renew = array_slice($data, 0, $from); for ($i = $from; $i < sizeof($data); $i++) { $adata = $data[$i]; //需要处理的指标数据 $adata['ma60'] = DayKeeper::handleMA($data, $i, 60); $renew[] = $adata; } return $renew; }
public static function resetSingleDay($item, $type) { $end = strtotime("now -7 day") * 1000; $url = 'https://xueqiu.com/stock/forchartk/stocklist.json?symbol=' . $item['code'] . '&period=1day&type=' . $type . '&end=' . $end; self::$log->debugLog($item['name'], $item['code'], $type, $url); $json = DayKeeper::curlXueqiuJson($url, self::$tmp->getTmpFile('day.duty.cookie')); while (!($json = DayKeeper::parseXueqiuJson($json))) { $json = DayKeeper::curlXueqiuJson($url, self::$tmp->getTmpFile('day.duty.cookie')); sleep(1); } self::$log->debugLog($item['name'], $item['code'], $type, "Curl and Parse success"); //var_dump($json); //echo "<br/><br/><br/>"; //var_dump(end($json)); $json = DayKeeper::handleQuota($json); $dd = new DayData($item['code'], $type); if (DayKeeper::putDay($dd->getDataFile(), $json)) { self::$log->noticeLog($item['name'], $item['code'], $type, "Reset OK"); } else { self::$log->errorLog($item['name'], $item['code'], $type, "Reset Failed"); self::$tmp->putTmpContent('day.duty.failed', join(":", $item) . "|", FILE_APPEND); } }