| | |
| | | @classmethod |
| | | def push(cls, datas, request_id=None): |
| | | l2_codes_queue.put_nowait((int(time.time()), datas, request_id)) |
| | | logger_l2_codes_subscript.info("加入L2代码处理队列:数量-{}", len(datas)) |
| | | async_log_util.info(logger_l2_codes_subscript, "加入L2代码处理队列:数量-{}", len(datas)) |
| | | # cls.__get_redis().lpush(cls.__L2_CODE_KEY, json.dumps()) |
| | | |
| | | @classmethod |
| | |
| | | continue |
| | | # 获取自由流通市值 |
| | | if code not in global_util.zyltgb_map: |
| | | try: |
| | | __start_time = time.time() |
| | | zylt = kpl_api.getZYLTAmount(code) |
| | | async_log_util.info(logger_l2_codes_subscript, |
| | |
| | | # 保存自由流通股本 |
| | | ZYLTGBUtil.save_async(code, zylt // 10000, 1) |
| | | global_util.zyltgb_map[code] = int(zylt) |
| | | except: |
| | | pass |
| | | # 保存今日实时量 |
| | | temp_volumns.append((code, d[3])) |
| | | |
| | |
| | | from db import redis_manager |
| | | from db.redis_manager import RedisUtils |
| | | from log_module import async_log_util |
| | | from log_module.log import logger_l2_market_sell |
| | | from log_module.log import logger_l2_market_sell, logger_debug |
| | | from utils import tool |
| | | from utils.tool import CodeDataCacheUtil |
| | | |
| | |
| | | |
| | | @classmethod |
| | | def __load_datas(cls): |
| | | logger_debug.info("L2MarketSellManager __load_datas") |
| | | __redis = cls.__get_redis() |
| | | try: |
| | | keys = RedisUtils.keys(__redis, "fast_buy_used_sell_data-*") |
| | |
| | | return pos_list |
| | | |
| | | |
| | | # 获取L2每次批量处理数据的位置范围 |
| | | def get_real_place_order_positions(code, date=None): |
| | | if not date: |
| | | date = datetime.datetime.now().strftime("%Y-%m-%d") |
| | | pos_list = [] |
| | | with open("{}/logs/gp/l2/l2_real_place_order_position.{}.log".format(constant.get_path_prefix(), date), mode='r', |
| | | encoding="utf-8") as f: |
| | | while True: |
| | | line = f.readline() |
| | | if not line: |
| | | break |
| | | if line.find("{}-".format(code)) < 0: |
| | | continue |
| | | |
| | | if line.find("真实下单位置") > 0: |
| | | str_ = line.split("真实下单位置:")[1].strip() |
| | | pos = int(str_.split("-")[1].strip()) |
| | | # print("信号起始位置:", index) |
| | | pos_list.append(pos) |
| | | return pos_list |
| | | |
| | | |
| | | # 获取交易进度 |
| | | def get_trade_progress(code, date=None): |
| | | if not date: |
| | |
| | | import json |
| | | import time |
| | | |
| | | import requests |
| | | |
| | |
| | | DABAN_TYPE_EVER_LIMIT_DOWN = 5 |
| | | |
| | | |
| | | def __base_request(url, data): |
| | | def __base_request(url, data, timeout=60): |
| | | DELEGATE = True |
| | | if not DELEGATE: |
| | | headers = { |
| | |
| | | } |
| | | # proxies={'https': '192.168.3.251:9002'} |
| | | # 禁止代理,不然会走本地代理 |
| | | response = requests.post(url, data=data, headers=headers, proxies={"http": None, "https": None}) |
| | | response = requests.post(url, data=data, headers=headers, proxies={"http": None, "https": None}, |
| | | timeout=timeout) |
| | | if response.status_code != 200: |
| | | raise Exception("请求出错") |
| | | return response.text |
| | |
| | | # 获取自由流通市值 |
| | | def getZYLTAmount(code): |
| | | data = f"a=GetStockPanKou_Narrow&apiv=w32&c=StockL2Data&VerSion=5.8.0.2&State=1&PhoneOSNew=1&DeviceID=a38adabd-99ef-3116-8bb9-6d893c846e23&StockID={code}&" |
| | | result = __base_request("https://apphq.longhuvip.com/w1/api/index.php", data=data) |
| | | result = __base_request("https://apphq.longhuvip.com/w1/api/index.php", data=data, timeout=3) |
| | | result = json.loads(result) |
| | | if "real" in result: |
| | | return result["real"].get("actualcirculation_value") |
| | |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | print(getLimitUpInfo()) |
| | | start = time.time() |
| | | print(getZYLTAmount("000333"), time.time() - start) |
| | |
| | | import logging |
| | | |
| | | from l2.huaxin import huaxin_target_codes_manager |
| | | from log_module import async_log_util |
| | | from log_module.log import logger_l2_codes_subscript |
| | | from ths import client_manager |
| | | import constant |
| | |
| | | if True: |
| | | print("设置L2代码数量:", len(add_code_set)) |
| | | global latest_add_codes |
| | | logger_l2_codes_subscript.info(f"({request_id})预处理新增订阅代码:{add_code_set - latest_add_codes}") |
| | | async_log_util.info(logger_l2_codes_subscript, f"({request_id})预处理新增订阅代码:{add_code_set - latest_add_codes}") |
| | | latest_add_codes = add_code_set |
| | | add_datas = [] |
| | | for d in add_code_list: |
| | |
| | | # 获取L2处理位置信息 |
| | | process_indexs = log_export.get_l2_process_position(code, date) |
| | | trade_indexs = log_export.get_l2_trade_position(code, date) |
| | | fdatas = export_l2_data(code, datas, process_indexs, trade_indexs) |
| | | real_position_indexes = log_export.get_real_place_order_positions(code, date) |
| | | fdatas = export_l2_data(code, datas, process_indexs, trade_indexs, real_position_indexes) |
| | | __save_l2_datas(code, fdatas) |
| | | |
| | | |
| | |
| | | datas = local_today_datas[code] |
| | | process_indexs = log_export.get_l2_process_position(code, date) |
| | | trade_indexs = log_export.get_l2_trade_position(code, date) |
| | | fdatas = export_l2_data(code, datas, process_indexs, trade_indexs) |
| | | real_position_indexes = log_export.get_real_place_order_positions(code, date) |
| | | fdatas = export_l2_data(code, datas, process_indexs, trade_indexs, real_position_indexes) |
| | | return fdatas |
| | | |
| | | |
| | | def export_l2_data(code, datas, process_indexs, trade_indexs): |
| | | def export_l2_data(code, datas, process_indexs, trade_indexs, real_position_indexes): |
| | | def find_process_index(index): |
| | | for i in range(0, len(process_indexs)): |
| | | if process_indexs[i][0] <= index <= process_indexs[i][1]: |
| | |
| | | for data in datas: |
| | | index += 1 |
| | | trade_info = find_trade_index(data["index"]) |
| | | if not trade_info: |
| | | # 获取真实下单位置 |
| | | if data["index"] in real_position_indexes: |
| | | trade_info = [3] |
| | | style_int = None |
| | | if find_process_index(data["index"]) % 2 == 0: |
| | | style_int = 0 |
| | |
| | | |
| | | if __name__ == "__main__": |
| | | try: |
| | | export_l2_excel("002042") |
| | | export_l2_excel("000530") |
| | | except Exception as e: |
| | | logging.exception(e) |