| | |
| | | latest_trading_date = history_k_data_util.get_k_bar_dead_date() |
| | | codes = HistoryKDataManager().get_history_bars_codes(latest_trading_date) |
| | | count = len(codes) |
| | | logger_debug.info(f"K线代码数量:{count}") |
| | | fdata["today_history_k_bar_count"] = count |
| | | except Exception as e: |
| | | logger_debug.exception(e) |
| | | fdata["today_history_k_bar_count"] = -1 |
| | | |
| | | # 获取数据服务器是否联通 |
| | |
| | | IGNORE_BLOCK_IN_MONEY_MARKET_STRONG = 101 |
| | | |
| | | # 新版L2监听 |
| | | IS_L2_NEW = False |
| | | IS_L2_NEW = True |
| | | |
| | | |
| | |
| | | def add_subscript_codes(codes): |
| | | # print("add_subscript_codes", codes) |
| | | # 加入上传队列 |
| | | common_queue.put(('', "l2_subscript_codes", list(codes))) |
| | | pid = multiprocessing.current_process().pid |
| | | common_queue.put(('', "l2_subscript_codes_v2", (pid, list(codes)))) |
| | | |
| | | |
| | | def __send_response(sk, msg): |
| | |
| | | order_no_set = set() |
| | | limit_up_active_buy_datas = [] |
| | | for d in datas: |
| | | if abs(d[1] - limit_up_price) > 0.001: |
| | | continue |
| | | # 是否有涨停主动买成交 |
| | | if d[6] < d[7]: |
| | | continue |
| | | if abs(d[1] - limit_up_price) > 0.001: |
| | | continue |
| | | limit_up_active_buy_datas.append(d) |
| | | total_deal_volume = 0 |
| | |
| | | cls.__delegating_sell_num_dict[code] -= total_deal_volume |
| | | |
| | | if len(limit_up_active_buy_datas): |
| | | async_log_util.l2_data_log.info(hx_logger_l2_sell_deal, |
| | | f"涨停主动买成交:{limit_up_active_buy_datas}") |
| | | l2_log.info(code, hx_logger_l2_sell_deal, |
| | | f"涨停主动买成交:{limit_up_active_buy_datas}") |
| | | # 打印日志 |
| | | async_log_util.l2_data_log.info(hx_logger_l2_sell_deal, |
| | | f"有涨停主动卖:{code}-{datas[-1][3]}-{cls.__delegating_sell_num_dict.get(code)}, 成交量-{total_deal_volume}") |
| | | l2_log.info(code, hx_logger_l2_sell_deal, |
| | | f"有涨停主动卖:{code}-{datas[-1][3]}-{cls.__delegating_sell_num_dict.get(code)}, 成交量-{total_deal_volume}") |
| | | except: |
| | | pass |
| | | |
| | |
| | | use_time = time.time() - __start_time |
| | | __start_time = time.time() |
| | | use_time_list.append(("处理涨停卖", use_time)) |
| | | |
| | | async_log_util.info(hx_logger_l2_upload, |
| | | f"{code}处理涨停卖:{use_time} 数据数量:{len(datas)} 详情:{use_time_list}") |
| | | |
| | | |
| | | |
| | | for d in datas: |
| | | # 获取当前是否为主动买 |
| | | try: |
| | |
| | | from cancel_strategy.s_l_h_cancel_strategy import LCancelBigNumComputer, LCancelRateManager |
| | | from cancel_strategy.s_l_h_cancel_strategy import SCancelBigNumComputer |
| | | from code_attribute import gpcode_manager |
| | | from l2 import l2_data_util, l2_data_manager, transaction_progress |
| | | from l2 import l2_data_util, l2_data_manager, transaction_progress, l2_log |
| | | from l2.cancel_buy_strategy import FCancelBigNumComputer, \ |
| | | NewGCancelBigNumComputer, \ |
| | | NBCancelBigNumComputer |
| | |
| | | |
| | | _start_time = time.time() |
| | | L2LimitUpSellDataManager.set_deal_datas(code, datas) |
| | | use_time_list.append(("统计涨停卖成交", time.time() - _start_time)) |
| | | _start_time = time.time() |
| | | # 大单统计 |
| | | # cls.__statistic_thread_pool.submit(cls.statistic_big_order_infos, code, datas, order_begin_pos) |
| | | try: |
| | | cls.statistic_big_order_infos(code, datas, order_begin_pos) |
| | | except Exception as e: |
| | | hx_logger_l2_debug.error(f"统计大单出错:{str(e)}") |
| | | use_time_list.append(("统计买单数据", time.time() - _start_time)) |
| | | async_log_util.error(hx_logger_l2_debug, f"统计大单出错:{str(e)}") |
| | | use_time_list.append(("统计大单数据", time.time() - _start_time)) |
| | | _start_time = time.time() |
| | | |
| | | big_sell_order_info = None |
| | |
| | | # 统计卖单 |
| | | big_sell_order_info = HuaXinSellOrderStatisticManager.add_transaction_datas(code, datas, limit_up_price) |
| | | |
| | | use_time_list.append(("处理卖单成交数据", time.time() - _start_time)) |
| | | _start_time = time.time() |
| | | use_time_list.append(("处理卖单成交数据", _start_time - __start_time)) |
| | | |
| | | if is_placed_order: |
| | | |
| | | need_cancel, cancel_msg = SCancelBigNumComputer().set_big_sell_order_info_for_cancel(code, |
| | |
| | | finally: |
| | | use_time = int((time.time() - __start_time) * 1000) |
| | | if use_time > 5: |
| | | async_log_util.info(hx_logger_l2_upload, |
| | | f"{code}处理成交用时:{use_time} 数据数量:{len(datas)} 详情:{use_time_list}") |
| | | l2_log.info(code, hx_logger_l2_upload, |
| | | f"{code}处理成交用时:{use_time} 数据数量:{len(datas)} 详情:{use_time_list}") |
| | |
| | | __TradeBuyQueue = transaction_progress.TradeBuyQueue() |
| | | __KPLCodeJXBlockManager = KPLCodeJXBlockManager() |
| | | __GCancelBigNumComputer = GCancelBigNumComputer() |
| | | # L2进程对应订阅的代码: {"进程ID": 代码列表} |
| | | __pid_l2_subscript_codes = {} |
| | | |
| | | def setup(self): |
| | | self.__init() |
| | |
| | | middle_api_protocol.request(fdata) |
| | | finally: |
| | | sk.sendall(socket_util.load_header(json.dumps({"code": 0}).encode(encoding='utf-8'))) |
| | | elif data_json["type"] == "l2_subscript_codes_v2": |
| | | try: |
| | | data = data_json["data"] |
| | | datas = data["data"] |
| | | pid, datas = datas[0], datas[1] |
| | | self.__pid_l2_subscript_codes[pid] = datas |
| | | # print("l2_subscript_codes", data_json) |
| | | fcodes = [] |
| | | for pid in self.__pid_l2_subscript_codes: |
| | | codes = self.__pid_l2_subscript_codes[pid] |
| | | fcodes.extend(codes) |
| | | # 订阅的代码 |
| | | huaxin_target_codes_manager.HuaXinL2SubscriptCodesManager.save_subscript_codes(fcodes) |
| | | # 上传数据 |
| | | codes = huaxin_target_codes_manager.HuaXinL2SubscriptCodesManager.get_subscript_codes() |
| | | l2_log.codeLogQueueDistributeManager.set_l2_subscript_codes(codes) |
| | | |
| | | fresults = [] |
| | | if codes: |
| | | for code in codes: |
| | | try: |
| | | # 获取成交大单:(参考大单金额,已成交大单金额,大单要求金额) |
| | | th, is_temp = BeforeSubDealBigOrderManager().get_big_order_threshold_info(code) |
| | | deal_big_money_info = radical_buy_data_manager.get_total_deal_big_order_info( |
| | | code, gpcode_manager.get_limit_up_price_as_num(code)) |
| | | deal_big_order_info = ( |
| | | output_util.money_desc(th), output_util.money_desc(deal_big_money_info[1]), |
| | | output_util.money_desc(deal_big_money_info[2])) |
| | | except: |
| | | deal_big_order_info = None |
| | | code_name = gpcode_manager.get_code_name(code) |
| | | fresults.append((code, code_name, deal_big_order_info)) |
| | | |
| | | fdata = middle_api_protocol.load_l2_subscript_codes(fresults) |
| | | middle_api_protocol.request(fdata) |
| | | finally: |
| | | sk.sendall(socket_util.load_header(json.dumps({"code": 0}).encode(encoding='utf-8'))) |
| | | |
| | | elif data_json["type"] == "get_level1_codes": |
| | | # print("get_level1_codes") |
| | | # 获取level1的代码 |
| | |
| | | @param queues: |
| | | @return: |
| | | """ |
| | | |
| | | def recieve_data(queue): |
| | | while True: |
| | | try: |
| | |
| | | my_l2_data_callback.OnMarketData(code, market_data) |
| | | except: |
| | | pass |
| | | |
| | | for q in queues: |
| | | threading.Thread(target=recieve_data, args=(q,), daemon=True).start() |
| | | |
| | |
| | | average_rate = total_rate / len(self.__watch_block_high_codes[b]) |
| | | if average_rate < 1: |
| | | forbidden_blocks.add(b) |
| | | async_log_util.info(logger_debug, f"板块平均涨幅 {b}-{average_rate}") |
| | | # async_log_util.info(logger_debug, f"板块平均涨幅 {b}-{average_rate}") |
| | | |
| | | self.__kpl_forbidden_plates_cache = forbidden_blocks |
| | | async_log_util.info(logger_debug, f"拉黑板块:{forbidden_blocks}") |
| | |
| | | """ |
| | | timestamp = round(time.time() * 1000) |
| | | if not sinfo: |
| | | sinfo = f"b_{code}_{timestamp}" |
| | | sinfo = f"ba_{code}_{timestamp}" |
| | | if not order_ref: |
| | | order_ref = huaxin_util.create_order_ref() |
| | | if not request_id: |