| | |
| | | else: |
| | | return None, order_info |
| | | |
| | | |
| | | # 因为L2数据慢的问题而重新计算 |
| | | def recompute_for_slow_time(code, order_info, real_place_index): |
| | | try: |
| | |
| | | # 下单时间不一致 |
| | | need_update = True |
| | | |
| | | if not need_update and real_place_index_data["val"]["num"] != volume//100: |
| | | if not need_update and real_place_index_data["val"]["num"] != volume // 100: |
| | | # 下单量不一致 |
| | | need_update = True |
| | | |
| | |
| | | # 已经撤单 |
| | | need_update = True |
| | | if need_update: |
| | | async_log_util.info(logger_debug, f"下单位矫正# {code}需要更新真实下单位置: 当前真实下单位-{real_place_index} order_info-{order_info}") |
| | | # 需要更新真实下单位置 |
| | | # 在时间内找引子单 |
| | | shadow_order_indexes = [] |
| | |
| | | if abs(shadow_price - float(val["price"])) >= 0.01: |
| | | continue |
| | | shadow_order_indexes.append(i) |
| | | async_log_util.info(logger_debug, f"下单位矫正# {code}获取到影子单索引:{shadow_order_indexes}") |
| | | |
| | | # 获取引子单前最近且符合真实下单位置特征的数据 |
| | | findexes_info = [] |
| | |
| | | continue |
| | | if not L2DataUtil.is_limit_up_price_buy(val): |
| | | continue |
| | | if volume//100 != val["num"]: |
| | | if volume // 100 != val["num"]: |
| | | continue |
| | | left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2( |
| | | code, |
| | |
| | | continue |
| | | findexes_info.append((index, i)) |
| | | break |
| | | async_log_util.info(logger_debug, f"下单位矫正# {code}真实下单位计算结果:{findexes_info}") |
| | | if findexes_info: |
| | | findexes_info.sort(key=lambda x: x[0] - x[1]) |
| | | # 获取成功 |
| | |
| | | # 获取L2的数据 |
| | | ps_dict = dict([(k, v[0]) for k, v in parse_qs(url.query).items()]) |
| | | code = ps_dict['code'] |
| | | datas = data_export_util.get_l2_datas(code, l2_data_util.local_today_datas.get(code)) |
| | | date = ps_dict.get('date') |
| | | datas = data_export_util.get_l2_datas(code, l2_data_util.local_today_datas.get(code), date = date) |
| | | code_name = gpcode_manager.get_code_name(code) |
| | | response_data = json.dumps({"code": 0, "data": {"code": code, "code_name": code_name, "data": datas}}) |
| | | except Exception as e: |
| | |
| | | |
| | | if __name__ == "__main__": |
| | | try: |
| | | export_l2_excel("002036") |
| | | export_l2_excel("600822", date="2024-03-12") |
| | | except Exception as e: |
| | | logging.exception(e) |