From 8c51895ecab1de9c6faf664d389168473951f3bd Mon Sep 17 00:00:00 2001 From: admin <admin@example.com> Date: 星期三, 26 三月 2025 13:52:10 +0800 Subject: [PATCH] 日志修改 --- data_server.py | 40 ++++++++++++++++++++++------------------ 1 files changed, 22 insertions(+), 18 deletions(-) diff --git a/data_server.py b/data_server.py index 3ff89f3..890f79a 100644 --- a/data_server.py +++ b/data_server.py @@ -11,7 +11,7 @@ from db import redis_manager_delegate as redis_manager, mysql_data_delegate as mysql_data from db.redis_manager_delegate import RedisUtils -from log_module.log import hx_logger_l2_transaction, logger_debug +from log_module.log import hx_logger_l2_transaction, logger_debug, logger_request_api from strategy import data_cache from strategy.trade_setting import TradeSetting from trade import huaxin_trade_api, huaxin_trade_data_update @@ -219,6 +219,7 @@ result_str = json.dumps({"code": 1001, "msg": "绛惧悕閿欒"}) return print("涔板叆", params) + logger_request_api.info(f"涔板叆锛歿params}") # 涔板叆 code = params.get("code") # 浠g爜 volume = params.get("volume") # 閲� @@ -243,23 +244,26 @@ result_str = json.dumps({"code": 1001, "msg": "绛惧悕閿欒"}) return # 鍗栧嚭 - print("鍗栧嚭", params) - code = params.get("code") # 浠g爜 - volume = params.get("volume") # 閲� - price = params.get("price") - if not price: - # 娌℃湁涓婁紶浠锋牸锛屽氨闇�瑕佽幏鍙栨渶杩戠殑浠锋牸杩涜涔板叆 - data = data_cache.latest_code_market_info_dict.get(code) - if not data: - raise Exception("娌℃湁鑾峰彇鍒癓1鏁版嵁") - pre_price = data[1] - current_price = data[2] if data[2] else data[5][0][0] - price = tool.get_buy_min_price(current_price) - price = max(price, tool.get_limit_down_price(code, pre_price)) - else: - price = round(params.get("price"), 2) # 浠锋牸 - result = huaxin_trade_api.order(2, code, volume, price, blocking=True) - result_str = json.dumps(result) + try: + print("鍗栧嚭", params) + code = params.get("code") # 浠g爜 + volume = params.get("volume") # 閲� + price = params.get("price") + if not price: + # 娌℃湁涓婁紶浠锋牸锛屽氨闇�瑕佽幏鍙栨渶杩戠殑浠锋牸杩涜涔板叆 + data = data_cache.latest_code_market_info_dict.get(code) + if not data: + raise Exception("娌℃湁鑾峰彇鍒癓1鏁版嵁") + pre_price = data[1] + current_price = data[2] if data[2] else data[5][0][0] + price = tool.get_buy_min_price(current_price) + price = max(price, tool.get_limit_down_price(code, pre_price)) + else: + price = round(params.get("price"), 2) # 浠锋牸 + result = huaxin_trade_api.order(2, code, volume, price, blocking=True) + result_str = json.dumps(result) + finally: + logger_request_api.info(f"鍗栧嚭锛歿params}") elif url.path == "/set_buy_money": # 璁剧疆姣忔涔板叆鐨勯噾棰� -- Gitblit v1.8.0