def do_somthing(q_out,q,i,trueStartDate,trueEndDate,preStartDate,allExistTables,stock_gainian):
#Init conn
conn = MySQLdb.connect(host='localhost',db='tushare',user='root',passwd='',port=3306,charset='UTF8')
#Init df_Cc
df_Cc = pd.DataFrame()
df_Cc['ticker'] = pd.Series(dtype=numpy.int64,index=df_Cc.index)
df_Cc['secShortName'] = pd.Series(dtype=numpy.object,index=df_Cc.index)
df_Cc['percent'] = pd.Series(dtype=numpy.float64,index=df_Cc.index)
df_Cc['startPrice'] = pd.Series(dtype=numpy.float64,index=df_Cc.index)
df_Cc['endPrice'] = pd.Series(dtype=numpy.float64,index=df_Cc.index)
df_Cc['startDate'] = pd.Series(dtype=numpy.object,index=df_Cc.index)
df_Cc['endDate'] = pd.Series(dtype=numpy.object,index=df_Cc.index)
df_Cc['gainian'] = pd.Series(dtype=numpy.object,index=df_Cc.index)
df_Cc['shizhi'] = pd.Series(dtype=numpy.float64,index=df_Cc.index)
df_Cc['liutong'] = pd.Series(dtype=numpy.float64,index=df_Cc.index)
while True:
aa = q.get()
if aa != None:
ticker = aa[0]
secShortName = aa[1]
totalShares = aa[2]
nonrestfloatA = aa[3]
listDate = datetime.datetime.strptime(aa[4], "%Y-%m-%d")
stock_mktequd_name = '%s%06d' % (init.g_mktequd,ticker)
if (stock_mktequd_name in allExistTables) & (trueEndDate>=listDate>=trueStartDate)==False:
str = 'select * from %s where tradeDate>=\'%s\' and tradeDate<=\'%s\' order by tradeDate' % (stock_mktequd_name,trueStartDate.strftime("%Y-%m-%d"),trueEndDate.strftime("%Y-%m-%d"))
df = pd.read_sql(str,conn)
l = len(df_Cc)
df_Cc.at[l,'ticker'] = ticker
df_Cc.at[l,'secShortName'] = secShortName
nn = df.shape[0]
if nn>0:
#
startPrice = df.iloc[0]['preClosePrice']*GetQfq(ticker,preStartDate,conn) # if nn>=n else df.iloc[0]['preClosePrice']*1
endPrice = df.iloc[nn-1]['closePrice']*df.iloc[nn-1]['accumAdjFactor']
percent = (endPrice-startPrice)/startPrice*100 # if startPrice!=0 else -100
df_Cc.at[l,'startDate'] = df.iloc[0]['tradeDate']
df_Cc.at[l,'endDate'] = df.iloc[nn-1]['tradeDate']
df_Cc.at[l,'percent'] = percent
df_Cc.at[l,'startPrice'] = startPrice
df_Cc.at[l,'endPrice'] = endPrice
df_gn = stock_gainian.query('ticker==%s' % ticker)
if df_gn.shape[0]==1:
df_Cc.at[l,'gainian'] = df_gn.iloc[0]['ref_gainian']
df_Cc.at[l,'shizhi'] = totalShares*startPrice/100000000
df_Cc.at[l,'liutong'] = nonrestfloatA*startPrice/100000000
else:
break
q_out.put(df_Cc)
conn.close()
print 'end-in %s %s' % (i,datetime.datetime.now())
私は私のpythonを知っていると思います(与えられた唯一のタグ)が、私はこの質問が何を話しているのか分かりませんし、システムに精通している人には意味があるかどうかも分かりません。これはPythonの上にいくつかのフレームワークですか? –