def get_AHstocks_list(request): final_list = [] page_number = request.GET["PageNumber"] try: url = "http://58.push2.eastmoney.com/api/qt/clist/get?pz=20&po=1&np=1&ut=bd1d9ddb04089700cf9c27f6f7426281&fltt=2&invt=2&fid=f3&fs=b:DLMK0101&fields=f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152,f191,f192,f193,f186,f185,f187,f189,f188" + "&pn=" + str( page_number) response = SendRequest(url, headers) response_data = json.loads(response.get_initial_data()) for j in range(len(response_data["data"]["diff"])): final_list.append({ "股票名称": response_data["data"]["diff"][j]["f14"], "港股代码": response_data["data"]["diff"][j]["f12"], "A股代码": response_data["data"]["diff"][j]["f191"], "最新": str(response_data["data"]["diff"][j]["f186"]) + "," + str(response_data["data"]["diff"][j]["f2"]), "涨幅": str(response_data["data"]["diff"][j]["f187"]) + "%," + str(response_data["data"]["diff"][j]["f3"]) + "%", "溢价(A/H)": str(response_data["data"]["diff"][j]["f188"]) + "%" }) except Exception: return JsonResponse({"code": 400, "data": "网络出问题了"}, safe=False) return JsonResponse({ "code": 200, "page": 6, "data": final_list }, safe=False)
def get_rate_rank_industry(): final_result = {} final_list = [] for j in range(4): url = "http://89.push2.eastmoney.com/api/qt/clist/get?pz=20&po=1&np=1&ut=bd1d9ddb04089700cf9c27f6f7426281&fltt=2&invt=2&fid=f3&fs=m:90+t:2&fields=f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f222" + "&pn=" + str( j + 1) request = SendRequest(url, headers) s_initial = request.get_initial_data() s = json.loads(s_initial) data_num = len(s["data"]["diff"]) for i in range(data_num): temp_dict = { "名称": str(s["data"]["diff"][i]["f14"]), "涨幅": str(s["data"]["diff"][i]["f3"]) + "%", "涨跌额": str(s["data"]["diff"][i]["f14"]), "总市值": Number_util.num_check(s["data"]["diff"][i]["f20"]), "换手率": str(s["data"]["diff"][i]["f8"]) + "%", "上涨家数": str(s["data"]["diff"][i]["f104"]), "下跌家数": str(str(s["data"]["diff"][i]["f105"])), "最新价": str(s["data"]["diff"][i]["f2"]), "领涨股": str(s["data"]["diff"][i]["f128"]), "代码": str(s["data"]["diff"][i]["f140"]), "领涨股涨幅": str(s["data"]["diff"][i]["f136"]) } final_list.append(temp_dict) final_result["行业板块"] = final_list return final_result
def get_single_plate(request): try: url = "http://74.push2.eastmoney.com/api/qt/clist/get?po=1&np=1&fltt=2&invt=2&fid=f3&fs=m:90+t:2&fields=f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f222&_=1582597649159&pn=1" request = SendRequest(url, headers) s_initial = request.get_initial_data() s = json.loads(s_initial) return JsonResponse({"plate": str(s["data"]["diff"][0]["f14"])}, safe=False) except Exception: return JsonResponse({"code": 400, "data": "网络出问题了"}, safe=False)
def get_kechuang(request): page = request.GET["Page"] sort_field = request.GET["SortField"] sort_type = request.GET["SortType"] url = "http://13.push2.eastmoney.com/api/qt/clist/get?pn=1&pz=100&po=1&np=1&ut=bd1d9ddb04089700cf9c27f6f7426281&fltt=2&invt=2&fid=f3&fs=m:1+t:23&fields=f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62&_=1585819086668" initial_data = json.loads(SendRequest(url, header=headers).get_initial_data()) final_result = [] try: if sort_type is "1": initial_data = sorted(filter(is_number, initial_data["data"]["diff"]), key=lambda x: x[All_Field[sort_field]], reverse=False) else: initial_data = sorted(filter(is_number, initial_data["data"]["diff"]), key=lambda x: x[All_Field[sort_field]], reverse=True) if 20 * int(page) <= len(initial_data): stock_list = initial_data[(int(page) - 1) * 20:int(page) * 20] else: if 20 * (int(page) - 1) < len(initial_data) < 20 * int(page): stock_list = initial_data[20 * (int(page) - 1):len(initial_data)] else: return JsonResponse({"code": 400, "data": "没有更多数据了"},safe=False) for item in stock_list: final_result.append( {"code": item["f12"], "name": item["f14"], "nowPrice": item["f2"], "diff_rate": str(item["f3"]) + "%", "diff_money": item["f4"], "tradeAmount": Number_util.num_check(item["f5"]), "turnover": str(item["f8"]) + "%", "pe": str(item["f9"]) + "%", "pb": str(item["f23"]) + "%"}) except Exception: return JsonResponse({"code": 400, "data": "网络出问题了"}, safe=False) return JsonResponse({"code": 200, "上榜股票数": len(initial_data), "page": page, "data": final_result}, safe=False)
def get_rate_rank_industry_top6(): final_result = {} final_list = [] url = "http://89.push2.eastmoney.com/api/qt/clist/get?pz=20&po=1&np=1&ut=bd1d9ddb04089700cf9c27f6f7426281&fltt=2&invt=2&fid=f3&fs=m:90+t:2&fields=f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f222&pn=1" request = SendRequest(url, headers) s_initial = request.get_initial_data() s = json.loads(s_initial) for i in range(6): temp_dict = { "名称": str(s["data"]["diff"][i]["f14"]), "涨幅": str(s["data"]["diff"][i]["f3"]) + "%", "领涨股": str(s["data"]["diff"][i]["f128"]) } final_list.append(temp_dict) final_result["行业板块"] = final_list return final_result
def get_wellknown_HKStocks(request): final_list = [] page_number = request.GET["PageNumber"] try: url = "http://40.push2.eastmoney.com/api/qt/clist/get?pz=20&po=1&np=1&ut=bd1d9ddb04089700cf9c27f6f7426281&fltt=2&invt=2&fid=f3&fs=b:MK0106&fields=f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f19,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152" + "&pn=" + str( page_number) response = SendRequest(url, headers) response_data = json.loads(response.get_initial_data()) for j in range(len(response_data["data"]["diff"])): final_list.append({ "股票名称": response_data["data"]["diff"][j]["f14"], "代码": response_data["data"]["diff"][j]["f12"], "最新": str(response_data["data"]["diff"][j]["f2"]), "涨跌额": str(response_data["data"]["diff"][j]["f4"]), "涨跌幅": str(response_data["data"]["diff"][j]["f3"]) + "%", "今开": str(response_data["data"]["diff"][j]["f16"]), "最高": str(response_data["data"]["diff"][j]["f15"]), "最低": str(response_data["data"]["diff"][j]["f17"]), "昨收": str(response_data["data"]["diff"][j]["f18"]), "成交量(股)": Number_util.num_check(response_data["data"]["diff"][j]["f5"]), "成交额(港元)": Number_util.num_check(response_data["data"]["diff"][j]["f6"]) }) except Exception: return JsonResponse({"code": 400, "data": "网络出问题了"}, safe=False) return JsonResponse({ "code": 200, "page": 5, "data": final_list }, safe=False)
def get_worldstock_index(request): url = "http://42.push2.eastmoney.com/api/qt/clist/get?pn=1&pz=20&po=1&np=1&ut=bd1d9ddb04089700cf9c27f6f7426281&fltt=2&invt=2&fid=f3&fs=i:1.000001,i:0.399001,i:0.399005,i:0.399006,i:1.000300,i:100.HSI,i:100.HSCEI,i:124.HSCCI,i:100.TWII,i:100.N225,i:100.KOSPI200,i:100.KS11,i:100.STI,i:100.SENSEX,i:100.KLSE,i:100.SET,i:100.PSI,i:100.KSE100,i:100.VNINDEX,i:100.JKSE,i:100.CSEALL&fields=f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107&_=1584063319092" final_result = [] try: response = SendRequest(url=url, header=headers) initial_data = json.loads(response.get_initial_data()) data = initial_data["data"]["diff"] for item in data: final_result.append({ "股指名": item["f14"], "最新价": str(item["f2"]), "涨跌额": str(item["f4"]), "涨跌幅": str(item["f3"]) + "%" }) except Exception: return JsonResponse({"code": 400, "data": "网络出问题了"}, safe=False) return JsonResponse({"code": 200, "data": final_result}, safe=False)
def get_mainforce_money_top6(request): url_industry = "http://push2.eastmoney.com/api/qt/clist/get?pn=1&pz=500&po=1&np=1&fields=f12,f13,f14,f62&fid=f62&fs=m:90+t:2&ut=b2884a393a59ad64002292a3e90d46a5" url_concept = "http://push2.eastmoney.com/api/qt/clist/get?pn=1&pz=500&po=1&np=1&fields=f12,f13,f14,f62&fid=f62&fs=m:90+t:3&ut=b2884a393a59ad64002292a3e90d46a5" url_region = "http://push2.eastmoney.com/api/qt/clist/get?pn=1&pz=500&po=1&np=1&fields=f12,f13,f14,f62&fid=f62&fs=m:90+t:1&ut=b2884a393a59ad64002292a3e90d46a5" try: response_industry, response_concept, response_region = SendRequest( url_industry, headers), SendRequest(url_concept, headers), SendRequest(url_region, headers) data_industry = json.loads(response_industry.get_initial_data()) data_concept = json.loads(response_concept.get_initial_data()) data_region = json.loads(response_region.get_initial_data()) industry_dict, concept_dict, region_dict = { "title": "行业主力净流入" }, { "title": "概念主力净流入" }, { "title": "地域主力净流入" } for i in range(6): industry_dict[data_industry["data"]["diff"][i] ["f14"]] = Number_util.num_check( data_industry["data"]["diff"][i]["f62"]) concept_dict[data_concept["data"]["diff"][i] ["f14"]] = Number_util.num_check( data_concept["data"]["diff"][i]["f62"]) region_dict[data_region["data"]["diff"][i] ["f14"]] = Number_util.num_check( data_region["data"]["diff"][i]["f62"]) final_result = { "code": 200, "data": [industry_dict, concept_dict, region_dict] } except Exception: return JsonResponse({"code": 400, "data": "网络出问题了"}, safe=False) return JsonResponse(final_result, safe=False)
def get_hkstock_list(request): page_number = request.GET['PageNumber'] url = "http://4.push2.eastmoney.com/api/qt/clist/get?pz=20&po=1&np=1&ut=bd1d9ddb04089700cf9c27f6f7426281&fltt=2&invt=2&fid=f3&fs=m:116+t:3&fields=f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f19,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152" + "&pn=" + str( page_number) try: response = SendRequest(url, headers) data_initial = json.loads(response.get_initial_data()) stock_data = [] for i in range(len(data_initial["data"]["diff"])): temp_dict = { "代码": str(data_initial["data"]["diff"][i]["f12"]), "股票名称": str(data_initial["data"]["diff"][i]["f14"]), "最新": str(data_initial["data"]["diff"][i]["f2"]), "涨跌幅": str(data_initial["data"]["diff"][i]["f3"]) + "%", "涨跌额": str(data_initial["data"]["diff"][i]["f4"]), "今开": str(data_initial["data"]["diff"][i]["f17"]), "最高": str(data_initial["data"]["diff"][i]["f15"]), "最低": str(data_initial["data"]["diff"][i]["f16"]), "昨收": str(data_initial["data"]["diff"][i]["f18"]), "成交量(股)": Number_util.num_check(data_initial["data"]["diff"][i]["f5"]), "成交额(港元)": Number_util.num_check(data_initial["data"]["diff"][i]["f6"]) } stock_data.append(temp_dict) final_result = {"code": 200, "page": 107, "data": stock_data} except Exception: return JsonResponse({"code": 400, "data": "网络出问题了"}, safe=False) return JsonResponse(final_result, safe=False)
def get_rate_rank_top5(): url = "http://74.push2.eastmoney.com/api/qt/clist/get?po=1&np=1&fltt=2&invt=2&fid=f3&fs=m:90+t:2&fields=f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f222&_=1582597649159&pn=1" request = SendRequest(url, headers) s_initial = request.get_initial_data() s = json.loads(s_initial) data_num = len(s["data"]["diff"]) final_result = {} final_list = [] if data_num >= 5: for i in range(5): temp_dict = { str(s["data"]["diff"][i]["f14"]): str(s["data"]["diff"][i]["f3"]) + "%" } final_list.append(temp_dict) else: for i in range(5): temp_dict = { s["data"]["diff"][i]["f14"]: str(s["data"]["diff"][i]["f3"]) + "%" } final_list.append(temp_dict) final_result["今日涨幅最大"] = final_list return final_result
def get_fiveday_rate_rank_top5(): url = "http://push2.eastmoney.com/api/qt/clist/get?pn=1&pz=50&po=1&np=1&ut=b2884a393a59ad64002292a3e90d46a5&fltt=2&invt=2&fid=f109&fs=m:90+t:2&stat=5&fields=f12,f14,f2,f109,f164,f165,f166,f167,f168,f169,f170,f171,f172,f173,f257,f258,f124&rt=52765509" request = SendRequest(url, headers) s_initial = request.get_initial_data() s = json.loads(s_initial) data_num = len(s["data"]["diff"]) final_result = {} final_list = [] if data_num >= 5: for i in range(5): temp_dict = { s["data"]["diff"][i]["f14"]: str(s["data"]["diff"][i]["f109"]) + "%" } final_list.append(temp_dict) else: for i in range(5): temp_dict = { s["data"]["diff"][i]["f14"]: str(s["data"]["diff"][i]["f109"]) + "%" } final_list.append(temp_dict) final_result["5日涨幅最大"] = final_list return final_result
def get_money_rank_top5(): url = "http://push2.eastmoney.com/api/qt/clist/get?pn=1&pz=50&po=1&np=1&fltt=2&invt=2&fid=f62&fs=m:90+t:2&stat=1&fields=f12,f14,f2,f3,f62,f184,f66,f69,f72,f75,f78,f81,f84,f87,f204,f205,f124" request = SendRequest(url, headers) s_initial = request.get_initial_data() s = json.loads(s_initial) data_num = len(s["data"]["diff"]) final_result = {} final_list = [] if data_num >= 5: for i in range(5): temp_dict = { s["data"]["diff"][i]["f14"]: Number_util.num_check(s["data"]["diff"][i]["f62"]) } final_list.append(temp_dict) else: for i in range(5): temp_dict = { s["data"]["diff"][i]["f14"]: Number_util.num_check(s["data"]["diff"][i]["f62"]) } final_list.append(temp_dict) final_result["资金流入最多"] = final_list return final_result
def get_yidong(request): YiDong_dict = { 8202: "快速反弹", 8201: "火箭发射", 64: "有大买盘", 8210: "低开5日线", 8203: "高台跳水", 8193: "大笔买入", 8194: "大笔卖出", 128: "有大卖盘", 8204: "加速下跌", 8208: "竞价下跌", 8213: "60日新高", 8216: "60日大幅下跌", 4: "封涨停板", 8215: "60日大幅上涨", 16: "打开涨停板", 8: "封跌停板", 32: "打开涨跌板", 8209: "高开5日线", 8214: "60日新低", 8207: "竞价上涨", 8212: "向下缺口", 8211: "向上缺口", } page_index, final_result = int(request.GET["PageNumber"]) - 1, [] try: url = "http://push2ex.eastmoney.com/getAllBKChanges?ut=7eea3edcaed734bea9cbfc24409ed989&dpt=wzchanges&pageindex=0&pagesize=50" + "&pageindex=" + str( page_index) response = SendRequest(url=url, header=headers) data = json.loads(response.get_initial_data()) if data["data"] is None: return JsonResponse({"code": 400, "data": "暂无当日异动数据"}, safe=False) for i in range(len(data["data"]["allbk"])): final_result.append({ "板块名称": data["data"]["allbk"][i]["n"], "涨跌幅": data["data"]["allbk"][i]["u"] + "%", "主力净流入": Number_util.num_check(data["data"]["allbk"][i]["zjl"]), "板块异动总次数": data["data"]["allbk"][i]["ct"], "板块异动最频繁个股及所属类型": data["data"]["allbk"][i]["ms"]["n"] + "(" + YiDong_dict[data["data"]["allbk"][i]["ms"]["t"]] + ")", YiDong_dict[data["data"]["allbk"][i]["ydl"][0]["t"]]: data["data"]["allbk"][i]["ydl"][0]["ct"], YiDong_dict[data["data"]["allbk"][i]["ydl"][1]["t"]]: data["data"]["allbk"][i]["ydl"][1]["ct"], YiDong_dict[data["data"]["allbk"][i]["ydl"][2]["t"]]: data["data"]["allbk"][i]["ydl"][2]["ct"], YiDong_dict[data["data"]["allbk"][i]["ydl"][3]["t"]]: data["data"]["allbk"][i]["ydl"][3]["ct"], YiDong_dict[data["data"]["allbk"][i]["ydl"][4]["t"]]: data["data"]["allbk"][i]["ydl"][4]["ct"], YiDong_dict[data["data"]["allbk"][i]["ydl"][5]["t"]]: data["data"]["allbk"][i]["ydl"][5]["ct"], YiDong_dict[data["data"]["allbk"][i]["ydl"][6]["t"]]: data["data"]["allbk"][i]["ydl"][6]["ct"], }) except Exception: return JsonResponse({"code": 400, "data": "网络出问题了"}, safe=False) return JsonResponse({ "code": 200, "page": 7, "data": final_result }, safe=False)
def get_winnerlist(request): start_date, end_date = request.GET["StartDate"], request.GET["EndDate"] page = request.GET["Page"] try: url = "http://data.eastmoney.com/DataCenter_V3/stock2016/TradeDetail/pagesize=200,page=1,sortRule=-1,sortType=,startDate=" + start_date + ",endDate=" + end_date + ",gpfw=0,js=.html?rt=26398232" response = SendRequest(url=url, header=headers) initial_data = json.loads(response.get_initial_data()) if len(initial_data["data"]) >= 20 * int(page): stock_list = initial_data["data"][20 * (int(page) - 1):20 * int(page)] else: if 20 * (int(page) - 1) < len( initial_data["data"]) < 20 * int(page): stock_list = initial_data["data"][20 * ( int(page) - 1):len(initial_data["data"])] else: return JsonResponse({ "code": 400, "data": "没有更多数据了" }, safe=False) for item in stock_list: final_result.append({ "代码": item["SCode"], "名称": item["SName"], "上榜日": item["Tdate"], "上榜原因": item["Ctypedes"], "解读": item["JD"], "收盘价": item["ClosePrice"], "涨跌幅": item["Chgradio"], "龙虎榜净买额": Number_util.convert_stringnumber(item["JmMoney"]), "龙虎榜买入额": Number_util.convert_stringnumber(item["Bmoney"]), "龙虎榜成交额": Number_util.convert_stringnumber(item["ZeMoney"]), "市场总成交额": Number_util.convert_stringnumber(item["Turnover"]), "净买额占总成交比": item["JmRate"] + "%", "成交额占总成交比": item["ZeRate"] + "%", "换手率": item["Dchratio"] + "%", "流通市值": Number_util.convert_stringnumber(item["Ltsz"]) }) except Exception: print(Exception.__str__()) return JsonResponse({"code": 400, "data": "网络出问题了"}, safe=False) return JsonResponse( { "code": 200, "上榜股票数": len(initial_data["data"]), "page": page, "data": final_result }, safe=False)