| | |
| | | from log_module.log import logger_local_huaxin_trade_debug, logger_system, logger_trade |
| | | from utils import tool |
| | | |
| | | |
| | | |
| | | ########B类######## |
| | | UserID = '388000013349' |
| | | # 登陆密码 |
| | |
| | | # 影子订单撤单 |
| | | # 撤掉影子单 |
| | | shadow_cancel_order_ref = shadow_order_ref + 1 |
| | | # 深证停留50ms上证停留200ms |
| | | delay_s = 0.05 if code.find("00") == 0 else 0.2 |
| | | self.cancel_buy(code, f"s_c_{shadow_order_ref}", order_sys_id=None, |
| | | order_ref=shadow_order_ref, |
| | | order_action_ref=None, delay_s=0.05) |
| | | order_action_ref=None, delay_s=delay_s) |
| | | |
| | | return ret |
| | | |
| | |
| | | pRspInfoField: "CTORATstpRspInfoField", nRequestID: "int", |
| | | bIsLast: "bool") -> "void": |
| | | if bIsLast != 1: |
| | | logger_local_huaxin_trade_debug.info('OnRspQryShareholderAccount[%d]: InvestorID[%s] ExchangeID[%s] ShareholderID[%s]' |
| | | % (nRequestID, pShareholderAccountField.InvestorID, pShareholderAccountField.ExchangeID, |
| | | pShareholderAccountField.ShareholderID)) |
| | | logger_local_huaxin_trade_debug.info( |
| | | 'OnRspQryShareholderAccount[%d]: InvestorID[%s] ExchangeID[%s] ShareholderID[%s]' |
| | | % (nRequestID, pShareholderAccountField.InvestorID, pShareholderAccountField.ExchangeID, |
| | | pShareholderAccountField.ShareholderID)) |
| | | else: |
| | | logger.info('查询股东账户结束[%d] ErrorID[%d] ErrorMsg[%s]' |
| | | % (nRequestID, pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | |
| | | |
| | | def run(trade_response_: TradeResponse = None, queue_other_w_l2_r_: multiprocessing.Queue = None, |
| | | queue_strategy_trade_write_=None, |
| | | queue_strategy_trade_read=None,queue_strategy_trade_read_for_read=None): |
| | | queue_strategy_trade_read=None, queue_strategy_trade_read_for_read=None): |
| | | try: |
| | | logger_system.info("交易进程ID:{}", os.getpid()) |
| | | logger_system.info(f"trade 线程ID:{tool.get_thread_id()}") |
| | |
| | | # 统计未撤订单的数量与金额 |
| | | total_datas = local_today_datas.get(code) |
| | | # 是否是下单5分钟内 |
| | | if tool.trade_time_sub(tool.get_now_time_str(), total_datas[real_order_index]['val']['time']) > 3 * 60: |
| | | return False, "下单超过5分钟" |
| | | if tool.trade_time_sub(tool.get_now_time_str(), total_datas[real_order_index]['val']['time']) > 2 * 60: |
| | | return False, "下单超过2分钟" |
| | | |
| | | total_left_count = 0 |
| | | total_left_num = 0 |
| | |
| | | # 获取下单信息 |
| | | def get_order_info(code): |
| | | info = _place_order_info_dict.get(code) |
| | | if info and time.time() - info[3] > 3: |
| | | async_log_util.info(logger_real_place_order_position, "get_order_info 间隔3s以上:code-{}", code) |
| | | TIME_SPACE_THRESHHOD = 3 if code.find("00") == 0 else 20 |
| | | if info and time.time() - info[3] > TIME_SPACE_THRESHHOD: |
| | | async_log_util.info(logger_real_place_order_position, "get_order_info 间隔{}s以上:code-{}",TIME_SPACE_THRESHHOD, code) |
| | | # 间隔3s以上就无效了 |
| | | info = None |
| | | _place_order_info_dict.pop(code) |
| | |
| | | real_place_index_info = shadow_place_order_index, RELIABILITY_TYPE_VIRTUAL |
| | | else: |
| | | real_place_index_info = real_place_index, RELIABILITY_TYPE_REAL |
| | | elif time.time() - order_time >= estimate_time_space: |
| | | elif tool.trade_time_sub(datas[-1]['val']['time'], exec_data['val']['time']) >= estimate_time_space: |
| | | # 下单超过2s |
| | | estimate_index = __compute_estimate_order_position(code, exec_data["index"]) |
| | | if estimate_index: |
| | |
| | | # if tool.trade_time_sub(latest_time, "09:32:00") < 0 or l2.l2_data_util.L2DataUtil.is_same_time(now_time_str, latest_time): |
| | | cls.__process_not_order(code, start_index, end_index, capture_timestamp, is_first_code) |
| | | |
| | | async_log_util.info(logger_l2_process, "code:{} 处理数据范围: {}-{} 处理时间:{} 截图时间戳:{}", code, |
| | | async_log_util.info(logger_l2_process, "code:{} 处理数据范围: {}-{} 处理时间:{} 线程ID:{}", code, |
| | | add_datas[0]["index"], |
| | | add_datas[-1]["index"], round(t.time() * 1000) - __start_time, |
| | | capture_timestamp) |
| | | l2_log.threadIds.get(code)) |
| | | |
| | | # 处理未挂单 |
| | | @classmethod |
| | |
| | | # 判断板块 |
| | | # (可以买的板块列表, 是否是独苗, 消息简介,可买的强势主线, 板块关键词) |
| | | can_buy_result = cls.__get_can_buy_block(code) |
| | | l2_log.debug(code, "获取到的板块信息:{}", can_buy_result) |
| | | # l2_log.debug(code, "获取到的板块信息:{}", can_buy_result) |
| | | if can_buy_result is None: |
| | | return False, True, "尚未获取到板块信息" |
| | | # -------量的约束-------- |
| | |
| | | @classmethod |
| | | def l2_order(cls, code, _datas, timestamp): |
| | | now_timestamp = int(time.time() * 1000) |
| | | async_log_util.info(hx_logger_l2_orderdetail, |
| | | f"{code}#耗时:{int((time.time() - timestamp) * 1000)}-{now_timestamp}#{_datas}") |
| | | thread_id = random.randint(0, 100000) |
| | | l2_log.threadIds[code] = thread_id |
| | | async_log_util.info(hx_logger_l2_orderdetail, |
| | | f"{code}#耗时:{int((time.time() - timestamp) * 1000)}-{thread_id}#{_datas}") |
| | | |
| | | # l2_data_log.l2_time_log(code, "开始处理L2逐笔委托") |
| | | try: |
| | | l2_data_manager_new.L2TradeDataProcessor.process_huaxin(code, _datas) |