fix: 完成部分数据计算

master
laixingyu 3 years ago
parent 52995fddbd
commit 6fdf7b7a70

@ -131,6 +131,18 @@ def getPeriodDiff(dbconfig,dbcursor,startDate,endDate):
def getPreData(dbconfig,dbcursor,date): def getPreData(dbconfig,dbcursor,date):
preDataMap = {} preDataMap = {}
sql_trade_period_qurey = 'select business_date,security_code,turnover,turnover5,turnover10,turnover20,turnover30,turnover_sort,turnover5_sort,turnover10_sort,turnover20_sort,turnover30_sort,turnover_ratio,turnover5_ratio,turnover10_ratio,turnover20_ratio,turnover30_ratio,rise_number,rise5_number,rise10_number,rise20_number,rise30_number,losses_number,losses5_number,losses10_number,losses20_number,losses30_number,flat_number,flat5_number,flat10_number,flat20_number,flat30_number from dong_cai_secondary_industry_statistics where business_date = %s'
dbcursor.execute(sql_trade_period_qurey,date)
datas = dbcursor.fetchall()
for row in datas:
business_date,security_code,turnover,turnover5,turnover10,turnover20,turnover30,turnover_sort,turnover5_sort,turnover10_sort,turnover20_sort,turnover30_sort,turnover_ratio,turnover5_ratio,turnover10_ratio,turnover20_ratio,turnover30_ratio,rise_number,rise5_number,rise10_number,rise20_number,rise30_number,losses_number,losses5_number,losses10_number,losses20_number,losses30_number,flat_number,flat5_number,flat10_number,flat20_number,flat30_number = row
preDataMap[security_code] = {'business_date':business_date,'security_code':security_code,
'turnover':turnover,'turnover5':turnover5,'turnover10':turnover10,'turnover20':turnover20,'turnover30':turnover30,
'turnover_sort':turnover_sort,'turnover5_sort':turnover5_sort,'turnover10_sort':turnover10_sort,'turnover20_sort':turnover20_sort,'turnover30_sort':turnover30_sort,
'turnover_ratio':turnover_ratio,'turnover5_ratio':turnover5_ratio,'turnover10_ratio':turnover10_ratio,'turnover20_ratio':turnover20_ratio,'turnover30_ratio':turnover30_ratio,
'rise_number':rise_number,'rise5_number':rise5_number,'rise10_number':rise10_number,'rise20_number':rise20_number,'rise30_number':rise30_number,
'losses_number':losses_number,'losses5_number':losses5_number,'losses10_number':losses10_number,'losses20_number':losses20_number,'losses30_number':losses30_number,
'flat_number':flat_number,'flat5_number':flat5_number,'flat10_number':flat10_number,'flat20_number':flat20_number,'flat30_number':flat30_number}
return preDataMap return preDataMap
@ -234,8 +246,9 @@ def main():
print('start transfer statistics ',trading_date , ' data.') print('start transfer statistics ',trading_date , ' data.')
# 获取前一日数据 # 获取前一日数据
preIndustryDataMap = getPreData(db_a_conn,db_a_cursor,period_trading_dateMap['1']) prevIndustryDataMap = getPreData(db_a_conn,db_a_cursor,period_trading_dateMap['1'])
hasPrevIndustryData = len(prevIndustryDataMap)
# 获取多日成交额汇总数据 # 获取多日成交额汇总数据
turnOver5 = getPeriodTurnOver(db_a_conn,db_a_cursor,period_trading_dateMap['5'],trading_date) turnOver5 = getPeriodTurnOver(db_a_conn,db_a_cursor,period_trading_dateMap['5'],trading_date)
for data in turnOver5: for data in turnOver5:
@ -279,7 +292,7 @@ def main():
security_name = name security_name = name
turnover = amount turnover = amount
turnover_sort = sortIndex turnover_sort = sortIndex
turnover_change = '' #todo 从交易数据中获取然后计算 ,一日、多日 turnover_change = turnover - prevIndustryDataMap[code]['turnover'] if hasPrevIndustryData else turnover #todo 从交易数据中获取然后计算 ,一日、多日
sortIndex +=1 sortIndex +=1
rise_number = risenum rise_number = risenum
flat_number = flatnum flat_number = flatnum
@ -297,25 +310,25 @@ def main():
# turnover_ratio_change = '' #todo # turnover_ratio_change = '' #todo
# turnover_sort_change = ''#todo # turnover_sort_change = ''#todo
turnover5 = turnOver5[code]['turnover'] #todo turnover5 = turnOver5[code]['turnover'] #todo
turnover5_change = '' #todo turnover5_change = turnover5 - prevIndustryDataMap[code]['turnover5'] if hasPrevIndustryData else turnover5 #todo
turnover5_ratio = (turnover5*Decimal('100.00') )/ turnOver5[code]['total'] #todo turnover5_ratio = (turnover5*Decimal('100.00') )/ turnOver5[code]['total'] #todo
turnover5_ratio_change = '' #todo turnover5_ratio_change = '' #todo
turnover5_sort = '' #todo turnover5_sort = '' #todo
turnover5_sort_change = ''#todo turnover5_sort_change = ''#todo
turnover10 = turnOver10[code]['turnover'] #todo turnover10 = turnOver10[code]['turnover'] #todo
turnover10_change = '' #todo turnover10_change = turnover10 - prevIndustryDataMap[code]['turnover10'] if hasPrevIndustryData else turnover10 #todo
turnover10_ratio = (turnover10*Decimal('100.00') )/ turnOver10[code]['total'] #todo turnover10_ratio = (turnover10*Decimal('100.00') )/ turnOver10[code]['total'] #todo
turnover10_ratio_change = '' #todo turnover10_ratio_change = '' #todo
turnover10_sort = '' #todo turnover10_sort = '' #todo
turnover10_sort_change = ''#todo turnover10_sort_change = ''#todo
turnover20 = turnOver20[code]['turnover'] #todo turnover20 = turnOver20[code]['turnover'] #todo
turnover20_change = '' #todo turnover20_change = turnover20 - prevIndustryDataMap[code]['turnover20'] if hasPrevIndustryData else turnover20 #todo
turnover20_ratio = (turnover20*Decimal('100.00') )/ turnOver20[code]['total'] #todo turnover20_ratio = (turnover20*Decimal('100.00') )/ turnOver20[code]['total'] #todo
turnover20_ratio_change = '' #todo turnover20_ratio_change = '' #todo
turnover20_sort = '' #todo turnover20_sort = '' #todo
turnover20_sort_change = ''#todo turnover20_sort_change = ''#todo
turnover30 = turnOver30[code]['turnover'] #todo turnover30 = turnOver30[code]['turnover'] #todo
turnover30_change = '' #todo turnover30_change = turnover30 - prevIndustryDataMap[code]['turnover30'] if hasPrevIndustryData else turnover30 #todo
turnover30_ratio = (turnover30*Decimal('100.00') )/ turnOver30[code]['total'] #todo turnover30_ratio = (turnover30*Decimal('100.00') )/ turnOver30[code]['total'] #todo
turnover30_ratio_change = '' #todo turnover30_ratio_change = '' #todo
turnover30_sort = '' #todo turnover30_sort = '' #todo

Loading…
Cancel
Save