예제 #1
0
def run(conf={}):
    date = Date.getInstantDate() #instant date 应该Date.getDate +1,key的编码问题
    conf['date']=date

    logging.info("start downloading instant data.Date is %s" % conf['date'])
    downloader = Downloader(conf = conf)
    downloader.download("instant")

    logging.info("start computing instant data.Date is %s"% conf['date'])
    stock=Stock(conf)
    extract = Extract(conf = conf)
    extract.extract(project = "instant", stock = stock, date = date)

    logging.info("start instant strategic data.Date is %s" %conf['date'])
    strategic_conf ={}
    strategic_conf.update(conf)
    strategic_conf['stock']=stock
    strategic = Strategic(conf = strategic_conf)
    strategicResult = strategic.compute()
    Dumper.dump(path = os.path.join(conf.get("SYS_HOME"),conf.get("INSTANT_DATA_PATH"),"strategic.json"),data = strategicResult)

    logging.info("Start Bayes statistics.Date is %s"% conf['date'])
    conf['strategic']=strategic
    bayesHandler = Bayes(conf)
    bayes = bayesHandler.posterior()
    Dumper.dump(path = os.path.join(conf.get("SYS_HOME"),conf.get("INSTANT_DATA_PATH"),"bayes.json"),data = bayes)

    logging.info("Start report.Date is %s"% conf['date'])
    report = Report(conf = conf)
    report.compute(strategic = strategic , statistics = bayes)
    print report

    #profile
    profile_conf =  {"stock":stock,"date":date}
    profile_conf.update(conf)
    profile = Profile(profile_conf)
    profile.viewProfile()

    path = os.path.join(conf.get("SYS_HOME"),conf.get("INSTANT_REPORT_DATA_PATH"))
    Dumper.dump(path = path,data = report.data)
    return report.data
예제 #2
0
def run(conf={}):
    """
    @param {Dict} conf
    @param conf.date 抓取日期
    @param {'min'|'detail'|'info'} [conf.download] 数据更新内容.day为日线数据,detail为详细数据,info为股票代码,对应的公司名等数据
    @param {'detail'|'all'|'day'} [conf.mode] 当数据抓取模式为'day'时,'day'数据抓取模式。detail为从detail数据中抓取数据。all为抓取所有数据。day为更新每日数据
    @param {'single'|'mutil'} [conf.thread] 当数据抓取模式为'detail'时,采取的线程模式。single为单线程,mutil为多线程
    """
    logging.info("Start spider.")
    downloader=Downloader(conf)
    check = Check(conf)
    date = conf.get("date",Date.getDate())
    checkIndex = 0
    while checkIndex < conf.get("MIN_DATA_NUM",MIN_DATA_NUM):
        checkDate=Date.getDate(0-checkIndex,date)
        checkReport = check.check(checkDate)
        if not checkReport:
            logging.info("Download %s 's data." % checkDate)
            downloader.download(name="detail",conf={"date":checkDate})
        checkIndex += 1
    logging.info("Download finish.")
    return True