Administrator
2024-05-09 9ac765c32f39bb34cf2cd378e6ca7c1428e91b41
可转债订阅修改
4个文件已修改
28 ■■■■■ 已修改文件
cb_main.py 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
constant.py 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
huaxin_client/l2_client_for_cb.py 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
log_module/log.py 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cb_main.py
@@ -1,9 +1,11 @@
"""
可转债入口函数
"""
import constant
from huaxin_client import l2_client_for_cb
from utils import middle_api_protocol
if __name__ == '__main__':
    constant.LOG_DIR = "logs_cb"
    middle_api_protocol.SERVER_PORT = 10008
    l2_client_for_cb.run()
constant.py
@@ -48,6 +48,8 @@
MAX_L2_CHANNEL_COUNT = 10
LOG_DIR = "sell_logs"
# 获取根路径
def get_path_prefix():
    return 'D:' if is_windows() else '/home/userzjj'
huaxin_client/l2_client_for_cb.py
@@ -172,8 +172,7 @@
            logger_system.info(f"L2行情登录成功")
    def OnRspSubTransaction(self, pSpecificSecurity, pRspInfo, nRequestID, bIsLast):
        huaxin_l2_log.info(logger_local_huaxin_l2_subscript,
                           f"订阅结果:{pSpecificSecurity['SecurityID']} {pRspInfo['ErrorID']} {pRspInfo['ErrorMsg']}")
        logger_local_huaxin_l2_subscript.info(f"订阅:{pSpecificSecurity['SecurityID']}")
        if pRspInfo["ErrorID"] == 0:
            self.subscripted_codes.add(pSpecificSecurity['SecurityID'])
        if bIsLast == 1:
@@ -216,14 +215,17 @@
                    "SellNo": pTransaction['SellNo'],
                    "ExecType": pTransaction['ExecType'].decode()}
            logger_local_huaxin_l2_transaction.info(f"{item}")
            if pTransaction['TradePrice'] == self.limit_up_price_dict.get(pTransaction['SecurityID']):
                # TODO 成交价是涨停价才输出
                huaxin_l2_log.info(logger_local_huaxin_l2_transaction, f"{item}")
                if not self.__is_limit_up_dict.get(pTransaction['SecurityID']):
                    huaxin_l2_log.info(logger_local_huaxin_l2_upload, f"{pTransaction['TradeTime']} {pTransaction['SecurityID']} 下单")
                    huaxin_l2_log.info(logger_local_huaxin_l2_upload,
                                       f"{pTransaction['TradeTime']} {pTransaction['SecurityID']} 下单")
                self.__is_limit_up_dict[pTransaction['SecurityID']] = True
            else:
                self.__is_limit_up_dict[ pTransaction['SecurityID']] = False
                self.__is_limit_up_dict[pTransaction['SecurityID']] = False
class MyL2ActionCallback(L2ActionCallback):
log_module/log.py
@@ -274,8 +274,6 @@
                   filter=lambda record: record["extra"].get("name") == "local_huaxin_l2_market",
                   rotation="00:00", compression="zip", enqueue=True)
        logger.add(self.get_local_huaxin_path("contact", "debug"),
                   filter=lambda record: record["extra"].get("name") == "local_huaxin_debug",
                   rotation="00:00", compression="zip", enqueue=True)
@@ -306,20 +304,20 @@
                   rotation="00:00", compression="zip", enqueue=True)
    def get_path(self, dir_name, log_name):
        path_str = "{}/sell_logs/gp/{}/{}".format(constant.get_path_prefix(), dir_name,
                                                  log_name) + ".{time:YYYY-MM-DD}.log"
        path_str = "{}/{}/gp/{}/{}".format(constant.get_path_prefix(), constant.LOG_DIR, dir_name,
                                           log_name) + ".{time:YYYY-MM-DD}.log"
        # print(path_str)
        return path_str
    def get_hx_path(self, dir_name, log_name):
        path_str = "{}/sell_logs/huaxin/{}/{}".format(constant.get_path_prefix(), dir_name,
                                                      log_name) + ".{time:YYYY-MM-DD}.log"
        path_str = "{}/{}/huaxin/{}/{}".format(constant.get_path_prefix(), constant.LOG_DIR, dir_name,
                                               log_name) + ".{time:YYYY-MM-DD}.log"
        # print(path_str)
        return path_str
    def get_local_huaxin_path(self, dir_name, log_name):
        path_str = "{}/sell_logs/huaxin_local/{}/{}".format(constant.get_path_prefix(), dir_name,
                                                            log_name) + ".{time:YYYY-MM-DD}.log"
        path_str = "{}/{}/huaxin_local/{}/{}".format(constant.get_path_prefix(), constant.LOG_DIR, dir_name,
                                                     log_name) + ".{time:YYYY-MM-DD}.log"
        # print(path_str)
        return path_str