人为设置累计大单阈值时,如果不够移红/没加红的撤单率以人为的撤单率为准
| | |
| | | client_id, |
| | | request_id) |
| | | return |
| | | TotalDealBigOrderThresholdMoneyManager().set_money(code, int(money)) |
| | | TotalDealBigOrderThresholdMoneyManager().set_money(code, int(money), trade_manager.CodesTradeStateManager().get_trade_state_cache(code)) |
| | | |
| | | # 如果是加红状态,且大单不够就需要移红 |
| | | if gpcode_manager.MustBuyCodesManager().is_in_cache(code): |
| | | deal_big_order_info = radical_buy_data_manager.get_total_deal_big_order_info(code, gpcode_manager.get_limit_up_price_as_num(code)) |
| | | if deal_big_order_info[0] > 0: |
| | | gpcode_manager.MustBuyCodesManager().remove_code(code) |
| | | trade_record_log_util.add_common_msg(code, "移红", f"大单阈值修改({money})") |
| | | self.send_response({"code": 0, "data": {}}, |
| | | client_id, |
| | | request_id) |
| | |
| | | human_rate = 0 |
| | | if must_buy: |
| | | # 扫入加红 |
| | | return max(constant.L_CANCEL_RATE_WITH_MUST_BUY_FOR_REDICAL_BUY, human_rate), True, (constant.L_CANCEL_RATE_WITH_MUST_BUY_FOR_REDICAL_BUY, human_rate) |
| | | return max(constant.L_CANCEL_RATE_WITH_MUST_BUY_FOR_REDICAL_BUY, human_rate), True, ( |
| | | constant.L_CANCEL_RATE_WITH_MUST_BUY_FOR_REDICAL_BUY, human_rate) |
| | | else: |
| | | deal_big_order_info = radical_buy_data_manager.get_total_deal_big_order_info(code, |
| | | gpcode_manager.get_limit_up_price_as_num( |
| | |
| | | if deal_big_order_info[0] <= 0: |
| | | # 大单足够,将基础比例调整至79% |
| | | threshold_rate = max(threshold_rate, 0.79) |
| | | return max(threshold_rate, human_rate), False, (threshold_rate, human_rate) |
| | | return human_rate if human_rate > 0 else threshold_rate, False, (threshold_rate, human_rate) |
| | | else: |
| | | deal_rate = round(deal_big_order_info[1] / deal_big_order_info[2], 2) |
| | | threshold_rate = 0.5 * deal_rate + 0.35 |
| | |
| | | if deal_big_order_info[0] <= 0: |
| | | # 大单足够,将基础比例调整至79% |
| | | threshold_rate = max(threshold_rate, 0.79) |
| | | return max(threshold_rate, human_rate), False, (threshold_rate, human_rate) |
| | | return human_rate if human_rate > 0 else threshold_rate, False, (threshold_rate, human_rate) |
| | | if must_buy: |
| | | if is_up: |
| | | return constant.L_CANCEL_RATE_UP_WITH_MUST_BUY, True, None |
| | |
| | | __instance = None |
| | | __today_volumn_cache = {} |
| | | __reference_volume_as_money_y_dict = {} |
| | | __max_volume_in_5days = {} |
| | | __max_volume_info_in_5days = {} |
| | | |
| | | def __new__(cls, *args, **kwargs): |
| | | if not cls.__instance: |
| | |
| | | for k in keys: |
| | | code = k.split("-")[1] |
| | | global_util.yesterday_volumn[code] = RedisUtils.get(redis, k, auto_free=False) |
| | | keys = RedisUtils.keys(redis, "volumn_max_5days-*", auto_free=False) |
| | | keys = RedisUtils.keys(redis, "volumn_max_5days_info-*", auto_free=False) |
| | | if keys is not None: |
| | | for k in keys: |
| | | code = k.split("-")[1] |
| | | val = RedisUtils.get(redis, k, auto_free=False) |
| | | cls.__max_volume_in_5days[code] = int(val) |
| | | cls.__max_volume_info_in_5days[code] = json.loads(val) |
| | | finally: |
| | | RedisUtils.realse(redis) |
| | | |
| | | # 设置历史量 |
| | | def set_histry_volumn(self, code, max60, yesterday, max60_day, max60_day_count, max5_volume): |
| | | def set_histry_volumn(self, code, max60, yesterday, max60_day, max60_day_count, max5_volume, max5_volume_day): |
| | | redis = self.__redis_manager.getRedis() |
| | | global_util.max60_volumn[code] = (max60, max60_day, max60_day_count) |
| | | global_util.yesterday_volumn[code] = yesterday |
| | | self.__save_max_volume_in_5days(code, max5_volume) |
| | | self.__save_max_volume_in_5days(code, max5_volume, max5_volume_day) |
| | | try: |
| | | RedisUtils.setex_async(self.__db, "volumn_max60-{}".format(code), tool.get_expire(), |
| | | json.dumps((max60, max60_day, max60_day_count)), |
| | |
| | | finally: |
| | | RedisUtils.realse(redis) |
| | | |
| | | def __save_max_volume_in_5days(self, code, volume): |
| | | self.__max_volume_in_5days[code] = volume |
| | | RedisUtils.setex_async(self.__db, "volumn_max_5days-{}".format(code), tool.get_expire(), volume, |
| | | def __save_max_volume_in_5days(self, code, volume, day): |
| | | self.__max_volume_info_in_5days[code] = (volume, day) |
| | | RedisUtils.setex_async(self.__db, "volumn_max_5days_info-{}".format(code), tool.get_expire(), json.dumps((volume, day)), |
| | | auto_free=False) |
| | | |
| | | def get_max_volume_in_5days(self, code): |
| | |
| | | @param code: |
| | | @return: |
| | | """ |
| | | return self.__max_volume_in_5days.get(code) |
| | | if code in self.__max_volume_info_in_5days: |
| | | return self.__max_volume_info_in_5days.get(code)[0] |
| | | return None |
| | | |
| | | def get_radical_buy_refer_volume(self, code, limit_up_price): |
| | | """ |
| | |
| | | return volume |
| | | return int(self.get_reference_volume_as_money_y(code) * 1e8 / limit_up_price) |
| | | |
| | | def get_radical_buy_refer_volume_info(self, code, limit_up_price): |
| | | """ |
| | | TODO 更改正确 |
| | | 获取扫入的参考量: |
| | | 参考额小于3.14亿就取90天参考量 |
| | | 否则就取最近5天的参考量 |
| | | @param code: |
| | | @param limit_up_price: |
| | | @return: |
| | | """ |
| | | # 60个交易日未涨停取 |
| | | k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code) |
| | | has_limit_up_in_60 = True |
| | | if k_format and not k_format[13]: |
| | | has_limit_up_in_60 = False |
| | | volume_info = self.__max_volume_info_in_5days.get(code, None) |
| | | if volume_info and volume_info[0] * limit_up_price >= 9e8 and has_limit_up_in_60: |
| | | return volume_info |
| | | return int(self.get_reference_volume_as_money_y(code) * 1e8 / limit_up_price) |
| | | |
| | | def get_volume_rate_refer_in_5days(self, code, total_sell_volume=0): |
| | | """ |
| | | 获取今日量与5日最大量的参考值 |
| | |
| | | if not volumes_data: |
| | | continue |
| | | volumes = init_data_util.parse_max_volume_new(code, volumes_data[:60]) |
| | | max_volume_in_5_days = init_data_util.parse_max_volume_in_days(volumes_data, 5) |
| | | max_volume_in_5_days, max_volume_day_in_5_days = init_data_util.parse_max_volume_in_days(volumes_data, 5) |
| | | |
| | | async_log_util.info(logger_first_code_record, f"{code} 获取到首板60天最大量:{volumes}") |
| | | code_volumn_manager.CodeVolumeManager().set_histry_volumn(code, volumes[0], volumes[1], volumes[2], |
| | | volumes[3], max_volume_in_5_days) |
| | | volumes[3], max_volume_in_5_days, |
| | | max_volume_day_in_5_days) |
| | | |
| | | # 保存K线形态 |
| | | k_format = code_nature_analyse.get_k_format(code, limit_up_price, volumes_data) |
| | |
| | | """ |
| | | __db = 3 |
| | | __redis_manager = redis_manager.RedisManager(3) |
| | | # (金额, 当时的交易状态) |
| | | __total_big_order_threshold = {} |
| | | |
| | | def __init__(self): |
| | |
| | | return self.__redis_manager.getRedis() |
| | | |
| | | def __load_data(self): |
| | | keys = redis_manager.RedisUtils.keys(self.__get_redis(), "total_radical_big_order_threshold-*") |
| | | keys = redis_manager.RedisUtils.keys(self.__get_redis(), "total_radical_big_order_threshold_info-*") |
| | | for k in keys: |
| | | code = k.split("-")[1] |
| | | val = redis_manager.RedisUtils.get(self.__get_redis(), k) |
| | | val = int(val) |
| | | if val: |
| | | val = json.loads(val) |
| | | self.__total_big_order_threshold[code] = val |
| | | |
| | | def set_money(self, code, money): |
| | | def set_money(self, code, money, trade_state): |
| | | """ |
| | | 设置金额 |
| | | @param trade_state: 当时代码的交易状态 |
| | | @param code: |
| | | @param money: |
| | | @return: |
| | | """ |
| | | self.__total_big_order_threshold[code] = money |
| | | redis_manager.RedisUtils.setex_async(self.__db, f"total_radical_big_order_threshold-{code}", tool.get_expire(), |
| | | money) |
| | | self.__total_big_order_threshold[code] = (money, trade_state) |
| | | redis_manager.RedisUtils.setex_async(self.__db, f"total_radical_big_order_threshold_info-{code}", |
| | | tool.get_expire(), |
| | | json.dumps((money, trade_state))) |
| | | |
| | | def get_money_cache(self, code): |
| | | """ |
| | | 获取缓存 |
| | | @param code: |
| | | @return: |
| | | """ |
| | | if code in self.__total_big_order_threshold: |
| | | return self.__total_big_order_threshold.get(code)[0] |
| | | return None |
| | | |
| | | def get_money_info_cache(self, code): |
| | | """ |
| | | 获取缓存 |
| | | @param code: |
| | |
| | | if WantBuyCodesManager().is_in_cache(code): |
| | | if total_deal_big_order_result[0] <= 0: |
| | | # 累计大单足够需要加红 |
| | | human_setting_money = TotalDealBigOrderThresholdMoneyManager().get_money_cache(code) |
| | | if not human_setting_money: |
| | | # 没有人为设置累计大单阈值就不能加白 |
| | | human_setting_money_info = TotalDealBigOrderThresholdMoneyManager().get_money_info_cache(code) |
| | | if not human_setting_money_info or not trade_util.is_delegated(human_setting_money_info[1]): |
| | | # 没有人为设置累计大单阈值/不是在下单状态设置的 就不能加白 |
| | | return |
| | | gpcode_manager.MustBuyCodesManager().add_code(code) |
| | | trade_record_log_util.add_must_buy(code, "累计成交大单足够") |
| | |
| | | if not trade_util.is_delegated(trade_state): |
| | | # 没下单 |
| | | return |
| | | human_setting_money = TotalDealBigOrderThresholdMoneyManager().get_money_cache(code) |
| | | if not human_setting_money: |
| | | # 没有人为设置累计大单阈值就不能加白 |
| | | human_setting_money_info = TotalDealBigOrderThresholdMoneyManager().get_money_info_cache(code) |
| | | if not human_setting_money_info or not trade_util.is_delegated(human_setting_money_info[1]): |
| | | # 没有人为设置累计大单阈值/不是在下单状态设置的 就不能加白 |
| | | return |
| | | try: |
| | | total_deal_big_order_result = get_total_deal_big_order_info(code, |
| | |
| | | return |
| | | |
| | | if not gpcode_manager.MustBuyCodesManager().is_in_cache(code): |
| | | human_setting_money = TotalDealBigOrderThresholdMoneyManager().get_money_cache(code) |
| | | if not human_setting_money: |
| | | # 没有人为设置累计大单阈值就不能加白 |
| | | human_setting_money_info = TotalDealBigOrderThresholdMoneyManager().get_money_info_cache(code) |
| | | if not human_setting_money_info or not trade_util.is_delegated(human_setting_money_info[1]): |
| | | # 没有人为设置累计大单阈值/不是在下单状态设置的 就不能加白 |
| | | return |
| | | gpcode_manager.MustBuyCodesManager().add_code(code) |
| | | trade_record_log_util.add_must_buy(code, "大单足够") |
| | |
| | | |
| | | # 判断是否可以扫入, 暂时都不可扫入 |
| | | can_direct_buy = False |
| | | human_setting_money = TotalDealBigOrderThresholdMoneyManager().get_money_cache(code) |
| | | if human_setting_money: |
| | | # 自由市值80亿以上不扫 |
| | | # zyltgb = global_util.zyltgb_map.get( |
| | | # code) |
| | | # if zyltgb and zyltgb < 80e8: |
| | | # can_direct_buy = True |
| | | pass |
| | | # human_setting_money = TotalDealBigOrderThresholdMoneyManager().get_money_cache(code) |
| | | # if human_setting_money: |
| | | # # 自由市值80亿以上不扫 |
| | | # # zyltgb = global_util.zyltgb_map.get( |
| | | # # code) |
| | | # # if zyltgb and zyltgb < 80e8: |
| | | # # can_direct_buy = True |
| | | # pass |
| | | |
| | | # 获取参考总卖额 |
| | | refer_sell_data = L2MarketSellManager().get_refer_sell_data(code, l2_huaxin_util.convert_time( |
| | |
| | | if d["volume"] > max_volume_info[0]: |
| | | max_volume_info = (d["volume"], d) |
| | | if max_volume_info: |
| | | return max_volume_info[0] |
| | | return None |
| | | return max_volume_info[0], max_volume_info[1]['bob'].strftime("%Y-%m-%d") |
| | | return None, None |
| | | |
| | | |
| | | # 返回:(60天最大量,昨日量,量参考日期,参考量据今交易日数) |