| | |
| | | |
| | | def need_cancel(self, code, buy_exec_index, start_index, end_index, total_data, is_first_code): |
| | | if buy_exec_index is None: |
| | | return False, "尚未找到下单位置" |
| | | return False, "尚未找到下单位置", "" |
| | | time_space = tool.trade_time_sub(total_data[start_index]["val"]["time"], |
| | | total_data[buy_exec_index]["val"]["time"]) |
| | | # 守护S撤以外的数据 |
| | | if time_space <= constant.L_CANCEL_START_TIME or int(tool.get_now_time_str().replace(":", "")) > int("145000"): |
| | | return False, None |
| | | return False, None, "" |
| | | # 下单位临近撤 |
| | | can_cancel, cancel_data = self.__compute_need_cancel(code, buy_exec_index, start_index, end_index, total_data, |
| | | is_first_code) |
| | | can_cancel, cancel_data = False, None |
| | | try: |
| | | can_cancel, cancel_data = self.__compute_need_cancel(code, buy_exec_index, start_index, end_index, total_data, |
| | | is_first_code) |
| | | except Exception as e: |
| | | logger_l2_l_cancel.exception(e) |
| | | raise e |
| | | extra_msg = "L下" |
| | | if not can_cancel: |
| | | # 成交位临近撤 |
| | | can_cancel, cancel_data = self.__compute_near_by_trade_progress_need_cancel(code, buy_exec_index, |
| | | start_index, end_index, |
| | | total_data, |
| | | is_first_code) |
| | | extra_msg = "L上" |
| | | try: |
| | | can_cancel, cancel_data = self.__compute_near_by_trade_progress_need_cancel(code, buy_exec_index, |
| | | start_index, end_index, |
| | | total_data, |
| | | is_first_code) |
| | | extra_msg = "L上" |
| | | except Exception as e: |
| | | logger_l2_l_cancel.exception(e) |
| | | raise e |
| | | return can_cancel, cancel_data, extra_msg |
| | | |
| | | def place_order_success(self, code): |
| | |
| | | f"L撤出错 参数:buy_single_index-{_buy_single_index} buy_exec_index-{_buy_exec_index} 错误原因:{str(e)}") |
| | | logger_l2_error.exception(e) |
| | | async_log_util.exception(logger_l2_error, e) |
| | | raise e |
| | | finally: |
| | | # l2_data_log.l2_time(code, round(t.time() * 1000) - _start_time, "已下单-L撤大单计算") |
| | | pass |