Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Rocky Chen committed Oct 21, 2019
1 parent 463f1bf commit 9b21528
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 28 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ user.json
codes.txt
.vscode/
settings.py
keys/
keys/
email_list.py
55 changes: 38 additions & 17 deletions SPSIOP_PRICE.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

import requests
import pymongo
from settings import s
from settings import send_aliyun, llogger,QQ_MAIL

client = pymongo.MongoClient('192.168.10.48', 17001)
doc = client['db_stock']['SPSIOP']
# 先访问一下雪球首页得到cookies
logger = llogger('log/huabaoyouqi.log')

home_headers = {'User-Agent': 'Xueqiu App'}

Expand All @@ -20,7 +22,7 @@
'P3P': 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"'}
url = 'https://stock.xueqiu.com/v5/stock/quote.json?symbol=.SPSIOP&extend=detail'
home_page = 'https://xueqiu.com'

today = datetime.datetime.now().strftime('%Y-%m-%d')


def get_price():
Expand All @@ -29,7 +31,7 @@ def get_price():
session.get(url=home_page, headers=home_headers)

r = session.get(url=url,
headers=headers)
headers=headers)

js_data = r.json()

Expand All @@ -38,27 +40,46 @@ def get_price():
quote['crawltime'] = datetime.datetime.now()
doc.insert_one(quote)
percent = quote.get('percent')
ret = qdii_info()
if ret:
predict_v = round((1+percent*0.95*0.01)*ret,3)
logger.info(f'最新估值{predict_v}')
d={'日期':today,'估值':predict_v}
client['db_stock']['huabaoyouqi_predict'].insert_one(d)
title=f'{today}华宝估值{predict_v}'
send_aliyun(title,'',QQ_MAIL)
else:

logger.error('获取估值失败')

# current = quote.get('current')
# low52w = quote.get('low52w')
# high52w = quote.get('high52w')
# amplitude = quote.get('amplitude')
# d={}
# d['']


def qdii_info():
today = datetime.datetime.now().strftime('%Y-%m-%d')
url='https://www.jisilu.cn/data/qdii/qdii_list/?rp=25&page=1'
r=requests.get(url=url,headers=home_headers)
js_data=r.json()
rows = js_data.get('rows',[])
doc=client['DB_QDII'][today]
url = 'https://www.jisilu.cn/data/qdii/qdii_list/?rp=25&page=1'
r = requests.get(url=url, headers=home_headers)
js_data = r.json()
rows = js_data.get('rows', [])
new_rows=[]
for row in rows:
new_rows.append(row.get('cell'))
doc = client['DB_QDII'][today]

try:
doc.insert(rows)
doc.insert(new_rows)

except Exception as e:
print(e)
logger.error(e)
else:
for row in rows:
if row.get('cell', {}).get('fund_nm') == '华宝油气':

nav = row.get('cell', {}).get('fund_nav')
try:
nav = float(nav) # 网站给的是字符
except:
return None
else:
return nav


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions fetch_each_day.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
import os
from settings import get_engine, llogger, is_holiday, DATA_PATH

filename=os.path.basename(__file__)
logger = llogger('log/'+filename)
logger = llogger('log/fetch_each_day.log')


class FetchDaily(object):
Expand Down
2 changes: 1 addition & 1 deletion jisilu.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from sqlalchemy import VARCHAR
import os
engine = get_engine('db_jisilu')
logger = llogger('log/'+'jisilu')
logger = llogger('log/'+'jisilu.log')


# 爬取集思录 可转债的数据
Expand Down
2 changes: 2 additions & 0 deletions log/plot_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[2019-10-21 15:43:37,791][Filename: yesterday_zt_monitor.py][line: 90][INFO] :: Start
[2019-10-21 16:38:36,305][Filename: yesterday_zt_monitor.py][line: 90][INFO] :: Start
9 changes: 4 additions & 5 deletions yesterday_zt_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
from plot_line import plot_stock_line
from settings import llogger

filename=os.path.basename(__file__)
logger = llogger('log/'+filename)
logger = llogger('log/yester_zdt.log')

def monitor():
engine = get_engine('db_zdt','local')
Expand Down Expand Up @@ -84,9 +83,9 @@ def plot_yesterday_zt(type_name='zrzt', current=datetime.datetime.now().strftime

if __name__ == '__main__':

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

logger.info("Start")
api = ts.get_apis()
Expand Down
3 changes: 1 addition & 2 deletions zdt.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
import datetime
import tushare as ts

filename=os.path.basename(__file__)
logger = llogger('log/'+filename)
logger = llogger('log/zdt.log')

class GetZDT:
def __init__(self,today):
Expand Down

0 comments on commit 9b21528

Please sign in to comment.