Administrator
2025-05-28 1a9060fd3373df54b6908ad234587f93a62d14fd
servers/data_server.py
@@ -9,10 +9,12 @@
import requests
import constant
import inited_data
from code_attribute.gpcode_manager import BlackListCodeManager, HumanRemoveForbiddenManager
from l2.huaxin import huaxin_target_codes_manager
from l2.l2_transaction_data_manager import HuaXinBuyOrderManager
from log_module.log import logger_system, logger_debug, logger_kpl_limit_up, logger_request_api
from log_module.log import logger_system, logger_debug, logger_kpl_limit_up, logger_request_api, \
    logger_kpl_market_strong, logger_kpl_new_blocks
from third_data.custom_block_in_money_manager import CodeInMoneyManager
from third_data.kpl_data_constant import LimitUpCodesBlockRecordManager, LimitUpDataConstant, \
    ContainsLimitupCodesBlocksManager
@@ -23,7 +25,7 @@
from trade.buy_radical.new_block_processor import BeforeBlocksComputer
from trade.buy_strategy import OpenLimitUpGoodBlocksBuyStrategy
from trade.buy_radical.radical_buy_data_manager import RadicalBuyBlockManager, BeforeSubDealBigOrderManager
from utils import global_util, tool, data_export_util
from utils import global_util, tool, data_export_util, init_data_util
from code_attribute import gpcode_manager, code_nature_analyse
from log_module import log_analyse, log_export, async_log_util
from l2 import code_price_manager, l2_data_util, transaction_progress
@@ -808,8 +810,9 @@
                deals_month = trade_data_manager.AccountMoneyManager().get_deal_count_info(start_date, end_date)
                cost_month = sum([round(0.1 * x[1], 2) for x in delegates_month])
                make_month = 0
                make_month += max(1 * deals_month[0][1] if deals_month[0][1] else 0, deals_month[0][2] * 1.854 / 10000 if deals_month[0][2] else 0) + 1 * deals_month[1][
                    1] + 0 * deals_month[2][1]
                make_month += max(1 * deals_month[0][1] if deals_month[0][1] else 0,
                                  deals_month[0][2] * 1.854 / 10000 if deals_month[0][2] else 0) + 1 * deals_month[1][
                                  1] + 0 * deals_month[2][1]
                fdata["month_commission"] = round(make_month - cost_month, 2)
                # 计算当日手续费详情
                delegates = trade_data_manager.AccountMoneyManager().get_delegated_count_info()
@@ -959,13 +962,20 @@
                                 big_money_rate * 100  # 大单成交比
                                 ),
                                output_util.money_desc(deal_big_money_info[1]),
                                output_util.money_desc(deal_big_money_info[2])]
                                output_util.money_desc(deal_big_money_info[2]),
                                output_util.money_desc(deal_big_money_info[3]),
                            ]
                            if len(codes) == 1:
                                # 加载大单详情
                                deal_big_order_detail_info = radical_buy_data_manager.get_l2_big_order_deal_info(code)
                                # 加载涨停大单详情
                                limit_up_big_order_detail = radical_buy_data_manager.get_total_detal_big_order_details(
                                    code)
                                if max(limit_up_big_order_detail) == 0:
                                    # 没有数据,从网络加载
                                    limit_up_big_order_detail = list(limit_up_big_order_detail)
                                    limit_up_big_order_detail[1] = deal_big_order_detail_info[1][0]
                                    limit_up_big_order_detail[3] = deal_big_order_detail_info[2][0]
                                deal_big_order_info.append(
                                    output_util.money_desc(limit_up_big_order_detail[0] + limit_up_big_order_detail[1]))
                                deal_big_order_info.append(
@@ -975,6 +985,8 @@
                        except Exception as e:
                            logger_debug.error(f"可能没有获取到涨停价:{code}")
                            if not gpcode_manager.get_limit_up_price(code):
                                init_data_util.re_set_price_pre(code)
                            # logger_debug.exception(e)
                            deal_big_order_info = None
                        code_name = gpcode_manager.get_code_name(code)
@@ -1037,7 +1049,11 @@
                @return:
                """
                yesterday_codes = kpl_data_manager.get_yesterday_limit_up_codes()
                blocks = set()
                for bi in blocks_info:
                    if bi[0] in blocks:
                        continue
                    blocks.add(bi[0])
                    result = kpl_api.getCodesByPlate(bi[1])
                    result = json.loads(result)
                    code_info_list = []
@@ -1046,14 +1062,18 @@
                            continue
                        # 涨幅要大于5%
                        rate = d[6] / int(round((tool.get_limit_up_rate(d[0]) - 1) * 10))
                        if rate/((tool.get_limit_up_rate(d[0])-1)*10) < 5:
                        if rate / ((tool.get_limit_up_rate(d[0]) - 1) * 10) < 5:
                            continue
                        # 格式:(代码,涨幅)
                        code_info_list.append((d[0], d[6]))
                    # 保存新题材
                    datas = [(d[0], d[6]) for d in result["list"]]
                    async_log_util.info(logger_kpl_new_blocks, f"{(tool.get_thread_id(), bi, datas)}")
                    if code_info_list:
                        # 将代码加入新题材
                        new_block_processor.process_new_block_by_component_codes(bi[0], set([x[0] for x in code_info_list]), all_new_blocks)
                        new_block_processor.process_new_block_by_component_codes(bi[0],
                                                                                 set([x[0] for x in code_info_list]),
                                                                                 all_new_blocks)
            try:
                if result_list_:
@@ -1129,7 +1149,9 @@
                    try:
                        # 新题材
                        new_block_codes = new_block_processor.screen_new_blocks_with_limit_up_datas([(x[0], x[5]) for x in result_list_])
                        new_block_processor.process_limit_up_list({x[0]: x[5] for x in result_list_})
                        new_block_codes = new_block_processor.screen_new_blocks_with_limit_up_datas(
                            [(x[0], x[5]) for x in result_list_])
                        if new_block_codes:
                            # 统计板块的代码
                            records = KPLLimitUpDataRecordManager.total_datas
@@ -1149,8 +1171,8 @@
                                # 需要获取板块下的代码
                                self.__new_blocks_codes_request_thread_pool.submit(
                                    lambda: request_new_blocks_codes(update_new_block_plates, new_block_codes.keys()))
                    except:
                        pass
                    except Exception as e:
                        logger_debug.exception(e)
                    self.__kplDataManager.save_data(type_, result_list_)
            except Exception as e:
                logger_debug.exception(e)
@@ -1230,11 +1252,10 @@
                RealTimeKplMarketData.set_market_jingxuan_out_blocks(result_list)
        elif type_ == KPLDataType.MARKET_STRONG.value:
            strong = data["data"]
            logger_debug.debug("开盘啦市场强度:{}", strong)
            logger_kpl_market_strong.info(strong)
            # 保存市场热度
            if strong is not None:
                RealTimeKplMarketData.set_market_strong(strong)
        return json.dumps({"code": 0})
    def __send_response(self, data):