Administrator
2023-07-10 55ed3168a72faf42b5bb8a144890accb045d0842
华鑫适配
3个文件已修改
64 ■■■■ 已修改文件
logs_/log.py 32 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
logs_/log_analyse.py 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/current_price_process_manager.py 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
logs_/log.py
@@ -248,25 +248,25 @@
# 导出数据处理位置日志
def __export_l2_pos_range(code, date, dir):
    LogUtil.extract_log_from_key("{} 处理数据范围".format(code),
                                 "{}/logs_/gp/l2/l2_process.{}.log".format(constant.get_path_prefix(), date),
                                 "{}/logs/gp/l2/l2_process.{}.log".format(constant.get_path_prefix(), date),
                                 "{}/l2_process_{}.log".format(dir, date))
# 导出交易日志
def __export_l2_trade_log(code, date, dir):
    LogUtil.extract_log_from_key(code, "{}/logs_/gp/l2/l2_trade.{}.log".format(constant.get_path_prefix(), date),
    LogUtil.extract_log_from_key(code, "{}/logs/gp/l2/l2_trade.{}.log".format(constant.get_path_prefix(), date),
                                 "{}/l2_trade_{}.log".format(dir, date))
# 导出交易取消日志
def __export_l2_trade_cancel_log(code, date, dir):
    LogUtil.extract_log_from_key(code, "{}/logs_/gp/l2/l2_trade_cancel.{}.log".format(constant.get_path_prefix(), date),
    LogUtil.extract_log_from_key(code, "{}/logs/gp/l2/l2_trade_cancel.{}.log".format(constant.get_path_prefix(), date),
                                 "{}/l2_trade_cancel_{}.log".format(dir, date))
def __analyse_pricess_time():
    date = datetime.datetime.now().strftime("%Y-%m-%d")
    file_path = f"{constant.get_path_prefix()}/logs_/gp/l2/l2_process.{date}.log"
    file_path = f"{constant.get_path_prefix()}/logs/gp/l2/l2_process.{date}.log"
    with open(file_path, encoding="utf-8") as f:
        line = f.readline()
        while line:
@@ -280,7 +280,7 @@
    if len(code) < 6:
        return
    date = datetime.datetime.now().strftime("%Y-%m-%d")
    dir_ = "{}/logs_/gp/l2/{}".format(constant.get_path_prefix(), code)
    dir_ = "{}/logs/gp/l2/{}".format(constant.get_path_prefix(), code)
    if not os.path.exists(dir_):
        os.mkdir(dir_)
    __export_l2_pos_range(code, date, dir_)
@@ -300,7 +300,7 @@
    if date is None:
        date = datetime.datetime.now().strftime("%Y-%m-%d")
    try:
        with open("{}/logs_/gp/l2/l2_data.{}.log".format(constant.get_path_prefix(), date), mode='r') as f:
        with open("{}/logs/gp/l2/l2_data.{}.log".format(constant.get_path_prefix(), date), mode='r') as f:
            while True:
                data = f.readline()
                if not data:
@@ -335,7 +335,7 @@
    if not date:
        date = datetime.datetime.now().strftime("%Y-%m-%d")
    pos_list = []
    with open("{}/logs_/gp/l2/l2_process.{}.log".format(constant.get_path_prefix(), date), mode='r', encoding="utf-8") as f:
    with open("{}/logs/gp/l2/l2_process.{}.log".format(constant.get_path_prefix(), date), mode='r', encoding="utf-8") as f:
        while True:
            line = f.readline()
            if not line:
@@ -355,7 +355,7 @@
    if not date:
        date = datetime.datetime.now().strftime("%Y-%m-%d")
    pos_list = []
    with open("{}/logs_/gp/l2/l2_trade.{}.log".format(constant.get_path_prefix(), date), mode='r', encoding="utf-8") as f:
    with open("{}/logs/gp/l2/l2_trade.{}.log".format(constant.get_path_prefix(), date), mode='r', encoding="utf-8") as f:
        while True:
            line = f.readline()
            if not line:
@@ -395,7 +395,7 @@
        date = datetime.datetime.now().strftime("%Y-%m-%d")
    index_list = []
    buy_queues = []
    with open("{}/logs_/gp/l2/l2_trade_buy_queue.{}.log".format(constant.get_path_prefix(),date), mode='r', encoding="utf-8") as f:
    with open("{}/logs/gp/l2/l2_trade_buy_queue.{}.log".format(constant.get_path_prefix(),date), mode='r', encoding="utf-8") as f:
        while True:
            line = f.readline()
            if not line:
@@ -421,7 +421,7 @@
def get_h_cancel_compute_info(code, date=None):
    if not date:
        date = datetime.datetime.now().strftime("%Y-%m-%d")
    path_str = f"{constant.get_path_prefix()}/logs_/gp/l2/cancel/h_cancel.{date}.log"
    path_str = f"{constant.get_path_prefix()}/logs/gp/l2/cancel/h_cancel.{date}.log"
    latest_info = None
    if os.path.exists(path_str):
        with open(path_str, mode='r', encoding="utf-8") as f:
@@ -444,7 +444,7 @@
def get_kp_msg_list(date=None):
    if not date:
        date = datetime.datetime.now().strftime("%Y-%m-%d")
    path_str = f"{constant.get_path_prefix()}/logs_/gp/kp/kp_msg.{date}.log"
    path_str = f"{constant.get_path_prefix()}/logs/gp/kp/kp_msg.{date}.log"
    msg_list = []
    if os.path.exists(path_str):
        with open(path_str, mode='r', encoding="utf-8") as f:
@@ -459,7 +459,7 @@
def export_logs(code):
    code_name = gpcode_manager.get_code_name(code)
    date = datetime.datetime.now().strftime("%Y-%m-%d")
    target_dir = f"{constant.get_path_prefix()}/logs_/gp/l2/export/{code}_{code_name}_{date}"
    target_dir = f"{constant.get_path_prefix()}/logs/gp/l2/export/{code}_{code_name}_{date}"
    if os.path.exists(target_dir):
        shutil.rmtree(target_dir)
    os.makedirs(target_dir)
@@ -475,12 +475,12 @@
        dir_path = "/".join(target_path.split("/")[:-1])
        if not os.path.exists(dir_path):
            os.makedirs(dir_path)
        LogUtil.extract_log_from_key(key, f"{constant.get_path_prefix()}/logs_/gp/l2/{log_name}.{date}.log",
        LogUtil.extract_log_from_key(key, f"{constant.get_path_prefix()}/logs/gp/l2/{log_name}.{date}.log",
                                     target_path)
def export_trade_progress(code):
    path = f"{constant.get_path_prefix()}/logs_/gp/l2/l2_trade_buy_progress.{tool.get_now_date_str()}.log"
    path = f"{constant.get_path_prefix()}/logs/gp/l2/l2_trade_buy_progress.{tool.get_now_date_str()}.log"
    index_set = set()
    with open(path, mode='r', encoding="utf-8") as f:
        lines = f.readlines()
@@ -495,7 +495,7 @@
# 加载买入得分记录
def load_buy_score_recod(code):
    path = f"{constant.get_path_prefix()}/logs_/gp/trade/trade_record.{tool.get_now_date_str()}.log"
    path = f"{constant.get_path_prefix()}/logs/gp/trade/trade_record.{tool.get_now_date_str()}.log"
    fdatas = []
    if os.path.exists(path):
        with open(path, 'r', encoding="utf-8") as f:
@@ -511,7 +511,7 @@
def load_kpl_reason_changes():
    path = f"{constant.get_path_prefix()}/logs_/gp/kpl/kpl_limit_up_reason_change.{tool.get_now_date_str()}.log"
    path = f"{constant.get_path_prefix()}/logs/gp/kpl/kpl_limit_up_reason_change.{tool.get_now_date_str()}.log"
    fdatas = []
    if os.path.exists(path):
        with open(path, 'r', encoding="utf-8") as f:
logs_/log_analyse.py
@@ -9,7 +9,7 @@
def get_cant_order_reasons_dict():
    file_path = "{}/logs_/gp/l2/l2_trade.{}.log".format(constant.get_path_prefix(), tool.get_now_date_str())
    file_path = "{}/logs/gp/l2/l2_trade.{}.log".format(constant.get_path_prefix(), tool.get_now_date_str())
    dict_ = {}
    if os.path.exists(file_path):
        with open(file_path, encoding="utf-8") as f:
@@ -26,7 +26,7 @@
def get_kpl_can_buy_reasons_dict():
    file_path = "{}/logs_/gp/kpl/kpl_block_can_buy.{}.log".format(constant.get_path_prefix(), tool.get_now_date_str())
    file_path = "{}/logs/gp/kpl/kpl_block_can_buy.{}.log".format(constant.get_path_prefix(), tool.get_now_date_str())
    dict_ = {}
    if os.path.exists(file_path):
        with open(file_path, encoding="utf-8") as f:
trade/current_price_process_manager.py
@@ -119,20 +119,20 @@
            # 华鑫L2,获取加入代码的涨停价
            # 是否和上次一样
            add_code_set = set(add_code_list)
            global latest_add_codes
            if True: #tuple(latest_add_codes) != tuple(add_code_set):
                # latest_add_codes = add_code_set
                add_datas = []
                for d in add_code_list:
                    limit_up_price = gpcode_manager.get_limit_up_price(d)
                    limit_up_price = round(float(limit_up_price), 2)
                    min_volume = int(round(50 * 10000 / limit_up_price))
                    add_datas.append((d, min_volume, limit_up_price))
                try:
                    huaxin_target_codes_manager.push(add_datas)
                except Exception as e:
                    logging.exception(e)
            try:
                add_code_set = set(add_code_list)
                global latest_add_codes
                if not latest_add_codes or tuple(latest_add_codes) != tuple(add_code_set):
                    latest_add_codes = add_code_set
                    add_datas = []
                    for d in add_code_list:
                        limit_up_price = gpcode_manager.get_limit_up_price(d)
                        limit_up_price = round(float(limit_up_price), 2)
                        min_volume = int(round(50 * 10000 / limit_up_price))
                        add_datas.append((d, min_volume, limit_up_price))
                        huaxin_target_codes_manager.push(add_datas)
            except Exception as e:
                logging.exception(e)
        else:
            # 后面的代码数量
            # 先删除应该删除的代码