| | |
| | | # 处理首板代码信息 |
| | | |
| | | import constant |
| | | import inited_data |
| | | from code_attribute import gpcode_manager, gpcode_first_screen_manager, code_nature_analyse, \ |
| | | code_volumn_manager |
| | | from code_attribute.code_data_util import ZYLTGBUtil |
| | |
| | | from third_data.history_k_data_util import HistoryKDatasUtils |
| | | from ths import l2_code_operate |
| | | from trade import trade_data_manager, l2_trade_util |
| | | from utils import global_util, tool |
| | | from utils import global_util, tool, init_data_util |
| | | |
| | | __CodesPlateKeysManager = CodesHisReasonAndBlocksManager() |
| | | |
| | |
| | | def process_first_codes_datas(dataList, request_id=None): |
| | | logger_l2_codes_subscript.info(f"{request_id}加载l2代码相关数据") |
| | | print("首板代码数量:", len(dataList)) |
| | | # 获取最近5天的交易日期,为后面的数据计算做准备 |
| | | HistoryKDatasUtils.get_latest_trading_date_cache(5) |
| | | limit_up_price_dict = {} |
| | | temp_codes = [] |
| | | codes = [] |
| | |
| | | # 获取涨停价 |
| | | _limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | if not _limit_up_price: |
| | | inited_data.re_set_price_pres([code], True) |
| | | init_data_util.re_set_price_pres([code], True) |
| | | # 再次获取涨停价 |
| | | _limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | if _limit_up_price: |
| | |
| | | for code in codes: |
| | | # 如果涨停价是空值就需要设置昨日收盘价格 |
| | | if gpcode_manager.get_limit_up_price(code) is None: |
| | | inited_data.re_set_price_pres([code], True) |
| | | init_data_util.re_set_price_pres([code], True) |
| | | |
| | | # 板块关键字准备 暂时删除 |
| | | # for code in codes: |
| | |
| | | # 获取60天最大记录 |
| | | for code in codes: |
| | | need_get_volumn = False |
| | | if code not in global_util.max60_volumn or global_util.max60_volumn.get(code) is None: |
| | | if code not in global_util.max60_volumn or global_util.max60_volumn.get( |
| | | code) is None or code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code) is None: |
| | | need_get_volumn = True |
| | | # if not need_get_volumn and code_nature_analyse.CodeNatureRecordManager.get_nature_cache( |
| | | # code) is None: |
| | |
| | | if limit_up_price is None: |
| | | continue |
| | | try: |
| | | volumes_data = inited_data.get_volumns_by_code(code, 150) |
| | | volumes = inited_data.parse_max_volume(volumes_data[:90], |
| | | code_nature_analyse.is_new_top( |
| | | limit_up_price, |
| | | volumes_data[:90])) |
| | | volumes_data = init_data_util.get_volumns_by_code(code, 150) |
| | | volumes = init_data_util.parse_max_volume(volumes_data[:90], |
| | | code_nature_analyse.is_new_top( |
| | | limit_up_price, |
| | | volumes_data[:90]) or code_nature_analyse.is_near_top( |
| | | limit_up_price, |
| | | volumes_data[:90])) |
| | | logger_first_code_record.info("{} 获取到首板60天最大量:{}", code, volumes) |
| | | code_volumn_manager.set_histry_volumn(code, volumes[0], volumes[1], volumes[2]) |
| | | if code_nature_analyse.is_up_too_high_in_10d(volumes_data): |
| | | |
| | | # 保存K线形态 |
| | | k_format = code_nature_analyse.get_k_format(limit_up_price, volumes_data) |
| | | code_nature_analyse.CodeNatureRecordManager().save_k_format(code, k_format) |
| | | |
| | | if code_nature_analyse.is_up_too_high_in_10d_with_limit_up(volumes_data): |
| | | # 判断是否太高 |
| | | l2_trade_util.forbidden_trade(code, "股价长得太高") |
| | | # l2_trade_util.forbidden_trade(code, "股价长得太高(5天内有3个涨停)") |
| | | HighIncreaseCodeManager().add_code(code) |
| | | |
| | | if code_nature_analyse.is_up_too_high_in_120d(volumes_data): |
| | | # 判断是否太高 |
| | | l2_trade_util.forbidden_trade(code, "120天内股价长得太高") |
| | | HighIncreaseCodeManager().add_code(code) |
| | | # l2_trade_util.forbidden_trade(code, "120天内股价长得太高") |
| | | # HighIncreaseCodeManager().add_code(code) |
| | | pass |
| | | |
| | | if code_nature_analyse.is_price_too_high_in_days(volumes_data, limit_up_price): |
| | | # 判断是否太高 |
| | | l2_trade_util.forbidden_trade(code, "6天内股价长得太高") |
| | | |
| | | if code_nature_analyse.is_continue_limit_up_not_enough_fall_dwon(volumes_data): |
| | | # 判断是否太高 |
| | | l2_trade_util.forbidden_trade(code, "回踩不够") |
| | | |
| | | if code_nature_analyse.is_have_latest_max_volume(volumes_data, 2): |
| | | # 最近2天是否是最高量 |
| | |
| | | # volumes_data) |
| | | except Exception as e: |
| | | logger_first_code_record.error(f"{code}:{str(e)}") |
| | | logger_first_code_record.exception(e) |
| | | gpcode_manager.FirstCodeManager().add_record(codes) |
| | | # 初始化板块信息,暂时删除 |
| | | # for code in codes: |
| | |
| | | # 获取涨停价 |
| | | if temp_codes: |
| | | # 获取涨停价 |
| | | inited_data.re_set_price_pres(temp_codes) |
| | | init_data_util.re_set_price_pres(temp_codes) |
| | | # 重新获取涨停价 |
| | | for code in temp_codes: |
| | | limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | |
| | | gpcode_manager.FirstCodeManager().add_limited_up_record([code]) |
| | | pricePre = gpcode_manager.CodePrePriceManager.get_price_pre_cache(code) |
| | | if pricePre is None: |
| | | inited_data.re_set_price_pres([code]) |
| | | init_data_util.re_set_price_pres([code]) |
| | | |
| | | rate = round((float(price) - pricePre) * 100 / pricePre, 1) |
| | | prices.append( |
| | | {"code": code, "time": limit_up_time, "rate": rate, |
| | | "limit_up": is_limit_up}) |
| | | if code in new_add_codes: |
| | | if is_limit_up: |
| | | place_order_count = trade_data_manager.PlaceOrderCountManager().get_place_order_count( |
| | | code) |
| | | if place_order_count == 0: |
| | | trade_data_manager.PlaceOrderCountManager().place_order(code) |
| | | |
| | | gpcode_first_screen_manager.process_ticks(prices) |
| | | logger_l2_codes_subscript.info(f"({request_id})l2代码相关数据加载完成") |