Administrator
2023-07-10 a3496f857ea7ab367cd76a336e2418589a854192
华鑫适配
3个文件已修改
35 ■■■■ 已修改文件
l2/huaxin/l2_huaxin_util.py 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/huaxin_log.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/trade_server.py 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/huaxin/l2_huaxin_util.py
@@ -14,14 +14,14 @@
    if time_str.startswith("9"):
        time_str = f"0{time_str}"
    time_ = f"{time_str[0:2]}:{time_str[2:4]}:{time_str[4:6]}"
    price = item["Price"]
    price = item[1]
    if price <= 0:
        # 深证的买撤无价格数据,需要去查找价格数据,暂时设置为涨停价
        price = limit_up_price
    limitPrice = 1 if abs(limit_up_price - price) < 0.001 else 0
    operateType = 0
    if item[''] == 'D':
    if item[9] == 'D':
        if item[3] == '1':
            # 买撤
            operateType = 1
@@ -81,7 +81,7 @@
def get_format_l2_datas(code, origin_datas, limit_up_price, start_index):
    # 先转变数据格式
    datas = [__convert_order(x, limit_up_price) for x in origin_datas]
    fdatas = __format_l2_data(datas, code, limit_up_price)
    datas = [__convert_order(x, float(limit_up_price)) for x in origin_datas]
    fdatas = __format_l2_data(datas, code, float(limit_up_price))
    for i in range(0, len(fdatas)):
        fdatas[i]["index"] = start_index + i
        fdatas[i]["index"]= start_index + i
trade/huaxin/huaxin_log.py
@@ -25,7 +25,7 @@
                   rotation="00:00", compression="zip", enqueue=True)
    def get_path(self, dir_name, log_name):
        return "/home/logs_/huaxin/{}/{}".format(dir_name, log_name) + ".{time:YYYY-MM-DD}.log"
        return "/home/logs/huaxin/{}/{}".format(dir_name, log_name) + ".{time:YYYY-MM-DD}.log"
    def get_logger(self, log_name):
        return logger.bind(name=log_name)
trade/huaxin/trade_server.py
@@ -165,6 +165,7 @@
                            __start_time = round(time.time() * 1000)
                            l2_data_manager_new.L2TradeDataProcessor().process_add_datas(code, datas, 0, __start_time)
                        except Exception as e:
                            logging.exception(e)
                            logger_l2_error.exception(e)
                        finally:
                            l2_data_log.l2_time(code, round(time.time() * 1000) - origin_start_time,
@@ -378,8 +379,28 @@
if __name__ == "__main__":
    code = "002251"
    datas =[['002251', 0.0, 138300, '1', '2', 112555120, 2011, 18281251, 18233797, 'D']]
    origin_start_time = 0
    try:
        # 转换数据格式
        _start_index = 0
        if local_today_datas.get(code) is not None and len(
                local_today_datas[code]) > 0:
            _start_index = local_today_datas[code][-1]["index"] + 1
        datas = l2_huaxin_util.get_format_l2_datas(code, datas,
                                                   gpcode_manager.get_limit_up_price(code), _start_index)
        __start_time = round(time.time() * 1000)
        # l2_data_manager_new.L2TradeDataProcessor().process_add_datas(code, datas, 0, __start_time)
    except Exception as e:
        logging.exception(e)
        logger_l2_error.exception(e)
    finally:
        l2_data_log.l2_time(code, round(time.time() * 1000) - origin_start_time,
                            "l2数据处理总耗时",
                            True)
        # l2.l2_data_util.save_l2_data(code, None, datas)
    run()
    # ClientSocketManager.add_client(ClientSocketManager.CLIENT_TYPE_TRADE, "1", None)
    # ClientSocketManager.add_client(ClientSocketManager.CLIENT_TYPE_TRADE, "2", None)
    # ClientSocketManager.add_client(ClientSocketManager.CLIENT_TYPE_TRADE, "3", None)