예제 #1
0
def checkStockVolumn(begin, end, step, startDate, endDate):
    counter = 0
    result = []
    start = 0
    curTotal = end - begin
    engine = DBUtils.db_connection()
    while begin <= end:
        if (begin <= Utils.MAXSZ):
            szSpecial = Utils.change_sz_code(begin)
            start = szSpecial
        else:
            start = str(begin)
        currentRs = DBUtils.db_read_k_history_inc(start, engine, startDate,
                                                  endDate)
        tmpResult = DataAnalysis.check_by_vols(start, currentRs)
        if tmpResult is not None:
            result.append(tmpResult)
        begin = begin + step
        counter = counter + 1
        if (counter % 100 == 0):
            Utils.print_progess(counter, curTotal)
    print(result)
    result_frame = pandas.DataFrame(result)

    filename = SAVE_FILE_PATH + 'from ' + startDate + 'to ' + endDate
    if os.path.exists(filename):
        result_frame.to_csv(filename, mode='a', header='None')
    else:
        result_frame.to_csv(filename)
    return result
예제 #2
0
def save_data(begin, end, step, start_date, end_date):
    counter = 0
    cur_total = end - begin
    print("start db connection")
    engine = db_connection()
    print("end db connection")
    while begin <= end:
        if begin <= Utils.MAXSZ:
            sz_special = Utils.change_sz_code(begin)
            start = sz_special
        else:
            start = str(begin)
        db_save(engine, start, start_date, end_date, 'k_his_data')
        begin = begin + step
        counter = counter + 1
        if counter % 100 == 0:
            Utils.print_progess(counter, cur_total)