Ejemplo n.º 1
0
def strategy():
    #选出增持行为大于3次的用户
    directorDic = {}
    executeSql = 'select directorName, num from (select directorName, count(*) as num from director_stock_change where afterAction10Day != "0.00" and changeReason in ("竞价交易", "大宗交易", "二级市场买卖") group by directorName )tt where num >3 limit 100;'
    ret = getDB(executeSql, dbase='stock')
    if ret:
        for item in ret:
            directorName = item[0]
            aggregationDic = {}
            executeSql = 'select id, changeTime from director_stock_change where directorName = "%s" order by changeTime' % directorName
            ret1 = getDB(executeSql, dbase='stock')
            for item1 in ret1:
                aggregationDic[item1[0]] = str(item1[1])
            checkTimeInterval(aggregationDic)
Ejemplo n.º 2
0
def strategy():
    #选出增持行为大于3次的用户
    directorDic = {}
    #executeSql = 'select directorName, num from (select directorName, count(*) as num from stock_change_info where afterAction10Day != "0.00" and changeReason in ("竞价交易", "大宗交易", "二级市场买卖") and stockBalance>0 group by directorName )tt where num >3;'
    executeSql = 'select changeStockPerson, num from (select changeStockPerson, count(*) as num from stock_change_info where afterAction10Day != "0.00" and changeReason in ("二级市场买卖", "其他") and stockBalance>0 and dealPrice !=0 and ori="sh" group by changeStockPerson )tt where num >3;'
    ret = getDB(executeSql, dbase='stock')
    if ret:
        for item in ret:
            changeStockPerson = item[0]
            executeSql = 'select afterAction30Day - afterAction30DayIndex + afterAction50Day - afterAction50DayIndex + afterAction70Day - afterAction70DayIndex as num from stock_change_info where changeStockPerson = "%s"'%changeStockPerson
            res = getDB(executeSql, dbase='stock')
            total  = 0
            for term in res:
                total  = total + term[0]
            directorDic[changeStockPerson] = total
            #print changeStockPerson + '\t' + str(total)
    directorDic = sorted(directorDic.iteritems(), key=lambda d:d[1], reverse = True)
    print directorDic
    '''
Ejemplo n.º 3
0
def strategy():
    #选出增持行为大于3次的用户
    directorDic = {}
    #executeSql = 'select directorName, num from (select directorName, count(*) as num from stock_change_info where afterAction10Day != "0.00" and changeReason in ("竞价交易", "大宗交易", "二级市场买卖") and changeStockNum>0 group by directorName )tt where num >3;'
    executeSql = 'select changeStockPerson, num from (select changeStockPerson, count(*) as num from stock_change_info where afterAction10Day != "0.00" and changeReason in ("二级市场买卖") and stockBalance>0 and dealPrice !=0 and ori="sh" group by changeStockPerson )tt where num >3;'
    ret = getDB(executeSql, dbase='stock')
    if ret:
        for item in ret:
            changeStockPerson = item[0]
            executeSql = 'select afterAction30Day - afterAction30DayIndex + afterAction50Day - afterAction50DayIndex + afterAction70Day - afterAction70DayIndex as num from stock_change_info where changeStockPerson = "%s"' % changeStockPerson
            res = getDB(executeSql, dbase='stock')
            total = 0
            for term in res:
                total = total + term[0]
            directorDic[changeStockPerson] = total
    directorDic = sorted(directorDic.iteritems(),
                         key=lambda d: d[1],
                         reverse=True)
    for item2 in directorDic:
        executeSql = 'select stockCode, stockName, changeStockPerson, changeTime, changeStockNum, dealPrice, dealTimeIndex, changeReason, changePercent, stockBalance, changeStockPerson, companyPosition, relation, afterAction10Day, afterAction30Day, afterAction50Day, afterAction70Day, afterAction90Day, afterAction10DayIndex, afterAction30DayIndex, afterAction50DayIndex, afterAction70DayIndex, afterAction90DayIndex from stock_change_info where changeStockPerson = "%s"' % item2[
            0]
        ret2 = getDB(executeSql, dbase='stock')
        if ret2:
            f = open('./localfile', 'a')
            for item in ret2:
                values = []
                for value in item:
                    if isinstance(value, basestring) or isinstance(value, str):
                        values.append("'%s'" % value)
                    elif isinstance(value, int):
                        values.append("%d" % value)
                    elif isinstance(value, float):
                        values.append("%f" % value)
                    else:
                        values.append("%s" % value)
                line = "\t".join(values)
                print line
                f.write(line + '\t' + str(item2[1]) + '\n')
            f.close()
Ejemplo n.º 4
0
def getNeedPrice():
    executeSql = "select id, changeTime,stockCode,dealPrice,dealTimeIndex from director_stock_change";
    ret = getDB(executeSql, dbase='stock')
    if ret:
        for item in ret:
            id = item[0]
            changeDate = item[1]
            stockCode =  item[2]
            price =  item[3]
            stockIndex =  item[4]
            if stockCode and stockIndex and price:
                for i in [10, 30, 50, 70, 90]:
                    dealGetPrice(id, changeDate, stockCode, price, stockIndex, i)