From 0b8d40a005ec3bdee63f80eca3490e3dea6ec4e7 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期二, 17 六月 2025 11:20:24 +0800 Subject: [PATCH] ‘功能完善 --- api/outside_api_callback.py | 51 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 48 insertions(+), 3 deletions(-) diff --git a/api/outside_api_callback.py b/api/outside_api_callback.py index 85655a4..be5a8fe 100644 --- a/api/outside_api_callback.py +++ b/api/outside_api_callback.py @@ -3,11 +3,13 @@ import threading from api.outside_api_command_manager import ActionCallback +from huaxin_client import l1_subscript_codes_manager from huaxin_client.client_network import SendResponseSkManager from strategy import strategy_params_settings, env_info from strategy.env_info import RealTimeEnvInfo from strategy.strategy_variable_factory import DataLoader from third_data.history_k_data_manager import TradeDateManager +from third_data.kpl_block_manager import KPLCodeJXBlocksManager from utils import socket_util, middle_api_protocol, tool @@ -43,8 +45,20 @@ 鑾峰彇浜ゆ槗鍙傛暟 @return: """ - result = strategy_params_settings.settings.to_json_str() - return {"code": 0, "data": result} + result = strategy_params_settings.StrategyParamsSettingsManager().get_settings().to_json_str() + return {"code": 0, "data": json.loads(result)} + + def __on_set_settings(self, data): + """ + 璁剧疆浜ゆ槗鍙傛暟 + @return: + """ + settings = strategy_params_settings.StrategyParamsSettingsManager().get_settings() + for k in data: + settings.__setattr__(k, data[k]) + strategy_params_settings.StrategyParamsSettingsManager().set_settings(settings) + # 鍚屾鍙傛暟璁剧疆 + return {"code": 0, "data": {}} def __on_get_env(self, need_hsitory_data): """ @@ -64,7 +78,8 @@ else: # 濡傛灉鍦�16:00涔嬪悗閲囩敤涓嬩竴涓氦鏄撴棩 day = TradeDateManager().get_next_trade_day(tool.get_now_date_str()) - fdata["history_data"]["leading_limit_up_block_codes_count"] = env_info.get_leading_limit_up_block_codes_count( + fdata["history_data"][ + "leading_limit_up_block_codes_count"] = env_info.get_leading_limit_up_block_codes_count( day) if tool.get_now_time_str() < '16:00:00': @@ -74,6 +89,11 @@ # 濡傛灉鍦�16:00涔嬪悗閲囩敤涓嬩竴涓氦鏄撴棩 day = tool.get_now_date_str() fdata["history_data"]["k_bars_count"] = env_info.get_history_k_bars(day) + + day = tool.get_now_date_str() + fdata["history_data"]["kpl_code_jx_blocks_count"] = env_info.get_kpl_code_jx_blocks(day) + + return {"code": 0, "data": fdata, "msg": "娴嬭瘯缁撴灉"} def __on_update_leading_limit_up_datas(self): @@ -98,13 +118,38 @@ threading.Thread(target=lambda: update(), daemon=True).start() return {"code": 0} + def __on_update_kpl_code_jx_blocks_datas(self): + """ + 鏇存柊寮�鐩樺暒绮鹃�夋澘鍧楁暟鎹� + @return: + """ + + def update(): + codes = set() + codes_sh, codes_sz = l1_subscript_codes_manager.get_codes() + codes |= set([x.decode() for x in codes_sh]) + codes |= set([x.decode() for x in codes_sz]) + KPLCodeJXBlocksManager(day, codes).start_download_blocks() + # 濡傛灉鍦�16:00涔嬪墠閲囩敤褰撳墠鏃ユ湡 + day = tool.get_now_date_str() + threading.Thread(target=lambda: update(), daemon=True).start() + return {"code": 0} + def OnCommonRequest(self, client_id, request_id, data): ctype = data["ctype"] result_json = {} if ctype == "get_settings": result_json = self.__on_get_settings() + elif ctype == 'set_settings': + del data["ctype"] + result_json = self.__on_set_settings(data) elif ctype == 'get_env': + # 鑾峰彇鐜鏁版嵁 result_json = self.__on_get_env(data.get("history")) elif ctype == 'update_leading_limit_up_datas': + # 鏇存柊棰嗘定鏁版嵁 result_json = self.__on_update_leading_limit_up_datas() + elif ctype == 'update_kpl_code_jx_blocks_datas': + # 鏇存柊寮�鐩樺暒绮鹃�夋暟鎹� + result_json = self.__on_update_kpl_code_jx_blocks_datas() self.send_response(result_json, client_id, request_id) -- Gitblit v1.8.0