1.查看每日公布的龙虎榜
2.提取出多名著名游资参与的股票列表,也就是给力队友
3.提取出需要特别注意的股票,有多名一日游的游资参与的,也就是猪队友,次日注意跑路
import tushare as ts
import datetime
import requests
import re
import demjson
import time
from retrying import retry
from bs4 import BeautifulSoup
# 获取上一个交易日的日期
def tradecalc(mdate='2017-12-26'):
return 0
# 新浪龙虎榜个股
def getbillboardinfo(tradedate):
params = {'tradedate': tradedate}
headers = {'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate, sdch',
'Accept-Language': 'zh-CN,zh;q=0.8',
'Connection': 'keep-alive',
'Host': 'vip.stock.finance.sina.com.cn',
'Referer': 'http://vip.stock.finance.sina.com.cn/q/go.php/vInvestConsult/kind/lhb/index.phtml',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.107 Safari/537.36'
}
session = requests.Session()
baseurl = u"http://vip.stock.finance.sina.com.cn/q/go.php/vInvestConsult/kind/lhb/index.phtml"
rval = session.get(baseurl, params=params,
headers=headers, timeout=300)
rval.encoding = 'gbk'
stocklist = []
if rval.status_code == 200:
soup = BeautifulSoup(rval.text, 'html.parser')
tables = soup.find_all('table', attrs={'class': 'list_table'})
for table in tables:
trs = table.find_all('tr', attrs={'class': 'head'})
comment = list(trs[0].stripped_strings)[0]
data_list = [list(tr.stripped_strings)[1:-1] for tr in trs[2:]]
for tr in trs[2:]:
mstock = {}
mstock['code'] = list(tr.stripped_strings)[1]
mstock['comment'] = comment
td_last = tr.find_all('td')[-1]
match = re.search(r"showDetail\(\'(.*?)\'", str(td_last))
mstock['type'] = match.group(1)
stocklist.append(mstock)
return stocklist
# 龙虎榜个股买卖机构
def getbillboarddata(stockcode, tradedate, stype):
params = {'symbol': stockcode, 'tradedate': tradedate, 'type': stype}
headers = {'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate, sdch',
'Accept-Language': 'zh-CN,zh;q=0.8',
'Connection': 'keep-alive',
'Host': 'vip.stock.finance.sina.com.cn',
'Referer': 'http://vip.stock.finance.sina.com.cn/q/go.php/vInvestConsult/kind/lhb/index.phtml',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.107 Safari/537.36'
}
session = requests.Session()
baseurl = "http://vip.stock.finance.sina.com.cn/q/api/jsonp.php/var%20details=/InvestConsultService.getLHBComBSData"
dresult = demjson.decode('{}')
rval = session.get(baseurl, params=params,
headers=headers, timeout=300)
if rval.status_code == 200:
match = re.search(r'details=((.+))', rval.text)
if match:
binfo = re.sub('\'', '\"', str(match.group(
1)).replace('((', "").replace('))', ""))
dresult = demjson.decode(binfo)
# print(dresult)
return dresult
def main():
print('billboard monitor')
now = datetime.datetime.now()
delta = datetime.timedelta(days=0)
d = (now + delta).strftime('%Y-%m-%d')
print(d)
mlist = getbillboardinfo(tradedate=d)
billmsg = ''
for item in mlist:
# print(item)
dresult = getbillboarddata(stockcode=item['code'],
tradedate=d, stype=item['type'])
# 著名游资
count = 0
billmsg = ''
for ditem in dresult['buy']:
for mgidle in GoodIdleFund:
if str(ditem['comName']).find(str(mgidle)) != -1:
billmsg = billmsg + str(ditem['comName']) + " "
count = count + 1
if count >= 2:
print('买入金额最大的营业所里著名游资组合超过2个:%s,入榜原因:%s,机构名称:%s' %
(item['code'], item['comment'], billmsg))
# 一日游
foundbad = False
billmsg = ''
for ditem in dresult['buy']:
for mbidle in BadIdleFund:
if str(ditem['comName']).find(str(mbidle)) != -1:
billmsg = billmsg + str(ditem['comName']) + " "
foundbad = True
if foundbad:
print('买入金额最大的营业所里有一日游的:%s,入榜原因:%s,机构名称:%s' %
(item['code'], item['comment'], billmsg))
#----------------------------------------------
# 著名游资
count = 0
billmsg = ''
for ditem in dresult['sell']:
for mgidle in GoodIdleFund:
if str(ditem['comName']).find(str(mgidle)) != -1:
billmsg = billmsg + str(ditem['comName']) + " "
count = count + 1
if count >= 2:
print('卖出金额最大的营业所里著名游资组合超过2个:%s,入榜原因:%s,机构名称:%s' %
(item['code'], item['comment'], billmsg))
# 一日游
foundbad = False
billmsg = ''
for ditem in dresult['sell']:
for mbidle in BadIdleFund:
if str(ditem['comName']).find(str(mbidle)) != -1:
billmsg = billmsg + str(ditem['comName']) + " "
foundbad = True
if foundbad:
print('卖出金额最大的营业所里有一日游的:%s,入榜原因:%s,机构名称:%s' %
(item['code'], item['comment'], billmsg))
if __name__ == '__main__':
GoodIdleFund = ['深圳益田路荣超商务中心', '上海福山路', '上海古北路', '无锡清扬路', '上海溧阳路',
'上海奉贤区金碧路', '临安万马路', '深圳蛇口七路', '上海淮海中路', '深圳金田路', '华泰证券浙江分公司'] # 不错的游资
BadIdleFund = ['成都南一环', '成都北一环'] # 一日游的游资
# 封单量(手)对应流通盘(万)
Limitup_lv1 = [6000, (800, 3000)]
Limitup_lv2 = [10000, (3000, 5000)]
Limitup_lv3 = [20000, (5000, 10000)]
Limitup_lv4 = [40000, (10000, 20000)]
Limitup_lv5 = [50000, (20000, 30000)]
Limitup_lv6 = [80000, (30000, 60000)]
Limitup_lv7 = [100000, (60000, float('inf'))]
print('龙虎榜监测机构列表%s%s' % (GoodIdleFund, BadIdleFund))
print('封单等级:%s,%s,%s,%s,%s,%s,%s' % (Limitup_lv1, Limitup_lv2, Limitup_lv3,
Limitup_lv4, Limitup_lv5, Limitup_lv6, Limitup_lv7))
main()
强烈推荐文章:
2020年4月至6月净利润断层实战小结-真香!