1.修改有概念的强拉参数
2.修改充分交易量函数基础条件
3.GUI新增及修改 行情板块强度模块,服务端解析日志数据及应答
4.
| | |
| | | from log_module import log_export, async_log_util |
| | | from log_module.log import hx_logger_l2_transaction, logger_debug, logger_request_api |
| | | from strategy import data_cache |
| | | from strategy.kpl_data_manager import KPLStockOfMarketsPlateLogManager |
| | | from strategy.kpl_data_manager import KPLStockOfMarketsPlateLogManager, KPLMarketStockHeatLogManager |
| | | from strategy.trade_setting import TradeSetting |
| | | from trade import huaxin_trade_api, huaxin_trade_data_update |
| | | from trade.huaxin_trade_record_manager import DelegateRecordManager, DealRecordManager, MoneyManager, PositionManager |
| | |
| | | finally: |
| | | if use_time_list and use_time_list[-1][1] > 10: |
| | | logger_debug.warning(f"环境获取时间大于10s({request_id}):{use_time_list}") |
| | | |
| | | elif url.path == "/load_kpl_stock_of_markets_plate": |
| | | # 获取板块强度数据 |
| | | elif url.path == "/load_get_kpl_market_sift_plate": |
| | | # 加载数据 |
| | | KPLStockOfMarketsPlateLogManager().load_data() |
| | | response_data = json.dumps({"code": 0, "msg": "暂无内容"}) |
| | | elif url.path == "/get_kpl_stock_of_markets_plate": |
| | | elif url.path == "/get_kpl_market_sift_plate": |
| | | # 获取开盘啦流入板块详细信息 |
| | | print("==========get_kpl_market_sift_plate==========") |
| | | try: |
| | | time_str = params_dict.get("time") |
| | | if not time_str: |
| | | time_str = tool.get_now_time_str() |
| | | fdatas = KPLStockOfMarketsPlateLogManager().get_filter_log_datas() |
| | | response_data = json.dumps({"code": 1, "msg": "暂无内容"}) |
| | | for i in range(len(fdatas) - 1, -1, -1): |
| | | if fdatas[i][0] <= time_str: |
| | | response_data = json.dumps({"code": 0, "data": fdatas[i]}) |
| | | break |
| | | except Exception as e: |
| | | logging.exception(e) |
| | | response_data = json.dumps({"code": 1, "msg": str(e)}) |
| | | |
| | | # 获取个股强度数据 |
| | | elif url.path == "/load_get_kpl_market_stock_heat": |
| | | # 加载数据 |
| | | KPLMarketStockHeatLogManager().load_data() |
| | | response_data = json.dumps({"code": 0, "msg": "暂无内容"}) |
| | | elif url.path == "/get_get_kpl_market_stock_heat": |
| | | # 获取开盘啦流入板块详细信息 |
| | | print("==========get_kpl_stock_of_markets_plate==========") |
| | | try: |
| | | time_str = params_dict.get("time") |
| | | if not time_str: |
| | | time_str = tool.get_now_time_str() |
| | | fdatas = KPLStockOfMarketsPlateLogManager().get_filter_log_datas() |
| | | fdatas = KPLMarketStockHeatLogManager().get_filter_log_datas() |
| | | response_data = json.dumps({"code": 1, "msg": "暂无内容"}) |
| | | for i in range(len(fdatas) - 1, -1, -1): |
| | | if fdatas[i][0] <= time_str: |
| | |
| | | return contents |
| | | |
| | | |
| | | def load_market_stock_heat(date=tool.get_now_date_str()): |
| | | """ |
| | | 获取精选流入的成分股 |
| | | :param date: |
| | | :return: |
| | | """ |
| | | path = f"{constant.get_path_prefix()}/low_suction_log/gp/kpl/market_sift_plate.{date}.log" |
| | | fdatas = [] |
| | | if os.path.exists(path): |
| | | with open(path, 'r', encoding="utf-8") as f: |
| | | lines = f.readlines() |
| | | for line in lines: |
| | | if line: |
| | | time_str = __get_async_log_time(line) |
| | | try: |
| | | data = line.split(" - ")[1].strip() |
| | | if data.startswith("["): |
| | | data = data[data.find("]") + 1:].strip() |
| | | data_dict = eval(data) |
| | | fdatas.append((time_str, data_dict)) |
| | | except: |
| | | pass |
| | | return fdatas |
| | | |
| | | |
| | | def load_stock_of_markets_plate(date=tool.get_now_date_str()): |
| | | """ |
| | | 获取精选流入的成分股 |
| | |
| | | |
| | | # 充分交易量公式 用于计算日内涨幅段理论的安全交易量值 |
| | | def sufficient_volume(current_volume, yesterday_volume, today_growth): |
| | | if current_volume < yesterday_volume * today_growth: |
| | | return False |
| | | else: |
| | | return True |
| | | if today_growth > 0: |
| | | if current_volume < yesterday_volume * today_growth: |
| | | return False |
| | | else: |
| | | return True |
| | | |
| | | |
| | | # 计算 委买和委卖的比例函数(获取买盘强度数据)【掘金数据结构】 |
| | |
| | | logger_info(f"重复相交概念==={intersection_plate}") |
| | | # 调用充分交易量函数 |
| | | sufficient_volume = basic_methods.sufficient_volume(current_volume, k_line_data[0]['volume'], today_growth) |
| | | logger_info(f"【{k_line_data[0]['sec_name']}】当日当时量是否相对涨幅充足?===【{sufficient_volume}】 !当日当时总成交量:{round(current_volume / 10000, 2)}万,昨日的总成交量{round(k_line_data[0]['volume'] / 10000, 2)}万,当日当时涨幅:{today_growth}%。") |
| | | logger_info(f"【{k_line_data[0]['sec_name']}】当日当时量是否相对涨幅充足?===【{sufficient_volume}】 !当时与昨日成交率占比:{round(current_volume/k_line_data[0]['volume'], 2)}%,当日当时总成交量:{round(current_volume / 10000, 2)}万,昨日的总成交量{round(k_line_data[0]['volume'] / 10000, 2)}万,当日当时涨幅:{today_growth}%。") |
| | | logger_info(f"【有概念】(涨停列表中包含自身概念 且 不是唯一包含概念不可用) !最新价: {current_price},,当日当时涨幅:{today_growth}%。") |
| | | # 有概念有强度视界 |
| | | if strength_list_have_it is True: |
| | | logger_info(f"【有概念 有强度】出现在板块强度大于2的列表中 瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,当日当时涨幅:{today_growth}%。") |
| | | if tick_growth < 0.8 and (free_market_value <= 100 and current_price <= 10): |
| | | logger_info(f"【有概念 有强度 有强拉】瞬时涨幅 > 0.8% !瞬时涨幅:{round(tick_growth, 2)}%") |
| | | if tick_growth < 0.5 and (free_market_value <= 100 and current_price <= 10): |
| | | logger_info(f"【有概念 有强度 无强拉】瞬时涨幅 < 0.5% !瞬时涨幅:{round(tick_growth, 2)}%") |
| | | return |
| | | if last_volume_to_growth_ratio > 0.8 and (free_market_value <= 100 and current_price <= 10): |
| | | logger_info(f"【不利】瞬时量幅比> 0.8 且 (小自由市值<40亿 或 最新价小于20元 )!,瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,自由市值:{free_market_value} 亿。") |
| | |
| | | from log_module import log_export, async_log_util |
| | | from log_module.log import logger_stock_of_markets_plate, logger_debug |
| | | from log_module.log import logger_stock_of_markets_plate, logger_debug, logger_kpl_market_sift_plate |
| | | from utils import tool |
| | | |
| | | # 开盘啦个股强度日志管理 |
| | | @tool.singleton |
| | | class KPLMarketStockHeatLogManager: |
| | | """ |
| | | 精选流入板块与板块代码日志管理 |
| | | """ |
| | | |
| | | def __init__(self): |
| | | # 过滤后的日志数据 |
| | | self.__filter_log_datas = [] |
| | | |
| | | def __load_data(self): |
| | | if tool.get_now_time_str() > '13:10:00': |
| | | logger_debug.info("KPLMarketStockHeatLogManager 开始加载数据") |
| | | datas = log_export.load_market_stock_heat() |
| | | for data in datas: |
| | | # (发生时间,[净流入板块], {"板块":(代码, 名称, 涨幅)}) |
| | | self.__filter_log_datas.append(self.__filter_origin_data(data)) |
| | | logger_debug.info("KPLMarketStockHeatLogManager 数据加载完成:{}", len(self.__filter_log_datas)) |
| | | |
| | | def load_data(self): |
| | | self.__load_data() |
| | | |
| | | def __filter_origin_data(self, data): |
| | | return (data[0], [x[1] for x in data[1][0]], |
| | | {p: [xx for xx in data[1][1][p]] for p in data[1][1]}) |
| | | |
| | | def add_log(self, in_plates_info, plate_codes_info): |
| | | oringin_data = (tool.get_now_time_str(), in_plates_info, plate_codes_info) |
| | | async_log_util.info(logger_kpl_market_sift_plate, f"{(oringin_data[1], oringin_data[2])}") |
| | | |
| | | def get_filter_log_datas(self): |
| | | return self.__filter_log_datas |
| | | |
| | | # 开盘啦个股强度日志管理 |
| | | @tool.singleton |
| | | class KPLStockOfMarketsPlateLogManager: |
| | | """ |
| | |
| | | # print(f"market_sift_plate 数 ======{len(market_sift_plate['list'])}") |
| | | |
| | | # 精选板块【前20】 market_sift_plate['list'] ====== |
| | | if data_cache.OPENING_TIME < now_time < data_cache.CLOSING_TIME: |
| | | if data_cache.OPENING_TIME < now_time < data_cache.AFTER_CLOSING_TIME: |
| | | logger_kpl_market_sift_plate.info(f"{market_sift_plate['list']}") |
| | | # 总控制时间段 |
| | | if not (data_cache.OPENING_TIME < now_time < data_cache.NOON_MARKET_TIME): |
| | | return |
| | | # ['801235', '化工', 6996, 0.027, 2.43, 117836347690, -122548038, 8105997595, -8228545633, 0.92, 8595377775454, 0.09, 332297449, 9954902621130, -192457252, 24.0487, 17.1809, 6996, 0.027] |
| | | # market_sift_plate['list'][0] = ['801062', '军工', 3520, -0.49, 0.666, 139133934669, 383864272, 9077352839, -8693488567, 1.183, 6129448037490,-0.12, 168245858, 7088854452019, -290614763, 50.2408, 30.3672, 3520, 0] |
| | | # 行情精选板块列表 前20 中的 第一个板块列表数据 = 【代码,板块名称,强度,涨幅?,0.666?,成交额?,现额?,主买,主卖,1.183?,流通值?,-0.12?,300W大单净额?,总市值?,上季度机构增仓,今年平均PE,次年平均PE,强度,未知0值】 |
| | | # 行情精选板块列表 前20 中的 第一个板块列表数据 = 【代码,板块名称,强度,涨幅?,量比?,成交额?,现额?,主买,主卖,1.183?,流通值?,-0.12?,300W大单净额?,总市值?,上季度机构增仓,今年平均PE,次年平均PE,强度,未知0值】 |
| | | # logger.info(f"market_sift_plate['list'][0] ======{market_sift_plate['list'][0]}") |
| | | # 初始化精选板块对应个股字典 |
| | | market_sift_plate_stock_dict = {} |