| | |
| | | """ |
| | | 可转债入口函数 |
| | | """ |
| | | 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() |
| | |
| | | |
| | | MAX_L2_CHANNEL_COUNT = 10 |
| | | |
| | | LOG_DIR = "sell_logs" |
| | | |
| | | # 获取根路径 |
| | | def get_path_prefix(): |
| | | return 'D:' if is_windows() else '/home/userzjj' |
| | |
| | | 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: |
| | |
| | | "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): |
| | |
| | | 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) |
| | |
| | | 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 |
| | | |