| | |
| | | import constant |
| | | import inited_data |
| | | import outside_api_command_manager |
| | | from code_attribute import gpcode_manager |
| | | from code_attribute import gpcode_manager, code_volumn_manager |
| | | from db import mysql_data_delegate as mysql_data, redis_manager_delegate as redis_manager |
| | | from db.redis_manager_delegate import RedisUtils |
| | | from huaxin_client import l1_subscript_codes_manager |
| | | from huaxin_client.client_network import SendResponseSkManager |
| | | from l2 import l2_data_manager_new, l2_log, code_price_manager, l2_data_util, l2_data_manager, transaction_progress |
| | | from l2.cancel_buy_strategy import HourCancelBigNumComputer, LCancelBigNumComputer, DCancelBigNumComputer |
| | | from l2.cancel_buy_strategy import HourCancelBigNumComputer, LCancelBigNumComputer, DCancelBigNumComputer, \ |
| | | GCancelBigNumComputer |
| | | from l2.huaxin import huaxin_target_codes_manager |
| | | from l2.huaxin.huaxin_target_codes_manager import HuaXinL1TargetCodesManager |
| | | from l2.l2_data_manager_new import L2TradeDataProcessor |
| | |
| | | from trade import deal_big_money_manager, current_price_process_manager, trade_huaxin, trade_manager, l2_trade_util |
| | | |
| | | from trade.huaxin import huaxin_trade_api as trade_api, huaxin_trade_api, huaxin_trade_data_update |
| | | from trade.l2_trade_factor import L2PlaceOrderParamsManager |
| | | from trade.trade_manager import TradeTargetCodeModeManager |
| | | from utils import socket_util, data_export_util, middle_api_protocol, tool |
| | | |
| | |
| | | __inited = False |
| | | __TradeBuyQueue = transaction_progress.TradeBuyQueue() |
| | | __KPLCodeJXBlockManager = KPLCodeJXBlockManager() |
| | | __GCancelBigNumComputer = GCancelBigNumComputer() |
| | | |
| | | def setup(self): |
| | | self.__init() |
| | |
| | | finally: |
| | | sk.sendall(socket_util.load_header(json.dumps({"code": 0}).encode(encoding='utf-8'))) |
| | | elif data_json["type"] == "trading_order_canceled": |
| | | logger_l2_g_cancel.info(f"正在成交的订单撤单,data:{data_json}") |
| | | data = data_json["data"] |
| | | code = data["code"] |
| | | order_no = data["data"] |
| | | logger_l2_g_cancel.info(f"{code}-正在成交的订单撤单,order_no:{order_no}") |
| | | l2_data_manager_new.L2TradeDataProcessor.cancel_buy(code, "G撤撤单", "G撤") |
| | | volume_rate = code_volumn_manager.get_volume_rate(code) |
| | | volume_rate_index = code_volumn_manager.get_volume_rate_index(volume_rate) |
| | | m_val = L2PlaceOrderParamsManager(code, True, volume_rate, volume_rate_index, None).get_m_val()[ |
| | | 0] |
| | | limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | m_val_num = int(m_val / (float(limit_up_price) * 100)) |
| | | |
| | | try: |
| | | need_cancel, msg = self.__GCancelBigNumComputer.start_cancel(code, order_no, |
| | | l2_data_util.local_today_datas.get( |
| | | code), |
| | | l2_data_util.local_today_buyno_map.get( |
| | | code), |
| | | l2_data_util.local_today_num_operate_map.get( |
| | | code), m_val_num) |
| | | if need_cancel: |
| | | # 需要撤单 |
| | | l2_data_manager_new.L2TradeDataProcessor.cancel_buy(code, "G撤撤单", "G撤") |
| | | else: |
| | | logger_l2_g_cancel.info(f"{code}-不需要撤单:{str(e)}") |
| | | |
| | | |
| | | except Exception as e: |
| | | logger_l2_g_cancel.error(f"{code}-撤单异常:{str(e)}") |
| | | |
| | | |
| | | else: |
| | | # 断开连接 |
| | | break |