|
@@ -24,6 +24,7 @@ cursor = db.cursor()
|
|
|
cursor.execute('show tables like {}'.format('\'%{}\''.format(fre)))
|
|
|
|
|
|
stocks = list(get_all_securities(['stock'], date='2021-12-31').index)
|
|
|
+stocks = ['301058.XSHE']
|
|
|
|
|
|
print(dt.now(), 'stocks范围已获取!')
|
|
|
|
|
@@ -36,6 +37,8 @@ for stock in stocks:
|
|
|
except BaseException:
|
|
|
continue
|
|
|
|
|
|
+
|
|
|
+
|
|
|
print(dt.now(), '数据库数据已赋值!')
|
|
|
|
|
|
thd = threading.local()
|
|
@@ -68,76 +71,73 @@ def qbh_hlfx(stocks, df):
|
|
|
thd.df_day.iloc[-1, 3] = max(thd.df_day.iloc[-1, 3], thd.get_bars.loc[i, 'high'])
|
|
|
thd.df_day.iloc[-1, 4] = max(thd.df_day.iloc[-1, 4], thd.get_bars.loc[i, 'low'])
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- for x in range(stk_len, len(thd.df_day.index)):
|
|
|
- m = x - 1
|
|
|
-
|
|
|
- if ((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'])):
|
|
|
-
|
|
|
-
|
|
|
- thd.df_day.loc[x, 'HL'] = 'L*'
|
|
|
- if x == len(thd.df_day.index) -1:
|
|
|
- pass
|
|
|
-
|
|
|
- while m:
|
|
|
- if thd.df_day.loc[m, 'HL'] == 'H':
|
|
|
- if(i-m) > 3:
|
|
|
- thd.df_day.loc[x, 'HL'] = 'L'
|
|
|
- if x == len(thd.df_day.index) - 1:
|
|
|
- print(stock, '$$$$$$$', '\n', '买买买买买!!')
|
|
|
- break
|
|
|
- elif (thd.df_day.loc[m, 'HL'] == 'L' ):
|
|
|
- if thd.df_day.loc[x-1, 'low'] < thd.df_day.loc[m-1, 'low']:
|
|
|
-
|
|
|
- thd.df_day.loc[x, 'HL'] = 'L'
|
|
|
- if x == len(thd.df_day.index) - 1:
|
|
|
- print(stock, '$$$$$$$', '\n', '中继后的底————买吗?!')
|
|
|
+ if len(thd.df_day.index) > 2:
|
|
|
+
|
|
|
+ for x in range(stk_len, len(thd.df_day.index)):
|
|
|
+ m = x - 1
|
|
|
+
|
|
|
+ if ((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'])):
|
|
|
+
|
|
|
+
|
|
|
+ thd.df_day.loc[x, 'HL'] = 'L*'
|
|
|
+ while m:
|
|
|
+ if thd.df_day.loc[m, 'HL'] == 'H':
|
|
|
+ if(x-m) > 3:
|
|
|
+ thd.df_day.loc[x, 'HL'] = 'L'
|
|
|
+ if x == len(thd.df_day.index) - 1:
|
|
|
+ print(stock, '$$$$$$$', '\n', thd.df_day.loc[x, 'date'], '买买买买买!!')
|
|
|
break
|
|
|
- else:
|
|
|
+ elif (thd.df_day.loc[m, 'HL'] == 'L' ):
|
|
|
+ if thd.df_day.loc[x-1, 'low'] < thd.df_day.loc[m-1, 'low']:
|
|
|
+
|
|
|
+ thd.df_day.loc[x, 'HL'] = 'L'
|
|
|
+ if x == len(thd.df_day.index) - 1:
|
|
|
+
|
|
|
+ print(stock, '$$$$$$$', '\n', thd.df_day.loc[x, 'date'],'中继后的底————买吗?!')
|
|
|
+ break
|
|
|
+ else:
|
|
|
+ break
|
|
|
+ m = m-1
|
|
|
+
|
|
|
+ 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'])):
|
|
|
+
|
|
|
+
|
|
|
+ thd.df_day.loc[x, 'HL'] = 'H*'
|
|
|
+ while m:
|
|
|
+ if thd.df_day.loc[m, 'HL'] == 'L':
|
|
|
+ if x-m > 3:
|
|
|
+ thd.df_day.loc[x, 'HL'] = 'H'
|
|
|
+ if x == len(thd.df_day.index) - 1:
|
|
|
+
|
|
|
+ pass
|
|
|
+ thd.df_day.loc[x, 9] = thd.df_day.loc[x, 'close'] - thd.df_day.loc[m, 'close']
|
|
|
break
|
|
|
- m = m-1
|
|
|
-
|
|
|
-
|
|
|
- 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'])):
|
|
|
-
|
|
|
-
|
|
|
- thd.df_day.loc[x, 'HL'] = 'H*'
|
|
|
- if x == len(thd.df_day.index) - 1:
|
|
|
-
|
|
|
- pass
|
|
|
- while m:
|
|
|
- if thd.df_day.loc[m, 'HL'] == 'L':
|
|
|
- if i-m > 3:
|
|
|
- thd.df_day.loc[x, 'HL'] = 'H'
|
|
|
- if x == len(thd.df_day.index) - 1:
|
|
|
-
|
|
|
- pass
|
|
|
- thd.df_day.loc[x, 9] = thd.df_day.loc[x, 'close'] - thd.df_day.loc[m, 'close']
|
|
|
- break
|
|
|
- elif (thd.df_day.loc[m, 'HL'] == 'H'):
|
|
|
- if thd.df_day.loc[x-1, 'high'] > thd.df_day.loc[m-1, 'high']:
|
|
|
-
|
|
|
- thd.df_day.loc[x, 'HL'] = 'H'
|
|
|
- if x == len(thd.df_day.index) - 1:
|
|
|
- pass
|
|
|
-
|
|
|
+ elif (thd.df_day.loc[m, 'HL'] == 'H'):
|
|
|
+ if thd.df_day.loc[x-1, 'high'] > thd.df_day.loc[m-1, 'high']:
|
|
|
+
|
|
|
+ thd.df_day.loc[x, 'HL'] = 'H'
|
|
|
+ if x == len(thd.df_day.index) - 1:
|
|
|
+ pass
|
|
|
+
|
|
|
+ break
|
|
|
break
|
|
|
- break
|
|
|
- m = m-1
|
|
|
- else:
|
|
|
- thd.df_day.loc[x, 'HL'] = '-'
|
|
|
+ m = m-1
|
|
|
+ else:
|
|
|
+ thd.df_day.loc[x, 'HL'] = '-'
|
|
|
+ print(thd.df_day)
|
|
|
+ else:
|
|
|
+ pass
|
|
|
except BaseException:
|
|
|
continue
|
|
|
|
|
|
|
|
|
-while True:
|
|
|
- df = get_bars(stocks, count=20, unit=fre,
|
|
|
- fields=['date', 'open', 'close', 'high', 'low', 'volume', 'money'], include_now=True, df=True)
|
|
|
- print(dt.now(), 'get_bars 成功')
|
|
|
-
|
|
|
- qbh_hlfx(stocks, df)
|
|
|
-
|
|
|
+
|
|
|
+df = get_bars(stocks, count=2, unit=fre,
|
|
|
+ fields=['date', 'open', 'close', 'high', 'low', 'volume', 'money'], include_now=True, df=True)
|
|
|
+print(dt.now(), 'get_bars 成功')
|
|
|
+
|
|
|
+qbh_hlfx(stocks, df)
|
|
|
+
|
|
|
|
|
|
|
|
|
|