From 2f2516749615da866e96d8d24e499b7ecbb63a3e Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期一, 23 六月 2025 12:28:52 +0800 Subject: [PATCH] 默认交易模式变更/真实下单位置计算位置修改 --- servers/data_server.py | 107 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 90 insertions(+), 17 deletions(-) diff --git a/servers/data_server.py b/servers/data_server.py index aca2244..a548267 100644 --- a/servers/data_server.py +++ b/servers/data_server.py @@ -9,10 +9,13 @@ import requests import constant +import inited_data +from api import low_suction_data_pusher 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 +26,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 +811,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() @@ -945,8 +949,39 @@ th_sell = BeforeSubDealBigOrderManager().get_big_sell_order_threshold(code) except: th_sell = 0 + + # (缂哄皯鐨勮祫閲�, 鍑�鎴愪氦閲戦, 瑕佹眰鐨勫ぇ鍗曢噾棰�, 璁$畻寰楀埌鐨勫ぇ鍗曢槇鍊奸噾棰�, 浜轰负璁剧疆鐨勫ぇ鍗�) deal_big_money_info = radical_buy_data_manager.get_total_deal_big_order_info( code, gpcode_manager.get_limit_up_price_as_num(code)) + if deal_big_money_info[1] == 0 and len(codes) == 1: + # 鎬绘垚浜ら噾棰濅负0 + deal_big_money_info = list(deal_big_money_info) + # 娌℃湁璁㈤槄L2浼氬嚭鐜版病鏈夊�肩殑鎯呭喌锛屽鏋滄定鍋滆繃灏辨媺鍙栦箣鍓嶇殑娑ㄥ仠涔�/鍗栧ぇ鍗� + deal_big_orders_result = radical_buy_data_manager.request_deal_big_orders(code) + if deal_big_orders_result: + buy_datas, sell_datas = deal_big_orders_result[0], deal_big_orders_result[1] + limit_up_price = gpcode_manager.get_limit_up_price_as_num(code) + limit_up_price_money_list = [x[0] for x in buy_datas if x[1] == limit_up_price] + if limit_up_price_money_list: + threshold_money = BeforeSubDealBigOrderManager().compute_re_limit_up_big_money_threshold( + limit_up_price_money_list) + else: + threshold_money = 299e4 + logger_debug.info(f"{code}-涓存椂鍥炲皝鍧囧ぇ鍗曪細{threshold_money}") + # 璁剧疆涔板崟闃堝�� + th_buy = threshold_money + buy_money = sum(limit_up_price_money_list) + sell_money = sum([x[0] for x in sell_datas if x[1] == limit_up_price]) + # 娑ㄥ仠涔板噣鎴愪氦閲戦鍑�涔伴 + deal_big_money_info[1] = buy_money - sell_money + # 瑕佹眰鐨勫ぇ鍗曠疮璁¢噾棰� + deal_big_money_info[ + 2] = radical_buy_data_manager.compute_total_deal_big_order_threshold_money(code, + limit_up_price, + threshold_money) + # logger_debug.info(f"{code}-绱澶у崟闃堝�硷細{deal_big_money_info[2]}") + # logger_debug.info(f"{code}闈炶闃呭ぇ鍗曪紝 buy_money-{buy_money}, sell_money-{sell_money}") + big_money_rate = radical_buy_data_manager.TotalDealBigOrderInfoManager.get_big_order_rate( code) if not big_money_rate: @@ -958,27 +993,49 @@ output_util.money_desc(th_sell), # 鍗栧崟闃堝�� 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]), + # 浜轰负璁剧疆鐨勫ぇ鍗� + output_util.money_desc(deal_big_money_info[4]) if deal_big_money_info[4] else '', + ] 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) - 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( - output_util.money_desc(limit_up_big_order_detail[2] + limit_up_big_order_detail[3])) + # 绱娑ㄥ仠涔伴噾棰� + buy_money = output_util.money_desc(limit_up_big_order_detail[0] + limit_up_big_order_detail[1]) + sell_money = output_util.money_desc(limit_up_big_order_detail[2] + limit_up_big_order_detail[3]) + deal_big_order_info.append(buy_money) + # 绱娑ㄥ仠鍗栭噾棰� + deal_big_order_info.append(sell_money) deal_big_order_info.append( radical_buy_data_manager.TotalDealBigOrderInfoManager().get_big_order_rate(code)) except Exception as e: logger_debug.error(f"鍙兘娌℃湁鑾峰彇鍒版定鍋滀环锛歿code}") - # logger_debug.exception(e) + 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) - fresults.append((code, code_name, deal_big_order_info, deal_big_order_detail_info)) + + big_order_enough = 0 + try: + total_deal_big_order_result = radical_buy_data_manager.get_total_deal_big_order_info(code, + gpcode_manager.get_limit_up_price_as_num( + code)) + if total_deal_big_order_result and total_deal_big_order_result[0]<=0: + big_order_enough = 1 + except: + pass + fresults.append((code, code_name, deal_big_order_info, deal_big_order_detail_info, big_order_enough)) response_data = json.dumps({"code": 0, "data": fresults}) except Exception as e: response_data = json.dumps({"code": 1, "data": str(1)}) @@ -1037,7 +1094,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 +1107,18 @@ continue # 娑ㄥ箙瑕佸ぇ浜�5% rate = d[6] / int(round((tool.get_limit_up_rate(d[0]) - 1) * 10)) - if rate < 5: + if rate / ((tool.get_limit_up_rate(d[0]) - 1) * 10) < 5: continue # 鏍煎紡锛�(浠g爜,娑ㄥ箙) 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 +1194,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 +1216,15 @@ # 闇�瑕佽幏鍙栨澘鍧椾笅鐨勪唬鐮� self.__new_blocks_codes_request_thread_pool.submit( lambda: request_new_blocks_codes(update_new_block_plates, new_block_codes.keys())) + except Exception as e: + logger_debug.exception(e) + + # 灏嗘暟鎹帹閫佽嚦鍏朵粬椤圭洰 + try: + low_suction_data_pusher.push_limit_up_list(result_list_) except: pass + self.__kplDataManager.save_data(type_, result_list_) except Exception as e: logger_debug.exception(e) @@ -1230,11 +1304,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): -- Gitblit v1.8.0