| | |
| | | L2数据溯源 |
| | | """ |
| | | import constant |
| | | from log_module.log import logger_l2_error |
| | | from utils import tool |
| | | |
| | | |
| | |
| | | for bd in buy_datas: |
| | | # 根据订单号做匹配 |
| | | if bd["val"]["orderNo"] == cancel_data["val"]["orderNo"]: |
| | | return bd |
| | | return bd["index"] |
| | | return None |
| | | |
| | | # 同花顺渠道的L2,根据买撤数据查找买入数据 |
| | |
| | | def get_buy_index_with_cancel_data(cls, code, cancel_data, local_today_num_operate_map): |
| | | key = "{}-{}-{}".format(cancel_data["val"]["num"], "1", cancel_data["val"]["price"]) |
| | | cancel_datas = local_today_num_operate_map.get(key) |
| | | try: |
| | | cancel_datas.sort(key=lambda t: t["index"]) |
| | | except Exception as e: |
| | | print("测试") |
| | | for item in cancel_datas: |
| | | # 提前做计算 |
| | | cls.__get_buy_index_with_cancel_data(code, item, local_today_num_operate_map) |
| | | if cancel_datas: |
| | | try: |
| | | cancel_datas.sort(key=lambda t: t["index"]) |
| | | except Exception as e: |
| | | # print("测试") |
| | | pass |
| | | for item in cancel_datas: |
| | | # 提前做计算 |
| | | cls.__get_buy_index_with_cancel_data(code, item, local_today_num_operate_map) |
| | | |
| | | return cls.__get_buy_index_with_cancel_data(code, cancel_data, local_today_num_operate_map) |
| | | |
| | | # 根据买撤数据计算买入数据(华鑫原生L2数据适用) |
| | | @classmethod |
| | | def get_buy_index_with_cancel_data_v2(cls, cancel_data, buyno_map): |
| | | order_no = str(cancel_data["val"]["orderNo"]) |
| | | buy_data = buyno_map.get(order_no) |
| | | if buy_data: |
| | | return buy_data["index"] |
| | | return None |
| | | |
| | | # 获取没撤的笔数 |
| | | @classmethod |
| | |
| | | data = None |
| | | try: |
| | | data = total_data[index] |
| | | except: |
| | | print("") |
| | | except Exception as e: |
| | | logger_l2_error.error(f"未找到买入索引对应的数据:index-{index} total_data长度-{len(total_data) if total_data else 0} 错误原因:{str(e)}") |
| | | val = data["val"] |
| | | # 判断当前买是否已经买撤 |
| | | cancel_datas = local_today_num_operate_map.get( |
| | |
| | | canceled = False |
| | | if cancel_datas: |
| | | for cancel_data in cancel_datas: |
| | | |
| | | buy_index = cls.get_buy_index_with_cancel_data(code, cancel_data, local_today_num_operate_map) |
| | | if buy_index == index: |
| | | canceled = True |
| | |
| | | return count |
| | | return 0 |
| | | |
| | | # 获取没撤的笔数 |
| | | |
| | | # 获取涨停买没有撤单的数量 |
| | | @classmethod |
| | | def get_limit_up_buy_no_canceled_count_v2(cls, code, index, total_data, canceled_buyno_map): |
| | | data = None |
| | | try: |
| | | data = total_data[index] |
| | | except Exception as e: |
| | | logger_l2_error.error( |
| | | f"未找到买入索引对应的数据:index-{index} total_data长度-{len(total_data) if total_data else 0} 错误原因:{str(e)}") |
| | | val = data["val"] |
| | | order_no = str(val["orderNo"]) |
| | | canceled_data = canceled_buyno_map.get(order_no) |
| | | if canceled_data: |
| | | return data["re"] - canceled_data["re"] |
| | | else: |
| | | return data["re"] |
| | | |
| | | @classmethod |
| | | def get_limit_up_buy_canceled_data_v2(cls, code, index, total_data, canceled_buyno_map): |
| | | data = None |
| | | try: |
| | | data = total_data[index] |
| | | except Exception as e: |
| | | logger_l2_error.error( |
| | | f"未找到买入索引对应的数据:index-{index} total_data长度-{len(total_data) if total_data else 0} 错误原因:{str(e)}") |
| | | val = data["val"] |
| | | order_no = str(val["orderNo"]) |
| | | canceled_data = canceled_buyno_map.get(order_no) |
| | | if canceled_data: |
| | | return canceled_data |
| | | else: |
| | | return None |
| | | |
| | | |
| | | # if __name__ == "__main__": |
| | | # code = "000925" |
| | | # l2_data_util.load_l2_data(code) |