| | |
| | | from l2 import l2_data_manager, l2_log, l2_data_source_util, code_price_manager, \ |
| | | transaction_progress, cancel_buy_strategy, l2_data_log |
| | | from l2.cancel_buy_strategy import SecondCancelBigNumComputer, HourCancelBigNumComputer, DCancelBigNumComputer, \ |
| | | LCancelBigNumComputer, LatestCancelIndexManager, FastCancelBigNumComputer, LCancelRateManager, GCancelBigNumComputer |
| | | LCancelBigNumComputer, LatestCancelIndexManager, LCancelRateManager, GCancelBigNumComputer |
| | | from l2.l2_data_manager import L2DataException, OrderBeginPosInfo |
| | | from l2.l2_data_util import local_today_datas, L2DataUtil, local_today_num_operate_map, local_today_buyno_map, \ |
| | | local_latest_datas, local_today_canceled_buyno_map |
| | |
| | | @classmethod |
| | | def set_real_place_order_index(cls, code, index, order_begin_pos: OrderBeginPosInfo): |
| | | trade_record_log_util.add_real_place_order_position_log(code, index, order_begin_pos.buy_single_index) |
| | | if order_begin_pos.mode == OrderBeginPosInfo.MODE_FAST: |
| | | need_cancel = FastCancelBigNumComputer().set_real_order_index(code, index) |
| | | if need_cancel: |
| | | l2_log.debug(code, "触发撤单,撤单位置:{} ,撤单原因:{}", index, "F撤不够2笔触发撤单") |
| | | cls.cancel_buy(code, msg="F撤不够2笔触发撤单") |
| | | return |
| | | l2_log.debug(code, "设置真实下单位:{}", index) |
| | | cancel_buy_strategy.set_real_place_position(code, index, order_begin_pos.buy_single_index) |
| | | |
| | |
| | | pass |
| | | return None, "" |
| | | |
| | | # F撤 |
| | | def f_cancel(_buy_single_index, _buy_exec_index): |
| | | try: |
| | | b_need_cancel, b_cancel_data = FastCancelBigNumComputer().need_cancel(code, start_index, end_index, |
| | | order_begin_pos) |
| | | if b_need_cancel and b_cancel_data: |
| | | return b_cancel_data, f"F撤" |
| | | except Exception as e: |
| | | if constant.TEST: |
| | | logging.exception(e) |
| | | async_log_util.error(logger_l2_error, |
| | | f"F撤出错 参数:buy_single_index-{_buy_single_index} buy_exec_index-{_buy_exec_index} 错误原因:{str(e)}") |
| | | async_log_util.exception(logger_l2_error, e) |
| | | return None, "" |
| | | |
| | | # L撤 |
| | | def l_cancel(_buy_single_index, _buy_exec_index): |
| | |
| | | if order_begin_pos.buy_volume_rate is None: |
| | | buy_volume_rate = 0.2 |
| | | cancel_data, cancel_msg = None, "" |
| | | if order_begin_pos.mode == OrderBeginPosInfo.MODE_FAST: |
| | | cancel_data, cancel_msg = f_cancel(order_begin_pos.buy_single_index, order_begin_pos.buy_exec_index) |
| | | |
| | | if not cancel_data: |
| | | cancel_data, cancel_msg = g_cancel(order_begin_pos.buy_single_index, order_begin_pos.buy_exec_index) |
| | | |