Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Rockyzsu committed Feb 22, 2019
1 parent 77a757f commit 97984dc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 24 deletions.
34 changes: 18 additions & 16 deletions alert_me.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ def monitor(self):

while 1:

# current = trading_time()
current=0
current = trading_time()
# current=0
if current == MARKET_OPENING:

# self.get_realtime_info(self.kzz_code, self.has_sent_kzz, '转债', self.kzz_stocks, self.kzz_stocks_yjl,
# ZZ_ALERT_PERCENT)
# self.get_realtime_info(self.zg_code, self.has_sent_zg, '正股', self.zg_stocks, self.zg_stocks_yjl,
# ZG_ALERT_PERCENT)
self.get_realtime_info(self.kzz_code, self.has_sent_kzz, '转债', self.kzz_stocks, self.kzz_stocks_yjl,
ZZ_ALERT_PERCENT)
self.get_realtime_info(self.zg_code, self.has_sent_zg, '正股', self.zg_stocks, self.zg_stocks_yjl,
ZG_ALERT_PERCENT)
self.get_price_diff(self.kzz_code, self.has_sent_diff, '差价')
time.sleep(LOOP_TIME)

Expand Down Expand Up @@ -147,17 +147,18 @@ def get_realtime_info(self, codes, has_sent, types, stock, yjl, percent):
if len(ret_dt) > 0:

# 提醒一次后,下一次的间隔为5分钟后
sent_list = []
# sent_list = []
for i in ret_dt['code']:

if has_sent[i] <= datetime.datetime.now():
print('整股时间',i,has_sent[i])
name_list = []
yjl_list = []
name_list.append(stock[i])
yjl_list.append(yjl[i])
has_sent[i] = has_sent[i] + datetime.timedelta(minutes=5)
sent_list.append(ret_dt[ret_dt['code'] == i])
print(has_sent[i])
has_sent[i] = datetime.datetime.now() + datetime.timedelta(minutes=5)
# sent_list.append(ret_dt[ret_dt['code'] == i])
# print(has_sent[i])

ret_dt1 = ret_dt[ret_dt['code'] == i]
ret_dt1['名称'] = name_list
Expand Down Expand Up @@ -189,7 +190,7 @@ def get_price_diff(self, codes, has_sent_, types):
time.sleep(EXECEPTION_TIME)

else:
print(df)
# print(df)
df['bid1'] = df['bid1'].astype(float)
df['ask1'] = df['ask1'].astype(float)
df['diff'] = np.abs(df['bid1'] - df['ask1'])
Expand All @@ -201,15 +202,16 @@ def get_price_diff(self, codes, has_sent_, types):
for j in result['code']:

if has_sent_[j] <= datetime.datetime.now():
has_sent_[j] = has_sent_[j] + datetime.timedelta(minutes=5)
print('差价时间',j,has_sent_[j])
has_sent_[j] = datetime.datetime.now()+ datetime.timedelta(minutes=5)
name_list = []
yjl_list = []
name_list.append(self.kzz_stocks[j])
yjl_list.append(self.kzz_stocks_yjl[j])
ret_dt1 = result[result['code'] == j]
ret_dt1['名称']=name_list
ret_dt1['溢价率']=yjl_list
ret_dt1 = ret_dt1.set_index('code', drop=True)
# ret_dt1 = ret_dt1.set_index('code', drop=True)

ret_dt1 = ret_dt1[['名称', 'code', 'bid1', 'ask1', 'bid_vol1', 'ask_vol1', 'diff']]

Expand All @@ -225,9 +227,9 @@ def get_price_diff(self, codes, has_sent_, types):

if __name__ == '__main__':

# if is_holiday():
# logger.info('Holiday')
# exit(0)
if is_holiday():
logger.info('Holiday')
exit(0)

# 周末的时候不登录微信

Expand Down
25 changes: 17 additions & 8 deletions shareholder_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,25 @@ def create_date():
# 十大和十大流通
def get_stockholder(code, start, end):
# 十大非流通
stockholder = pro.top10_holders(ts_code=code, start_date=start, end_date=end)
time.sleep(1)
# 十大流通
stockfloat = pro.top10_floatholders(ts_code=code, start_date=start, end_date=end)
time.sleep(1)
if stockholder.empty and stockfloat.empty:
return pd.DataFrame(), pd.DataFrame()
global pro
try:
stockholder = pro.top10_holders(ts_code=code, start_date=start, end_date=end)
time.sleep(1)
stockfloat = pro.top10_floatholders(ts_code=code, start_date=start, end_date=end)
time.sleep(1)

except Exception as e:
print(e)
time.sleep(10)
ts.set_token(token)
pro = ts.pro_api()

else:
return stockholder, stockfloat
if stockholder.empty and stockfloat.empty:
return pd.DataFrame(), pd.DataFrame()

else:
return stockholder, stockfloat


# 十大 股东 流动
Expand Down

0 comments on commit 97984dc

Please sign in to comment.