| | |
| | | |
| | | result = {"code": 0, "data": {"account_available_money": account_available_money, "delegates": fdatas}} |
| | | self.send_response(result, client_id, request_id) |
| | | elif ctype == "get_delegated_buy_code_infos_v2": |
| | | account_available_money = trade_data_manager.AccountMoneyManager().get_available_money_cache() |
| | | # 获取委托中的代码 |
| | | current_delegates = huaxin_trade_record_manager.DelegateRecordManager().list_current_delegates() |
| | | fdatas = [] |
| | | if current_delegates: |
| | | codes_set = set() |
| | | for c in current_delegates: |
| | | _start_time = time.time() |
| | | try: |
| | | if int(c["direction"]) != huaxin_util.TORA_TSTP_D_Buy: |
| | | continue |
| | | code = c["securityID"] |
| | | if code in codes_set: |
| | | continue |
| | | orderSysID = c.get("orderSysID") |
| | | codes_set.add(code) |
| | | code_name = gpcode_manager.get_code_name(code) |
| | | # 获取下单位置信息 |
| | | order_begin_pos = TradePointManager().get_buy_compute_start_data_cache(code) |
| | | if order_begin_pos is None or order_begin_pos.buy_single_index is None: |
| | | order_begin_pos = OrderBeginPosInfo(buy_single_index=0, buy_exec_index=0) |
| | | l2_data_util.load_l2_data(code) |
| | | total_datas = l2_data_util.local_today_datas.get(code) |
| | | if not total_datas: |
| | | continue |
| | | trade_index, is_default = transaction_progress.TradeBuyQueue().get_traded_index(code) |
| | | if trade_index is None: |
| | | trade_index = 0 |
| | | # 下单位置 |
| | | place_order_index = SCancelBigNumComputer().get_real_place_order_index_cache(code) |
| | | if place_order_index is None: |
| | | place_order_index = 0 |
| | | |
| | | # 获取剩下的笔数 |
| | | total_left_count = 0 |
| | | total_left_num = 0 |
| | | for i in range(trade_index + 1, place_order_index): |
| | | data = total_datas[i] |
| | | val = data["val"] |
| | | if not L2DataUtil.is_limit_up_price_buy(val): |
| | | continue |
| | | if val["num"] * float(val["price"]) < 5000: |
| | | continue |
| | | left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2( |
| | | code, |
| | | i, |
| | | total_datas, |
| | | l2_data_util.local_today_canceled_buyno_map.get( |
| | | code)) |
| | | if left_count > 0: |
| | | total_left_count += left_count |
| | | total_left_num += val["num"] * left_count |
| | | # 获取正在成交 |
| | | dealing_info = HuaXinBuyOrderManager.get_dealing_order_info(code) |
| | | if dealing_info: |
| | | if str(total_datas[trade_index]["val"]["orderNo"]) == str(dealing_info[0]): |
| | | total_left_num += (total_datas[trade_index]["val"]["num"] - dealing_info[1] // 100) |
| | | limit_up_price = gpcode_manager.get_limit_up_price_as_num(code) |
| | | buy1_money = Buy1PriceManager().get_latest_buy1_money(code) |
| | | if buy1_money is None: |
| | | buy1_money = 1 |
| | | real_place_order_after_count = 0 |
| | | real_place_order_after_num = 0 |
| | | is_ge_code = tool.is_ge_code(code) |
| | | # 统计真实下单位置后面未撤的金额 |
| | | for i in range(place_order_index, total_datas[-1]["index"]): |
| | | val = total_datas[i]["val"] |
| | | if not L2DataUtil.is_limit_up_price_buy(val): |
| | | continue |
| | | # 是不是大单 |
| | | if not l2_data_util_old.is_big_money(val, is_ge_code): |
| | | continue |
| | | |
| | | canceled_data = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_canceled_data_v2( |
| | | code, |
| | | i, |
| | | total_datas, |
| | | l2_data_util.local_today_canceled_buyno_map.get( |
| | | code)) |
| | | if not canceled_data: |
| | | real_place_order_after_count += 1 |
| | | real_place_order_after_num += val["num"] |
| | | |
| | | # 是否需要注意 |
| | | need_pay_attention = (total_left_count <= 10 or total_left_num * float( |
| | | limit_up_price) * 100 < 1500 * 10000) and ( |
| | | real_place_order_after_count <= 10 or real_place_order_after_num * limit_up_price * 100 < 1500 * 10000) |
| | | # L撤比例 |
| | | l_down_cancel_rate, must_buy, cancel_rate_info = LCancelRateManager.get_cancel_rate(code, |
| | | buy_mode=OrderBeginPosInfo.MODE_RADICAL) |
| | | |
| | | fdata = {"id": orderSysID, "code_info": (code, code_name), |
| | | "buy1_money": output_util.money_desc(buy1_money), |
| | | "left_count": total_left_count, |
| | | "left_money": output_util.money_desc(total_left_num * float(limit_up_price) * 100), |
| | | "pay_attention": need_pay_attention, |
| | | "trade_progress_percent": round( |
| | | total_left_num * float(limit_up_price) * 100 * 100 / buy1_money, 2), # 成交进度比例 |
| | | "limit_up_price": limit_up_price, |
| | | "block": '', |
| | | "trade_queue": [], |
| | | "l_down_cancel_rate": l_down_cancel_rate, |
| | | "l_down_cancel_rate_info": cancel_rate_info, |
| | | } |
| | | limit_up_data = kpl_data_manager.KPLLimitUpDataRecordManager.record_code_dict.get(code) |
| | | # 获取当前板块 |
| | | try: |
| | | limit_up_sequences = CodeLimitUpSequenceManager.get_current_limit_up_sequence(code) |
| | | if limit_up_sequences: |
| | | buy_blocks = RadicalBuyDealCodesManager().get_code_blocks(code) |
| | | blocks_info = [] |
| | | for limit_up_sequence in limit_up_sequences: |
| | | # 获取代码下单的板块 |
| | | if buy_blocks and limit_up_sequence[0] not in buy_blocks: |
| | | continue |
| | | blocks_info.append( |
| | | f"{limit_up_sequence[0]}-{limit_up_sequence[1]}({limit_up_sequence[2]}&{limit_up_sequence[2] - limit_up_sequence[3]})") |
| | | if buy_blocks: |
| | | fdata['block'] = "/".join(blocks_info) |
| | | except: |
| | | pass |
| | | # 获取涨停时间 |
| | | if limit_up_data: |
| | | fdata['limit_up_time'] = tool.to_time_str(limit_up_data[2]) |
| | | |
| | | # 获取委托队列 |
| | | try: |
| | | real_place_order_index = SCancelBigNumComputer().get_real_place_order_index_cache(code) |
| | | if real_place_order_index is not None: |
| | | trade_queue = l2_output_util.get_trade_queue_at_near_place_order(code, |
| | | real_place_order_index, |
| | | 9) |
| | | fdata['trade_queue'] = trade_queue |
| | | # 自由流通股本 |
| | | zyltgb = global_util.zyltgb_map.get(code) |
| | | if zyltgb is not None: |
| | | fdata['zyltgb'] = output_util.money_desc(zyltgb) |
| | | except: |
| | | pass |
| | | # L后囊括快照 |
| | | try: |
| | | __start_time = time.time() |
| | | current_info = LCancelBigNumComputer().statistic_l_down_watch_indexes_info(code) |
| | | fdata['l_down_watch_indexes_info'] = {} |
| | | if current_info: |
| | | fdata['l_down_watch_indexes_info']['current'] = current_info |
| | | use_time = time.time() - __start_time |
| | | if use_time > 0.05: |
| | | async_log_util.info(logger_debug, f"统计实撤用时:{code} - {use_time}") |
| | | except Exception as e: |
| | | logger_debug.exception(e) |
| | | fdatas.append(fdata) |
| | | except Exception as e: |
| | | logger_debug.exception(e) |
| | | finally: |
| | | use_time = time.time() - _start_time |
| | | if use_time > 0.1: |
| | | async_log_util.info(logger_debug, f"委托信息统计耗时:{c['securityID']}-{use_time}") |
| | | result = {"code": 0, "data": {"account_available_money": account_available_money, "delegates": fdatas}} |
| | | self.send_response(result, client_id, request_id) |
| | | elif ctype == "set_real_place_order_index": |
| | | # 设置真实下单位置 |
| | | code = data["code"] |
| | |
| | | old_rate = LCancelRateManager().get_cancel_rate(0)[0] |
| | | CancelRateHumanSettingManager().set_l_down(code, rate) |
| | | # L后重新囊括 |
| | | if rate < old_rate: |
| | | # if rate < old_rate: |
| | | # 改小才能重新囊括 |
| | | trade_record_log_util.add_common_msg(code, "L后重新囊括", msg=f"修改撤单比例: {old_rate}->{rate}") |
| | | LCancelBigNumComputer().re_compute_l_down_watch_indexes(code, is_force=True) |
| | | trade_record_log_util.add_common_msg(code, "L后重新囊括", msg=f"修改撤单比例: {old_rate}->{rate}") |
| | | LCancelBigNumComputer().re_compute_l_down_watch_indexes(code, is_force=True) |
| | | |
| | | self.send_response({"code": 0, "data": {}}, |
| | | client_id, |