diff --git a/transferIndustrySatistics_python.py b/transferIndustrySatistics_python.py index 78644c6..f739159 100644 --- a/transferIndustrySatistics_python.py +++ b/transferIndustrySatistics_python.py @@ -70,12 +70,14 @@ def getPeriodTurnOver(dbconfig,dbcursor,startDate,endDate): code,turnover = row total = turnover + sortIndex = 1 sql_trade_period_qurey = 'select code,sum(amount) as turnover from stock_index where trade_day >= %s and trade_day < %s group by code order by amount DESC ' dbcursor.execute(sql_trade_period_qurey,(startDate,endDate)) totalTurnOvers = dbcursor.fetchall() for row in totalTurnOvers: code,turnover = row - periodTurnOverMap[code] = {'code':code,'turnover':turnover,'total':total} + periodTurnOverMap[code] = {'code':code,'turnover':turnover,'total':total,'turnover_sort':sortIndex} + sortIndex += 1 return periodTurnOverMap def getPeriodDiff(dbconfig,dbcursor,startDate,endDate,hasData): @@ -202,7 +204,7 @@ def main(): stock_basic_map = {} #转换数据的日期(单日) - trans_date = '2022-03-07' + trans_date = '2022-03-10' #查询交易日数据 sql_trade_qurey = 'select date,week,trade from trade_dates where trade = %s and date > %s' @@ -331,25 +333,26 @@ def main(): turnover5_change = turnover5 - Decimal(prevIndustryDataMap[code]['turnover5']) if hasPrevIndustryData else turnover5 #todo turnover5_ratio = (turnover5*Decimal('100.00') )/ Decimal(turnOver5[code]['total']) if hasTurnOver5 else ratio #todo turnover5_ratio_change = turnover5_ratio - Decimal(prevIndustryDataMap[code]['turnover5_ratio']) if hasPrevIndustryData else turnover5_ratio #todo - turnover5_sort = Decimal(prevIndustryDataMap[code]['turnover5_sort']) if hasPrevIndustryData else turnover_sort #todo + turnover5_sort = Decimal(turnOver5[code]['turnover_sort']) if hasTurnOver5 else turnover_sort #todo + print('code:',code ,' turnover5_sort:',prevIndustryDataMap[code]['turnover5_sort']) turnover5_sort_change = Decimal(prevIndustryDataMap[code]['turnover5_sort']) - turnover5_sort if hasPrevIndustryData else turnover5_sort #todo turnover10 = Decimal(turnOver10[code]['turnover']) if hasTurnOver10 else turnover #todo turnover10_change = turnover10 - Decimal(prevIndustryDataMap[code]['turnover10']) if hasPrevIndustryData else turnover10 #todo turnover10_ratio = (turnover10*Decimal('100.00') )/ Decimal(turnOver10[code]['total']) if hasTurnOver10 else ratio #todo turnover10_ratio_change = turnover10_ratio - Decimal(prevIndustryDataMap[code]['turnover10_ratio']) if hasPrevIndustryData else turnover10_ratio #todo - turnover10_sort = Decimal(prevIndustryDataMap[code]['turnover10_sort']) if hasPrevIndustryData else turnover_sort #todo + turnover10_sort = Decimal(turnOver10[code]['turnover_sort']) if hasTurnOver10 else turnover_sort #todo turnover10_sort_change = Decimal(prevIndustryDataMap[code]['turnover10_sort']) - turnover10_sort if hasPrevIndustryData else turnover10_sort #todo turnover20 = Decimal(turnOver20[code]['turnover']) if hasTurnOver20 else turnover #todo turnover20_change = turnover20 - Decimal(prevIndustryDataMap[code]['turnover20']) if hasPrevIndustryData else turnover20 #todo turnover20_ratio = (turnover20*Decimal('100.00') )/ Decimal(turnOver20[code]['total']) if hasTurnOver20 else ratio #todo turnover20_ratio_change = turnover20_ratio - Decimal(prevIndustryDataMap[code]['turnover20_ratio']) if hasPrevIndustryData else turnover20_ratio #todo - turnover20_sort = Decimal(prevIndustryDataMap[code]['turnover20_sort']) if hasPrevIndustryData else turnover_sort #todo + turnover20_sort = Decimal(turnOver20[code]['turnover_sort']) if hasTurnOver20 else turnover_sort #todo turnover20_sort_change = Decimal(prevIndustryDataMap[code]['turnover20_sort']) - turnover20_sort if hasPrevIndustryData else turnover20_sort #todo turnover30 = Decimal(turnOver30[code]['turnover']) if hasTurnOver30 else turnover #todo turnover30_change = turnover30 - Decimal(prevIndustryDataMap[code]['turnover30']) if hasPrevIndustryData else turnover30 #todo turnover30_ratio = (turnover30*Decimal('100.00') )/ Decimal(turnOver30[code]['total']) if hasTurnOver30 else ratio #todo turnover30_ratio_change = turnover30_ratio - Decimal(prevIndustryDataMap[code]['turnover30_ratio']) if hasPrevIndustryData else turnover30_ratio #todo - turnover30_sort = Decimal(prevIndustryDataMap[code]['turnover30_sort']) if hasPrevIndustryData else turnover_sort #todo + turnover30_sort = Decimal(turnOver30[code]['turnover_sort']) if hasTurnOver30 else turnover_sort #todo turnover30_sort_change = Decimal(prevIndustryDataMap[code]['turnover30_sort']) - turnover30_sort if hasPrevIndustryData else turnover30_sort #todo rise_number = risenum flat_number = flatnum