Esempio n. 1
0
def get_month_maxdate(stockno):
    try:
        sql = "select max(date) maxdate from stock_month_data where code='"+stockno+"'"
        conn = MySQLdb.connect(host='localhost',user='******',passwd='123456',db='stock')
        cursor = conn.cursor()
        n = cursor.execute(sql)
        maxdate = ''
        for r in cursor:
             maxdate = r[0]
        cursor.close()
        conn.close
        if maxdate=='':
            stockDf =ts.get_stock_basics()
            sssj = str(stockDf.ix[stockno]['timeToMarket']) #上市日期YYYYMMDD
            return  dateutil.convertDate(sssj)
        return dateutil.get_next_day(maxdate)
    except Exception,e:
        print e.message
Esempio n. 2
0
def get_qfq_maxdate(stockno):
    try:
        sql = "select max(date) maxdate from stock_qfq_data where code='"+stockno+"'"
        engine = create_engine('mysql://*****:*****@127.0.0.1/stock?charset=utf8')
        #df.to_sql('inst_detail', engine, if_exists='append')

        conn = MySQLdb.connect(host='localhost',user='******',passwd='123456',db='stock')
        cursor = conn.cursor()
        n = cursor.execute(sql)
        maxdate = ''
        for r in cursor:
             maxdate = r[0][0:10]
        cursor.close()
        conn.close
        if maxdate=='':
            stockDf =ts.get_stock_basics()
            sssj = str(stockDf.ix[stockno]['timeToMarket']) #上市日期YYYYMMDD
            return  dateutil.convertDate(sssj)
        return dateutil.get_next_day(maxdate)
    except Exception,e:
        print e.message