| | |
| | | redis_manager.RedisUtils.setex_async(self.__db, f"radical_big_sell_order_threshold-{code}", tool.get_expire(), |
| | | f"{threshold_money}") |
| | | |
| | | @classmethod |
| | | def compute_re_limit_up_big_money_threshold(cls, limit_up_price_money_list): |
| | | """ |
| | | 获取回封的大单阈值 |
| | | @param limit_up_price_money_list: |
| | | @return: |
| | | """ |
| | | average_money = sum(limit_up_price_money_list) // len(limit_up_price_money_list) |
| | | max_money = max(limit_up_price_money_list) |
| | | # 取max((平均值+最大单一半)/2, 平均值) |
| | | threshold_money = max((max_money // 2 + average_money) // 2, average_money) |
| | | return threshold_money |
| | | |
| | | def set_big_deal_order_list(self, code, buy_money_list, sell_money_list, limit_up_price): |
| | | """ |
| | | 设置大单成交数据 |
| | |
| | | total_deal_buy_money += info[0] |
| | | total_deal_buy_money_info_list.append(info) |
| | | if limit_up_price_money_list: |
| | | # 计算大单的阈值 |
| | | average_money = sum(limit_up_price_money_list) // len(limit_up_price_money_list) |
| | | max_money = max(limit_up_price_money_list) |
| | | # 取max((平均值+最大单一半)/2, 平均值) |
| | | threshold_money = max((max_money // 2 + average_money) // 2, average_money) |
| | | threshold_money = self.compute_re_limit_up_big_money_threshold(limit_up_price_money_list) |
| | | self.set_big_order_threshold(code, threshold_money) |
| | | self.__already_total_deal_big_order_money[code] = (total_deal_buy_money, pre_limit_up_price_money_list) |
| | | async_log_util.info(logger_l2_radical_buy_data, |
| | |
| | | return buy_money, before_buy_money, sell_money, before_sell_money |
| | | |
| | | |
| | | def compute_total_deal_big_order_threshold_money(code, limit_up_price, threshold_money_per_order): |
| | | """ |
| | | 计算累计大单足够的阈值 |
| | | @param code: |
| | | @param limit_up_price: |
| | | @param threshold_money_per_order: 均大单阈值 |
| | | @return: |
| | | """ |
| | | |
| | | TOTAL_BIG_DEAL_MONEY_THRESHOLD_COUNT = round( |
| | | code_volumn_manager.CodeVolumeManager().get_radical_buy_refer_volume(code, |
| | | limit_up_price) * limit_up_price / 1e8, |
| | | 2) * 3 |
| | | if tool.is_ge_code(code): |
| | | TOTAL_BIG_DEAL_MONEY_THRESHOLD_COUNT *= 1.5 |
| | | return TOTAL_BIG_DEAL_MONEY_THRESHOLD_COUNT * threshold_money_per_order |
| | | |
| | | |
| | | def get_total_deal_big_order_info(code, limit_up_price, is_for_buy=False): |
| | | """ |
| | | 总成交大单啊是否足够 |
| | |
| | | """ |
| | | |
| | | THRESHOLD_MONEY, is_temp_threshold_money = BeforeSubDealBigOrderManager().get_big_order_threshold_info(code) |
| | | |
| | | TOTAL_BIG_DEAL_MONEY_THRESHOLD_COUNT = round( |
| | | code_volumn_manager.CodeVolumeManager().get_radical_buy_refer_volume(code, |
| | | limit_up_price) * limit_up_price / 1e8, |
| | | 2) * 3 |
| | | if tool.is_ge_code(code): |
| | | TOTAL_BIG_DEAL_MONEY_THRESHOLD_COUNT *= 3.3 |
| | | |
| | | TOTAL_BIG_DEAL_MONEY_THRESHOLD_MONEY_WITH_COMPUTE = TOTAL_BIG_DEAL_MONEY_THRESHOLD_COUNT * THRESHOLD_MONEY |
| | | TOTAL_BIG_DEAL_MONEY_THRESHOLD_MONEY_WITH_COMPUTE = compute_total_deal_big_order_threshold_money(code, |
| | | limit_up_price, |
| | | THRESHOLD_MONEY) |
| | | |
| | | human_setting_money = TotalDealBigOrderThresholdMoneyManager().get_money_cache(code) |
| | | if human_setting_money is not None: |
| | |
| | | return round(0 - 0.44 * fvolume_rate + 0.722, 3) |
| | | |
| | | |
| | | def request_deal_big_orders(code_): |
| | | """ |
| | | 请求大单成交 |
| | | @param code_: |
| | | @return: |
| | | """ |
| | | response_data = requests.get( |
| | | "http://127.0.0.1:9005/get_big_order_list?code=" + code_) |
| | | r_str = response_data.text |
| | | response_data = json.loads(r_str) |
| | | if response_data["code"] == 0: |
| | | datas = response_data["data"] |
| | | async_log_util.info(logger_debug, f"拉取订阅之前的数据:{code_}-{datas}") |
| | | if datas: |
| | | buy_datas = datas["buy"] |
| | | sell_datas = datas["sell"] |
| | | return buy_datas, sell_datas |
| | | return None |
| | | |
| | | |
| | | def pull_pre_deal_big_orders(code_): |
| | | """ |
| | | 拉取订阅之前成交的大单 |
| | |
| | | # 只有涨停过的代码才需要拉大单 |
| | | if code_ not in LimitUpDataConstant.get_history_limit_up_codes(): |
| | | return |
| | | response_data = requests.get( |
| | | "http://127.0.0.1:9005/get_big_order_list?code=" + code_) |
| | | r_str = response_data.text |
| | | response_data = json.loads(r_str) |
| | | if response_data["code"] == 0: |
| | | datas = response_data["data"] |
| | | async_log_util.info(logger_debug, f"拉取订阅之前的数据:{code_}-{datas}") |
| | | if datas: |
| | | |
| | | result = request_deal_big_orders(code_) |
| | | if result: |
| | | try: |
| | | buy_datas = datas["buy"] |
| | | sell_datas = datas["sell"] |
| | | buy_datas, sell_datas = result[0], result[1] |
| | | BeforeSubDealBigOrderManager().set_big_deal_order_list(code_, buy_datas, sell_datas, |
| | | gpcode_manager.get_limit_up_price_as_num(code_)) |
| | | except Exception as e: |
| | |
| | | return datas |
| | | return None |
| | | |
| | | |
| | | def list_l2_big_order_deal_info(codes): |
| | | """ |
| | | 获取成交大单信息 |