| | |
| | | # 是否需要撤销 |
| | | @dask.delayed |
| | | def is_need_cancel(*args): |
| | | f_cancel_data, f_cancel_msg = None, "" |
| | | try: |
| | | for i in range(0, len(args)): |
| | | _cancel_data, _cancel_msg = args[i] |
| | | if _cancel_data: |
| | | if not f_cancel_data: |
| | | f_cancel_data, f_cancel_msg = _cancel_data, _cancel_msg |
| | | else: |
| | | if _cancel_data["index"] < f_cancel_data["index"]: |
| | | # 取较早的撤销数据 |
| | | f_cancel_data, f_cancel_msg = _cancel_data, _cancel_msg |
| | | |
| | | |
| | | return _cancel_data, _cancel_msg |
| | | except Exception as e: |
| | | logging.exception(e) |
| | | finally: |
| | | pass |
| | | return f_cancel_data, f_cancel_msg |
| | | return None, "" |
| | | |
| | | if start_index < 0: |
| | | start_index = 0 |
| | |
| | | |
| | | f1 = compute_safe_count() |
| | | f2 = compute_m_big_num() |
| | | f3 = buy_1_cancel() |
| | | f4 = s_cancel() |
| | | f5 = h_cancel() |
| | | f3 = s_cancel() |
| | | f4 = h_cancel() |
| | | f5 = buy_1_cancel() |
| | | f6 = sell_cancel() |
| | | dask_result = is_need_cancel(f1, f2, f3, f4, f5, f6) |
| | | cancel_data, cancel_msg = dask_result.compute() |
| | | |
| | | _start_time = l2_data_log.l2_time(code, cls.random_key[code], round(t.time() * 1000) - _start_time, |
| | | "已下单-撤单 判断是否需要撤单") |
| | | |
| | | if cancel_data: |
| | | cls.debug(code, "触发撤单,撤单位置:{} ,撤单原因:{}", cancel_data["index"], cancel_msg) |
| | | # 撤单 |
| | | if cls.cancel_buy(code, cancel_msg): |
| | | _start_time = l2_data_log.l2_time(code, cls.random_key[code], round(t.time() * 1000) - _start_time, |
| | | "已下单-撤单 耗时") |
| | | # 撤单成功,继续计算下单 |
| | | cls.__process_not_order(code, cancel_data["index"] + 1, end_index, capture_time) |
| | | _start_time = l2_data_log.l2_time(code, cls.random_key[code], round(t.time() * 1000) - _start_time, |
| | | "处理剩余数据 耗时") |
| | | else: |
| | | # 撤单尚未成功 |
| | | pass |
| | | _start_time = l2_data_log.l2_time(code, cls.random_key[code], round(t.time() * 1000) - _start_time, |
| | | "已下单-撤单+处理剩余数据") |
| | | |
| | | else: |
| | | # 如果有虚拟下单需要真实下单 |
| | | unreal_buy_info = cls.unreal_buy_dict.get(code) |
| | |
| | | cls.__buy(code, unreal_buy_info[1], local_today_datas[code][unreal_buy_info[0]], |
| | | unreal_buy_info[0]) |
| | | _start_time = l2_data_log.l2_time(code, cls.random_key[code], round(t.time() * 1000) - _start_time, |
| | | "已下单-真实下单") |
| | | "已下单-真实下单 耗时") |
| | | |
| | | @classmethod |
| | | def __buy(cls, code, capture_timestamp, last_data, last_data_index): |
| | |
| | | # trade_manager.start_cancel_buy("000637") |
| | | # t.sleep(10) |
| | | # L2TradeDataProcessor.test() |
| | | L2LimitUpMoneyStatisticUtil.verify_num("601958", 89178, "13:22:45") |
| | | # L2LimitUpMoneyStatisticUtil.verify_num("601958", 89178, "13:22:45") |
| | | # load_l2_data("600213") |
| | | # |
| | | # buy_index, buy_data = l2_data_util.get_buy_data_with_cancel_data(local_today_datas["600213"][84], |
| | | # local_today_num_operate_map.get( |
| | | # "600213")) |
| | | # print(buy_index, buy_data) |
| | | dict_={"code":0} |
| | | dict_.clear() |
| | | print(dict_) |