|  | @@ -16,6 +16,7 @@ start = dt.now()
 | 
	
		
			
				|  |  |  # 注意修改time delta
 | 
	
		
			
				|  |  |  # fre = '30m'
 | 
	
		
			
				|  |  |  for fre in ['30m', '1d']:
 | 
	
		
			
				|  |  | +    start = dt.now()
 | 
	
		
			
				|  |  |      print(fre)
 | 
	
		
			
				|  |  |      # 连接数据库
 | 
	
		
			
				|  |  |      db = pymysql.connect(host='localhost',
 | 
	
	
		
			
				|  | @@ -33,6 +34,7 @@ for fre in ['30m', '1d']:
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      def hlfx(stocks, engine, engine2):
 | 
	
		
			
				|  |  |          for thd.stock in stocks:
 | 
	
		
			
				|  |  | +            print(thd.stock)
 | 
	
		
			
				|  |  |              if ('stk%s_%s' % (thd.stock, fre)) in table_list:
 | 
	
		
			
				|  |  |                  # 有历史数据
 | 
	
		
			
				|  |  |                  index_len = pd.read_sql_table('stk%s_%s' % (thd.stock, fre), con=engine2).iloc[-1, 0]
 | 
	
	
		
			
				|  | @@ -93,6 +95,8 @@ for fre in ['30m', '1d']:
 | 
	
		
			
				|  |  |                                      else:
 | 
	
		
			
				|  |  |                                          break
 | 
	
		
			
				|  |  |                                  m = m - 1
 | 
	
		
			
				|  |  | +                                if m == 0:
 | 
	
		
			
				|  |  | +                                    thd.df_day.loc[x, 'HL'] = 'L'
 | 
	
		
			
				|  |  |                          # 顶
 | 
	
		
			
				|  |  |                          elif ((thd.df_day.loc[x, 'high'] < thd.df_day.loc[x - 1, 'high']) and (
 | 
	
		
			
				|  |  |                                  thd.df_day.loc[x - 2, 'high'] < thd.df_day.loc[x - 1, 'high'])):
 | 
	
	
		
			
				|  | @@ -118,6 +122,8 @@ for fre in ['30m', '1d']:
 | 
	
		
			
				|  |  |                                          break
 | 
	
		
			
				|  |  |                                      break
 | 
	
		
			
				|  |  |                                  m = m - 1
 | 
	
		
			
				|  |  | +                                if m == 0:
 | 
	
		
			
				|  |  | +                                    thd.df_day.loc[x, 'HL'] = 'H'
 | 
	
		
			
				|  |  |                          else:
 | 
	
		
			
				|  |  |                              thd.df_day.loc[x, 'HL'] = '-'
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -176,6 +182,8 @@ for fre in ['30m', '1d']:
 | 
	
		
			
				|  |  |                                      else:
 | 
	
		
			
				|  |  |                                          break
 | 
	
		
			
				|  |  |                                  m = m - 1
 | 
	
		
			
				|  |  | +                                if m == 0:
 | 
	
		
			
				|  |  | +                                    thd.df_day.loc[x, 'HL'] = 'L'
 | 
	
		
			
				|  |  |                          # 顶
 | 
	
		
			
				|  |  |                          elif ((thd.df_day.loc[x, 'high'] < thd.df_day.loc[x - 1, 'high']) and (
 | 
	
		
			
				|  |  |                                  thd.df_day.loc[x - 2, 'high'] < thd.df_day.loc[x - 1, 'high'])):
 | 
	
	
		
			
				|  | @@ -201,12 +209,14 @@ for fre in ['30m', '1d']:
 | 
	
		
			
				|  |  |                                          break
 | 
	
		
			
				|  |  |                                      break
 | 
	
		
			
				|  |  |                                  m = m - 1
 | 
	
		
			
				|  |  | +                                if m == 0:
 | 
	
		
			
				|  |  | +                                    thd.df_day.loc[x, 'HL'] = 'H'
 | 
	
		
			
				|  |  |                          else:
 | 
	
		
			
				|  |  |                              thd.df_day.loc[x, 'HL'] = '-'
 | 
	
		
			
				|  |  |                  # 更新数据库
 | 
	
		
			
				|  |  |                  thd.df_day.to_sql('stk%s_%s' % (thd.stock, fre), con=engine2, index=True, if_exists='append')
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    step = 100
 | 
	
		
			
				|  |  | +    step = 500
 | 
	
		
			
				|  |  |      thread_list = []
 | 
	
		
			
				|  |  |      engine = []
 | 
	
		
			
				|  |  |      engine2 = []
 | 
	
	
		
			
				|  | @@ -222,4 +232,7 @@ for fre in ['30m', '1d']:
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      for thread in thread_list:
 | 
	
		
			
				|  |  |          thread.join()
 | 
	
		
			
				|  |  | -    db.close()
 | 
	
		
			
				|  |  | +    db.close()
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    end= dt.now()
 | 
	
		
			
				|  |  | +    print('总时长:', (end - start).seconds)
 |