Exemple #1
0
def haveBeenGreaterThanbyOneDayCodelist(dateDay, percentage):
    import santai3.tools.connectMySQL as CL
    cursor, db = CL.getStockDataBaseCursorAndDB()
    #start_date = None
    start = time.time()
    listResult = []
    codelist = getStockList()

    try:
        start = time.time()
        for row in codelist.itertuples(index=True, name='Pandas'):
            code = getattr(row, "Index")
            sqlSentence = "SELECT * FROM stockdatabase.stock_%s where 日期 =  \'%s\' and 最高价 > %s * 前收盘 " % (
                code, dateDay, percentage)
            print(sqlSentence)

            cursor.execute(sqlSentence)
            results = cursor.fetchone()
            print(results)
            if results is not None:
                #return True
                #print(True)
                listResult.append(code)

        stop = time.time()
        print('delay: %.3fs' % (stop - start))
    except Exception as msg:
        #print(str(msg))
        logger.error(msg)
    finally:
        # 关闭游标,提交,关闭数据库连接
        cursor.close()
        db.commit()
        db.close()
    return listResult
Exemple #2
0
def haveBeenGreaterThanbyOneDay(code, dateDay, percentage):
    import santai3.tools.connectMySQL as CL
    cursor, db = CL.getStockDataBaseCursorAndDB()
    #start_date = None
    try:
        sqlSentence = "SELECT * FROM stockdatabase.stock_%s where 日期 =  \'%s\' and 最高价 > %s * 前收盘 " % (
            code, '2017-09-04', percentage)
        print(sqlSentence)

        cursor.execute(sqlSentence)

        results = cursor.fetchone()
        print(results)
        if results is not None:
            return True

    except Exception as msg:
        #print(str(msg))
        logger.error(msg)
    finally:
        # 关闭游标,提交,关闭数据库连接
        cursor.close()
        db.commit()
        db.close()
    return False
Exemple #3
0
def haveBeenGreaterThanbyOneDayRemoveOpenLimitUp_Codelist(
        dateDay, percentage):  #涨停股票,去除一字涨停
    import santai3.tools.connectMySQL as CL
    cursor, db = CL.getStockDataBaseCursorAndDB()
    # start_date = None
    start = time.time()
    listResult = []
    codelist = getStockList()

    try:
        start = time.time()
        for row in codelist.itertuples(index=True, name='Pandas'):
            code = getattr(row, "Index")
            sqlSentence = "SELECT * FROM stockdatabase.stock_%s where 日期 =  \'%s\' and 最高价 > %s * 前收盘  and round(开盘价,2)  != round(round(前收盘 * 110)/100,2)" % (
                code, dateDay, percentage)  #这里要注意开盘价是float,比较越来有误差,因此要加round
            print(sqlSentence)

            try:
                cursor.execute(sqlSentence)
                results = cursor.fetchone()
            except Exception as e:
                import traceback
                print('traceback.print_exc():', traceback.print_exc())
                logger.info(e)

            print(results)
            if results is not None:
                # return True
                # print(True)
                listResult.append(code)

        stop = time.time()
        print('delay: %.3fs' % (stop - start))
    except Exception as msg:
        # print(str(msg))
        logger.error(msg)
    finally:
        # 关闭游标,提交,关闭数据库连接
        cursor.close()
        db.commit()
        db.close()
    return listResult