Administrator
2025-07-01 bccc14e6d890cefb5309c904a6413bea1270ff03
bug修复/策略完善
2个文件已修改
29 ■■■■ 已修改文件
api/outside_api_callback.py 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/strategy_manager.py 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/outside_api_callback.py
@@ -6,11 +6,13 @@
import constant
from api.outside_api_command_manager import ActionCallback
from code_attribute import gpcode_manager
from huaxin_client import l1_subscript_codes_manager
from huaxin_client.client_network import SendResponseSkManager
from strategy import strategy_params_settings, env_info, strategy_manager
from strategy.env_info import RealTimeEnvInfo
from strategy.strategy_manager import PlateWhiteListManager
from strategy.strategy_params_settings import StrategyParamsSettingsManager, StrategyParamsSettings
from strategy.strategy_variable_factory import DataLoader
from third_data.history_k_data_manager import TradeDateManager
from third_data.kpl_block_manager import KPLCodeJXBlocksManager
@@ -22,6 +24,7 @@
OPERRATE_DELETE = 2  # 删除
OPERRATE_GET = 3  # 获取
OPERRATE_ADD = 4  # 新增
class MyAPICallback(ActionCallback):
@@ -170,8 +173,8 @@
    def __on_plate_white_list(self, data):
        operate = data["operate"]
        if operate == OPERRATE_GET:
           plates =   PlateWhiteListManager().get_plates()
           return {"code": 0, "data": list(plates)}
            plates = PlateWhiteListManager().get_plates()
            return {"code": 0, "data": list(plates)}
        elif operate == OPERRATE_ADD:
            plate = data["plate"]
            PlateWhiteListManager().add_plate(plate)
@@ -180,8 +183,6 @@
            plate = data["plate"]
            PlateWhiteListManager().remove_plate(plate)
            return {"code": 0}
    def OnCommonRequest(self, client_id, request_id, data):
        ctype = data["ctype"]
@@ -206,7 +207,22 @@
        elif ctype == 'get_place_order_records':
            # 获取下单记录
            datas = trade_record_log_util.get_trade_records(trade_record_log_util.TYPE_PLACE_ORDER)
            for data in datas:
                data[3]["code_name"] = gpcode_manager.CodesNameManager().get_code_name(data[3]["code"])
            result_json = {"code": 0, "data": datas}
        elif ctype == 'get_can_buy_plates':
            # 获取可以买的板块
            settings: StrategyParamsSettings = StrategyParamsSettingsManager().get_settings()
            try:
                current_limit_up_plate_codes = strategy_manager.low_suction_strtegy.current_limit_up_plate_codes
                plates = [plate for plate, codes in current_limit_up_plate_codes.items() if
                          len(codes) >= settings.limit_up_count_of_new_plate]
            except:
                plates = []
            result_json = {"code": 0, "data": plates}
        elif ctype == 'plate_white_list':
            result_json = self.__on_plate_white_list(data)
        self.send_response(result_json, client_id, request_id)
strategy/strategy_manager.py
@@ -107,6 +107,7 @@
    """
    板块白名单管理
    """
    def __init__(self):
        self.__plate_white_list = set()
        self.__db = 13
@@ -472,7 +473,7 @@
                                                                                                 time_str=tool.get_now_time_str(),
                                                                                                 price=sv.当前价,
                                                                                                 rate=round((
                                                                                                                        sv.当前价 - sv.昨日收盘价) * 100 / sv.昨日收盘价,
                                                                                                                    sv.当前价 - sv.昨日收盘价) * 100 / sv.昨日收盘价,
                                                                                                            2),
                                                                                                 plates=compute_result[
                                                                                                     3],
@@ -484,4 +485,4 @@
# 当前的低吸策略对象
low_suction_strtegy = None
low_suction_strtegy: LowSuctionStrategy = None