def update(): global CLS_URL res = net.send(CLS_URL, 0) if res != -1: global CLS_CATCH_LIST baseinfo = re.findall(".*__NEXT_DATA__ = (.*)\\n module=.*", res) if len(baseinfo) <= 0: return data = json.loads(baseinfo[0]) dataList = data['props']['initialState']['telegraph']['dataList'] for info in dataList: level = info['level'] if level == 'B' or level == 'A': id = info['id'] if id not in CLS_CATCH_LIST: CLS_CATCH_LIST.append(id) ctime = info['ctime'] content = info['content'] pat = re.compile(r'<[^>]+>', re.S) content = pat.sub('', content) # modified_time = info['modified_time'] ftime = time.strftime("%H:%M:%S", time.localtime(ctime)) msg = '[财联社]' + '[' + ftime + ']' + content #print(msg) sendmsg.add(msg) if len(CLS_CATCH_LIST) > 30: CLS_CATCH_LIST.pop()
def quickup(code): stock_price, stock_time = 3, 31 global GP_CATCH_DIC data = GP_CATCH_DIC[code] stock = data['list'] lastprice = data['last'] # 上次价格 curprice = float(stock[stock_price]) # 当前价格 lastprice.append(curprice) lastlen = len(lastprice) if lastlen < 3: #数据太少无法计算 return elif lastlen > 10: #只存储10个数据 del lastprice[0] #快速拉升 minprice = float(min(lastprice)) if minprice <= 0: print('[dog] minprice err') #print(data) return global BK_NAME_CATCH_DIC #TIP_CATCH_LIST percent = float((curprice - minprice) / minprice * 100) #print('percent:' + str(percent) + ' curprice:' + str(curprice) + ' minprice:' + str(minprice)) if percent >= 3: msg = '[拉升][' + stock[stock_time] + '] ' + data[ 'name'] + ' ' + code + ' ' + BK_NAME_CATCH_DIC[ code] + ' 快速拉升' + str(percent) + '%' #TIP_CATCH_LIST.append(msg) sendmsg.add(msg) lastprice.clear() return #快速跳水 maxprice = float(max(lastprice)) if maxprice <= 0: print('[dog] maxprice err') #print(data) return percent = float((maxprice - curprice) / curprice * 100) if percent >= 3: msg = '[跳水][' + stock[stock_time] + '] ' + data[ 'name'] + ' ' + code + ' ' + BK_NAME_CATCH_DIC[ code] + ' 快速跳水' + str(percent) + '%' #TIP_CATCH_LIST.append(msg) lastprice.clear() sendmsg.add(msg)
def limitup(code): stock_price, stock_time = 3, 31 global GP_CATCH_DIC, GP_ZT_LIST, GP_DT_LIST #GP_CHECK_ZT_LIST,GP_DT_CNT,GP_ZT_CNT,GP_ZT_LIST data = GP_CATCH_DIC[code] stock = data['list'] close = data['lastclose'] # 昨日收盘价 open = data['open'] # 开盘价 curprice = float(stock[stock_price]) # 当前价格 st = data.get('st', False) # 是否st #涨停 ztprice = float(tools.getzt(close, st)) if curprice == ztprice: if code not in GP_ZT_LIST: GP_ZT_LIST.append(code) if open == curprice: #竞价涨停 msg = '[竞价][' + stock[stock_time] + '] ' + data[ 'name'] + ' ' + code + ' 竞价涨停 ' + BK_NAME_CATCH_DIC[code] else: #涨停 msg = '[涨停][' + stock[stock_time] + '] ' + data[ 'name'] + ' ' + code + ' 冲击涨停 ' + BK_NAME_CATCH_DIC[code] #if id in GP_LB_LIST.keys(): # s = s + '(' + str(GP_LB_LIST[id] + 1) + '连板)' #else: # s = s + '(首板)' #TIP_CATCH_LIST.append(msg) sendmsg.add(msg) #跌停 dtprice = float(tools.getdt(close, st)) if curprice == dtprice: if code not in GP_DT_LIST: GP_DT_LIST.append(code) if open == curprice: #竞价跌停 msg = '[竞价][' + stock[stock_time] + '] ' + data[ 'name'] + ' ' + code + ' 竞价跌停 ' + BK_NAME_CATCH_DIC[code] else: #跌停 msg = '[跌停][' + stock[stock_time] + '] ' + data[ 'name'] + ' ' + code + ' 冲击跌停 ' + BK_NAME_CATCH_DIC[code] #TIP_CATCH_LIST.append(msg) sendmsg.add(msg) '''
def firstup(code): global FIRSTUP_OLD_TIP if code in FIRSTUP_OLD_TIP: return percent = 3 #3% stock_high, stock_time = 4, 31 global GP_CATCH_DIC data = GP_CATCH_DIC[code] stock = data['list'] close = float(data['lastclose']) #昨日收盘价 high = float(stock[stock_high]) #今日最高价 price = tools.getpercent(close, percent) if high >= price: FIRSTUP_OLD_TIP.append(code) msg = '[涨幅][' + stock[stock_time] + '] ' + data[ 'name'] + ' ' + code + ' 首次涨幅到3% ' + BK_NAME_CATCH_DIC[code] #TIP_CATCH_LIST.append(msg) sendmsg.add(msg)
def kplje(): global KPL_RUL param = {} param['a'] = 'RealRankingInfo' param['c'] = 'StockRanking' param['Ratio'] = '5' param['Type'] = '1' param['Index'] = '0' param['Order'] = '1' param['st'] = '50' param['Token'] = '2efa906af1b5641270b21845a4bea7c0' param['UserID'] = '228432' res = net.sendpost(KPL_RUL,param) if res != -1: try: data = json.loads(res) except Exception as ee: print("[kpl] je json error") return -1 global KPL_ZLJE_LIST if data['errcode'] == '1001': print("[kpl] je login error") return -1 #print(data['list']) for row in data['list']: code = row['Code'] if code in KPL_ZLJE_LIST: continue ZLJE = row['ZLJE'] jz = Decimal(ZLJE / 100000000).quantize(Decimal('0.00')) jz = '{:g}'.format(float(jz)) jz = float(jz) if jz > 2: msg = '[主力净额][' + time.strftime("%H:%M:%S", time.localtime()) + '] ' + row['Name'] + ' ' + code + ' 本日净流入' + str(jz) + '亿' #print(msg) sendmsg.add(msg) KPL_ZLJE_LIST.append(code)
def kpldog(): global KPL_RUL param = {} param['a'] = 'GetPointPlate' param['c'] = 'PCArrangeData' param['Index'] = '0' param['PointType'] = '1,2,3' param['st'] = '1' #param['Date'] = '2018-07-30'#time.strftime("%Y-%m-%d", time.localtime())# param['Token'] = '2efa906af1b5641270b21845a4bea7c0' param['UserID'] = '228432' res = net.sendpost(KPL_RUL,param) if res != -1: try: data = json.loads(res) except Exception as ee: print("[kpl] dog json error") return -1 global KPL_SIGN_TIME for row in data['content']['List']: tid = row['Time'] if tid <= KPL_SIGN_TIME: continue KPL_SIGN_TIME = tid comment = row['Comment'] stock = row['Stock'] for stk in stock: name = stk[1] tip = '[' + name + ',' + stk[0] + ',' + str(stk[2]) + '%]' comment = comment.replace(name,tip) time_local = time.localtime(tid) stime = time.strftime("%H:%M:%S", time_local) msg = '[开盘啦][' + stime + '] ' + comment #print(msg) sendmsg.add(msg)