| | |
| | | # 是否具有辨识度 |
| | | p9 = is_special(record_datas) |
| | | p10 = is_latest_10d_max_volume_at_latest_2d(record_datas) |
| | | # 最近5天是否跌停/炸板 |
| | | p11 = __is_latest_open_limit_up_or_limit_down(record_datas, 5) |
| | | # 最近5天是否炸板 |
| | | p11 = __is_latest_open_limit_up(record_datas, 5) |
| | | # 30天内是否有涨停 |
| | | p12 = __has_limit_up(record_datas, 30) |
| | | # 最近5天是否跌停 |
| | | p13 = __is_latest_limit_down(record_datas, 5) |
| | | |
| | | return p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12 |
| | | return p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13 |
| | | |
| | | |
| | | # 是否具有K线形态 |
| | | def is_has_k_format(limit_up_price, record_datas): |
| | | is_too_high, is_new_top, is_lowest, is_near_new_top, is_n, is_v, has_format, volume_info, is_special, has_max_volume, open_limit_up, is_limit_up_in_30days = get_k_format( |
| | | is_too_high, is_new_top, is_lowest, is_near_new_top, is_n, is_v, has_format, volume_info, is_special, has_max_volume, open_limit_up, is_limit_up_in_30days, is_latest_limit_down = get_k_format( |
| | | float(limit_up_price), record_datas) |
| | | if not has_format: |
| | | return False, "不满足K线形态" |
| | |
| | | |
| | | |
| | | # 最近几天是否有炸板或跌停 |
| | | def __is_latest_open_limit_up_or_limit_down(datas, day_count): |
| | | def __is_latest_open_limit_up(datas, day_count): |
| | | datas = copy.deepcopy(datas) |
| | | datas.sort(key=lambda x: x["bob"]) |
| | | items = datas[0 - day_count:] |
| | |
| | | if abs(limit_up_price - item["high"]) < 0.001 and abs(limit_up_price - item["close"]) > 0.001: |
| | | # 炸板 |
| | | return True |
| | | return False |
| | | |
| | | |
| | | def __is_latest_limit_down(datas, day_count): |
| | | datas = copy.deepcopy(datas) |
| | | datas.sort(key=lambda x: x["bob"]) |
| | | items = datas[0 - day_count:] |
| | | for item in items: |
| | | # 是否有跌停 |
| | | limit_down_price = float(gpcode_manager.get_limit_down_price_by_preprice(item["pre_close"])) |
| | | if abs(limit_down_price - item["close"]) < 0.001: |
| | |
| | | real_place_order_index = self.__real_place_order_index_dict.get(code) |
| | | total_datas = local_today_datas.get(code) |
| | | # 30s内有效 |
| | | if tool.trade_time_sub(total_datas[end_index]["val"]["time"], total_datas[buy_exec_index]["val"]["time"]) > 30: |
| | | return False, None, "下单30s内才生效" |
| | | if tool.trade_time_sub(total_datas[end_index]["val"]["time"], total_datas[buy_exec_index]["val"]["time"]) > 15: |
| | | return False, None, "下单15s内才生效" |
| | | |
| | | for i in range(start_index, end_index + 1): |
| | | data = total_datas[i] |
| | |
| | | __L2LimitUpSellManager = L2LimitUpSellManager() |
| | | __PlaceOrderCountManager = PlaceOrderCountManager() |
| | | __CodeNatureRecordManager = code_nature_analyse.CodeNatureRecordManager() |
| | | __MarketSituationManager=MarketSituationManager() |
| | | __MarketSituationManager = MarketSituationManager() |
| | | |
| | | # 获取代码评分 |
| | | @classmethod |
| | |
| | | if can_buy_result is None: |
| | | return False, True, "尚未获取到板块信息" |
| | | # -------量的约束-------- |
| | | volume_rate_thresholds = buy_condition_util.get_volume_rate_by_level( |
| | | 1), buy_condition_util.get_volume_rate_by_level(2) |
| | | |
| | | k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code) |
| | | if k_format and (k_format[1][0] or k_format[3][0]) and len(k_format) >= 12 and k_format[11]: |
| | | # 破前高/接近前高且30天内有涨停 |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6: |
| | | return False, True, f"股价创新高或者逼近前高且30天内有涨停,当日量比({cls.volume_rate_info[code][0]})小于0.6" |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[1]: |
| | | return False, True, f"股价创新高或者逼近前高且30天内有涨停,当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[1]}" |
| | | |
| | | # 上5个交易日有炸板/跌停之后 |
| | | # 上5个交易日有炸板之后 |
| | | if k_format and len(k_format) >= 11 and k_format[10]: |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6: |
| | | return False, True, f"上5个交易日炸板/跌停,量未达到60%({cls.volume_rate_info[code][0]})" |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[1]: |
| | | return False, True, f"上5个交易日炸板,量未达到{volume_rate_thresholds[1]}({cls.volume_rate_info[code][0]})" |
| | | |
| | | # 上5个交易日有跌停 |
| | | if k_format and len(k_format) >= 13 and k_format[12]: |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.29: |
| | | return False, True, f"上5个交易日跌停,量未达到{0.29}({cls.volume_rate_info[code][0]})" |
| | | |
| | | # 获取量的参考日期 |
| | | if code in global_util.max60_volumn: |
| | | day = global_util.max60_volumn[code][1] |
| | | if day in HistoryKDatasUtils.get_latest_trading_date_cache(5): |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6: |
| | | return False, True, f"参考量在最近5天,量未达到60%({cls.volume_rate_info[code][0]})" |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[1]: |
| | | return False, True, f"参考量在最近5天,量未达到{volume_rate_thresholds[1]}({cls.volume_rate_info[code][0]})" |
| | | # 获取市场行情 |
| | | situation = cls.__MarketSituationManager.get_situation_cache() |
| | | zylt_threshold = buy_condition_util.get_zyltgb_threshold(situation) |
| | |
| | | zyltgb = zylt_threshold[1] + 1 |
| | | |
| | | if zyltgb >= zylt_threshold[0]: |
| | | return False, True, f"{zylt_threshold[0]//100000000}亿以上的都不买({zyltgb})" |
| | | return False, True, f"{zylt_threshold[0] // 100000000}亿以上的都不买({zyltgb})" |
| | | |
| | | if HighIncreaseCodeManager().is_in(code): |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.8: |
| | |
| | | if not can_buy_result[0] and can_buy_result[1]: |
| | | msg_list.append("独苗") |
| | | if zyltgb < zylt_threshold[1] or zyltgb > zylt_threshold[2]: |
| | | return False, True, f"强势10分钟,独苗({can_buy_result[4]})不下单({can_buy_result[4]})自由流通市值({zyltgb})不满足条件" |
| | | # 如果没有辨识度才不买 |
| | | if k_format and k_format[8][0]: |
| | | # 有辨识度 |
| | | pass |
| | | else: |
| | | return False, True, f"强势10分钟,独苗({can_buy_result[4]})不下单({can_buy_result[4]})自由流通市值({zyltgb})不满足条件" |
| | | if k_format and (k_format[1][0] or k_format[3][0]): |
| | | msg_list.append("股价创新高或者逼近前高") |
| | | # 股价创新高或者逼近前高 |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6: |
| | | return False, True, f"强势10分钟,独苗({can_buy_result[4]}),股价创新高或者逼近前高,当日量比({cls.volume_rate_info[code][0]})小于0.6" |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[1]: |
| | | return False, True, f"强势10分钟,独苗({can_buy_result[4]}),股价创新高或者逼近前高,当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[1]}" |
| | | else: |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.3: |
| | | return False, True, f"强势10分钟,独苗({can_buy_result[4]}),当日量比({cls.volume_rate_info[code][0]})小于0.3" |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[0]: |
| | | return False, True, f"强势10分钟,独苗({can_buy_result[4]}),当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[0]}" |
| | | else: |
| | | msg_list.append("非独苗") |
| | | if zyltgb < zylt_threshold[1] or zyltgb > zylt_threshold[2]: |
| | | msg_list.append("不满足自由流通") |
| | | if k_format and (k_format[1][0] or k_format[3][0]): |
| | | # 股价创新高或者逼近前高 |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6: |
| | | return False, True, f"强势10分钟,后排,不满足自由市值,股价创新高或者逼近前高,当日量比({cls.volume_rate_info[code][0]})小于0.6" |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[1]: |
| | | return False, True, f"强势10分钟,后排,不满足自由市值,股价创新高或者逼近前高,当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[1]}" |
| | | else: |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.3: |
| | | return False, True, f"强势10分钟,后排,不满足自由市值,当日量比({cls.volume_rate_info[code][0]})小于0.3" |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[0]: |
| | | return False, True, f"强势10分钟,后排,不满足自由市值,当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[0]}" |
| | | else: |
| | | msg_list.append("满足自由流通") |
| | | # 后排,满足自由流通市值需要下单 |
| | |
| | | if zyltgb < zylt_threshold[1] or zyltgb > zylt_threshold[2]: |
| | | if k_format and (k_format[1][0] or k_format[3][0]): |
| | | # 股价创新高或者逼近前高 |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6: |
| | | return False, True, f"非强势10分钟,强势主线后排,不满足自由市值,股价创新高或者逼近前高,当日量比({cls.volume_rate_info[code][0]})小于0.6" |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[1]: |
| | | return False, True, f"非强势10分钟,强势主线后排,不满足自由市值,股价创新高或者逼近前高,当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[1]}" |
| | | else: |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.3: |
| | | return False, True, f"非强势10分钟,强势主线后排,不满足自由市值,当日量比({cls.volume_rate_info[code][0]})小于0.3" |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[0]: |
| | | return False, True, f"非强势10分钟,强势主线后排,不满足自由市值,当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[0]}" |
| | | else: |
| | | if k_format and (k_format[1][0] or k_format[3][0]): |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.3: |
| | | return False, True, f"非强势10分钟,强势主线后排,满足自由市值,股价创新高或者逼近前高, 当日量比({cls.volume_rate_info[code][0]})小于0.3" |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[0]: |
| | | return False, True, f"非强势10分钟,强势主线后排,满足自由市值,股价创新高或者逼近前高, 当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[0]}" |
| | | else: |
| | | # 非强势主线 |
| | | if zyltgb < zylt_threshold[1] or zyltgb > zylt_threshold[2]: |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6: |
| | | return False, True, f"非强势10分钟,非强势主线后排,不满足自由市值, 当日量比({cls.volume_rate_info[code][0]})小于0.6" |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[1]: |
| | | return False, True, f"非强势10分钟,非强势主线后排,不满足自由市值, 当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[1]}" |
| | | else: |
| | | if k_format and (k_format[1][0] or k_format[3][0]): |
| | | # 股价创新高或者逼近前高 |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6: |
| | | return False, True, f"非强势10分钟,非强势主线后排,满足自由市值,股价创新高或者逼近前高, 当日量比({cls.volume_rate_info[code][0]})小于0.6" |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[1]: |
| | | return False, True, f"非强势10分钟,非强势主线后排,满足自由市值,股价创新高或者逼近前高, 当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[1]}" |
| | | else: |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.3: |
| | | return False, True, f"非强势10分钟,非强势主线后排, 满足自由市值,当日量比({cls.volume_rate_info[code][0]})小于0.3" |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[0]: |
| | | return False, True, f"非强势10分钟,非强势主线后排, 满足自由市值,当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[0]}" |
| | | return True, False, can_buy_result[2] |
| | | |
| | | @classmethod |
| | |
| | | # 获取涨停原因下面的代码 |
| | | ps_dict = dict([(k, v[0]) for k, v in parse_qs(url.query).items()]) |
| | | plate = ps_dict["plate"] |
| | | plate = plate.replace("概念","") |
| | | # 获取板块下的代码 |
| | | # 统计目前为止的代码涨停数量(分涨停原因) |
| | | now_limit_up_codes_info = self.__kplDataManager.get_data(KPLDataType.LIMIT_UP) |
| | |
| | | # 代码,名称,涨停时间,是否炸板,是否想买,是否已经下过单 |
| | | codes_info.append( |
| | | [d[3], d[4], tool.to_time_str(int(d[5])), 1 if d[3] not in now_limit_up_codes else 0, 0, 0, d[12], |
| | | output_util.money_desc(d[13])]) |
| | | output_util.money_desc(d[13]), 1]) |
| | | |
| | | for d in record_limit_up_datas: |
| | | if d[2] == plate: |
| | | continue |
| | | if plate not in d[6].split("、"): |
| | | continue |
| | | # 代码,名称,涨停时间,是否炸板,是否想买,是否已经下过单 |
| | | codes_info.append( |
| | | [d[3], d[4], tool.to_time_str(int(d[5])), 1 if d[3] not in now_limit_up_codes else 0, 0, 0, d[12], |
| | | output_util.money_desc(d[13]), 0]) |
| | | |
| | | codes_info.sort(key=lambda x: x[2]) |
| | | # 查询是否为想买单 |
| | | want_codes = gpcode_manager.WantBuyCodesManager().list_code_cache() |
| | |
| | | from trade.trade_manager import MarketSituationManager |
| | | |
| | | |
| | | # 获取自由流通市值的阈值范围 |
| | | def get_zyltgb_threshold(market_sitation: int): |
| | | if market_sitation == MarketSituationManager.SITUATION_GOOD: |
| | | return 100 * 100000000, 20 * 100000000, 60 * 100000000 |
| | | return 100 * 100000000, 10 * 100000000, 50 * 100000000 |
| | | return 50 * 100000000, 10 * 100000000, 20 * 100000000 |
| | | |
| | | return 40 * 100000000, 10 * 100000000, 20 * 100000000 |
| | | |
| | | # 获取量比的等级获取量 |
| | | def get_volume_rate_by_level(level: int): |
| | | volume_rates = [0, 0.19, 0.49, 0.89] |
| | | return volume_rates[level] |
| | | |