| | |
| | | __AccountAvailableMoneyManager = AccountAvailableMoneyManager() |
| | | __TradeBuyDataManager = trade_data_manager.TradeBuyDataManager() |
| | | __LimitUpTimeManager = limit_up_time_manager.LimitUpTimeManager() |
| | | __BlackListCodeManager = l2_trade_util.BlackListCodeManager() |
| | | __WhiteListCodeManager = l2_trade_util.WhiteListCodeManager() |
| | | __BlackListCodeManager = gpcode_manager.BlackListCodeManager() |
| | | __WhiteListCodeManager = gpcode_manager.WhiteListCodeManager() |
| | | __WantBuyCodesManager = gpcode_manager.WantBuyCodesManager() |
| | | __TradeTargetCodeModeManager = TradeTargetCodeModeManager() |
| | | __TradeOrderIdManager = trade_huaxin.TradeOrderIdManager() |
| | |
| | | HighIncreaseCodeManager().add_code(code) |
| | | return False, True, f"股价大于{constant.MAX_CODE_PRICE}块" |
| | | |
| | | place_order_count = cls.__PlaceOrderCountManager.get_place_order_count(code) |
| | | if place_order_count and place_order_count >= 10: |
| | | l2_trade_util.forbidden_trade(code, msg="当日下单次数已达10次") |
| | | return False, True, f"当日下单次数已达10次" |
| | | # place_order_count = cls.__PlaceOrderCountManager.get_place_order_count(code) |
| | | # if place_order_count and place_order_count >= 10: |
| | | # l2_trade_util.forbidden_trade(code, msg="当日下单次数已达10次") |
| | | # return False, True, f"当日下单次数已达10次" |
| | | |
| | | # ---------均价约束------------- |
| | | average_rate = cls.__Buy1PriceManager.get_average_rate(code) |
| | | if average_rate and average_rate <= 0.01: |
| | | return False, True, f"均价涨幅({average_rate})小于1%" |
| | | |
| | | # -------量的约束-------- |
| | | if float(limit_up_price) < 3.0 and cls.volume_rate_info[code][0] < 0.6: |
| | | return False, True, f"涨停价小于3块,当日量比({cls.volume_rate_info[code][0]})小于0.6" |
| | | |
| | | if HighIncreaseCodeManager().is_in(code) and cls.volume_rate_info[code][0] < 0.6: |
| | | return False, True, f"股价涨得过高,当日量比({cls.volume_rate_info[code][0]})小于0.6" |
| | | |
| | | if int(tool.get_now_time_str().replace(":", "")) <= int("100000"): |
| | | if cls.volume_rate_info[code][0] < 0.1: |
| | | return False, True, f"当日量比({cls.volume_rate_info[code][0]})小于0.1" |
| | | else: |
| | | if cls.volume_rate_info[code][0] < 0.2: |
| | | return False, True, f"当日量比({cls.volume_rate_info[code][0]})小于0.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]): |
| | | # 股价创新高或者逼近前高 |
| | | if cls.volume_rate_info[code][0] < 0.3: |
| | | return False, True, f"股价创新高或者逼近前高,当日量比({cls.volume_rate_info[code][0]})小于0.3" |
| | | if code_nature_analyse.LatestMaxVolumeManager().is_latest_max_volume(code): |
| | | # 最近几天有最大量,判断量比是否大于60% |
| | | if cls.volume_rate_info[code][0] < 0.6: |
| | | # HighIncreaseCodeManager().add_code(code) |
| | | return False, True, f"近日出现最大量,当日量比({cls.volume_rate_info[code][0]})小于0.6" |
| | | |
| | | total_data = local_today_datas.get(code) |
| | | if constant.L2_SOURCE_TYPE == constant.L2_SOURCE_TYPE_HUAXIN: |
| | |
| | | codes.discard(code) |
| | | if not codes: |
| | | return False, True, f"13:15以后炸板之后下单,({limit_up_reason}) 为独苗" |
| | | |
| | | # limit_up_info = cls.__Buy1PriceManager.get_limit_up_info(code) |
| | | # if limit_up_info[0] is None and False: |
| | | # total_data = local_today_datas.get(code) |
| | | # buy_single_index, buy_exec_index, buy_compute_index, num, count, max_num_set, buy_volume_rate = cls.__get_order_begin_pos( |
| | | # code) |
| | | # # 之前没有涨停过 |
| | | # # 统计买入信号位到当前位置没有撤的大单金额 |
| | | # min_money_w = l2_data_util.get_big_money_val(float(total_data[buy_single_index]["val"]["price"])) // 10000 |
| | | # left_big_num = cls.__SecondCancelBigNumComputer.compute_left_big_num(code, |
| | | # buy_single_index, |
| | | # buy_exec_index, |
| | | # total_data[-1][ |
| | | # "index"], |
| | | # total_data, |
| | | # 0, min_money_w) |
| | | # if left_big_num > 0: |
| | | # # 重新获取分数与分数索引 |
| | | # limit_up_time = cls.__LimitUpTimeManager.get_limit_up_time_cache(code) |
| | | # if limit_up_time is None: |
| | | # limit_up_time = tool.get_now_time_str() |
| | | |
| | | # logger_place_order_score.info("code={},data='score_index':{},'score_info':{}", code, |
| | | # cls.__l2PlaceOrderParamsManagerDict[code].score_index, |
| | | # cls.__l2PlaceOrderParamsManagerDict[code].score_info) |
| | | |
| | | if not cls.__WantBuyCodesManager.is_in_cache(code): |
| | | if cls.__TradeTargetCodeModeManager.get_mode_cache() == TradeTargetCodeModeManager.MODE_ONLY_BUY_WANT_CODES: |
| | | return False, True, f"只买想买单中的代码" |
| | | score_index = None # cls.__l2PlaceOrderParamsManagerDict[code].score_index |
| | | score = None # cls.__l2PlaceOrderParamsManagerDict[code].score |
| | | score_info = None # cls.__l2PlaceOrderParamsManagerDict[code].score_info |
| | | |
| | | # lp = LineProfiler() |
| | | # lp.enable() |
| | | # lp_wrap = lp(cls.can_buy_first) |
| | | # results = lp_wrap(code, limit_up_price, score_index, score, score_info, cls.volume_rate_info[code]) |
| | | # output = io.StringIO() |
| | | # lp.print_stats(stream=output) |
| | | # lp.disable() |
| | | # with open(f"{constant.get_path_prefix()}/logs/profile/{code}_can_buy_first.txt", 'w') as f: |
| | | # f.write(output.getvalue()) |
| | | # return results |
| | | # 暂时注释想买单功能 |
| | | # if not cls.__WantBuyCodesManager.is_in_cache(code): |
| | | # if cls.__TradeTargetCodeModeManager.get_mode_cache() == TradeTargetCodeModeManager.MODE_ONLY_BUY_WANT_CODES: |
| | | # return False, True, f"只买想买单中的代码" |
| | | return cls.can_buy_first(code, limit_up_price) |
| | | else: |
| | | return True, False, "在想买名单中" |
| | | # else: |
| | | # return True, False, "在想买名单中" |
| | | |
| | | # 获取可以买的板块 |
| | | @classmethod |
| | | def can_buy_first(cls, code, limit_up_price): |
| | | # 判断板块 |
| | | def __get_can_buy_block(cls, code): |
| | | can_buy_result = CodePlateKeyBuyManager.can_buy(code) |
| | | if can_buy_result is None: |
| | | async_log_util.warning(logger_debug, "没有获取到板块缓存,将获取板块") |
| | |
| | | block_info.get_before_blocks_dict(), |
| | | kpl_data_manager.KPLLimitUpDataRecordManager.get_current_reason_codes_dict()) |
| | | can_buy_result = CodePlateKeyBuyManager.can_buy(code) |
| | | return can_buy_result |
| | | |
| | | @classmethod |
| | | def can_buy_first(cls, code, limit_up_price): |
| | | # 判断板块 |
| | | can_buy_result = cls.__get_can_buy_block(code) |
| | | if can_buy_result is None: |
| | | return False, True, "尚未获取到板块信息" |
| | | |
| | | # -------量的约束-------- |
| | | k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code) |
| | | if k_format and (k_format[1][0] or k_format[3][0]): |
| | | # 股价创新高或者逼近前高 |
| | | if cls.volume_rate_info[code][0] < 0.3: |
| | | return False, True, f"股价创新高或者逼近前高,当日量比({cls.volume_rate_info[code][0]})小于0.3" |
| | | |
| | | # 如果是早上的强势后排就不需要判断量 |
| | | now_timestamp = int(tool.get_now_time_str().replace(":", "")) |
| | | if can_buy_result[0] and not can_buy_result[1] and now_timestamp <= int("094000"): |
| | | return True, False, f"9:40:00之前非独苗:{can_buy_result[0]}" |
| | | else: |
| | | if code in cls.volume_rate_info: |
| | | if float(limit_up_price) < 3.0 and cls.volume_rate_info[code][0] < 0.6: |
| | | return False, True, f"涨停价小于3块,当日量比({cls.volume_rate_info[code][0]})小于0.6" |
| | | |
| | | if HighIncreaseCodeManager().is_in(code) and cls.volume_rate_info[code][0] < 0.6: |
| | | return False, True, f"股价涨得过高,当日量比({cls.volume_rate_info[code][0]})小于0.6" |
| | | |
| | | if now_timestamp <= int("100000"): |
| | | if cls.volume_rate_info[code][0] < 0.1: |
| | | return False, True, f"当日量比({cls.volume_rate_info[code][0]})小于0.1" |
| | | else: |
| | | if cls.volume_rate_info[code][0] < 0.2: |
| | | return False, True, f"当日量比({cls.volume_rate_info[code][0]})小于0.2" |
| | | |
| | | if code_nature_analyse.LatestMaxVolumeManager().is_latest_max_volume(code): |
| | | # 最近几天有最大量,判断量比是否大于60% |
| | | if cls.volume_rate_info[code][0] < 0.6: |
| | | # HighIncreaseCodeManager().add_code(code) |
| | | return False, True, f"近日出现最大量,当日量比({cls.volume_rate_info[code][0]})小于0.6" |
| | | |
| | | if can_buy_result[1]: |
| | | # 独苗 |
| | | # ------自由流通市值约束------ |
| | | zyltgb = global_util.zyltgb_map.get(code) |
| | | if zyltgb: |
| | |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.6: |
| | | return False, True, f"独苗:量比({cls.volume_rate_info[code][0]})未达到60%" |
| | | |
| | | # 获取K线形态,判断是否近2天是否为10天内最大量 |
| | | k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code) |
| | | # 判断是否近2天是否为10天内最大量 |
| | | if k_format and len(k_format) >= 10 and k_format[9]: |
| | | # 是独苗 |
| | | if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.3: |
| | | return False, True, f"近2天有10日内最高量,量比({cls.volume_rate_info[code][0]})未达到30%" |
| | | |
| | | # 是独苗 |
| | | if can_buy_result[1]: |
| | | now_time_int = int(tool.get_now_time_str().replace(":", "")) |
| | | if now_time_int < int("100000") or int("130000") <= now_time_int < int("133000"): |
| | | if now_timestamp < int("100000") or int("130000") <= now_timestamp < int("133000"): |
| | | # 独苗必须9:30-10:00和13:00-13:30时间段内买 |
| | | return True, False, f"独苗:{can_buy_result[2]}" |
| | | else: |