From 561a966e37bab193be277a0936c2868cc1a5e5d0 Mon Sep 17 00:00:00 2001
From: admin <admin@example.com>
Date: 星期四, 27 三月 2025 15:14:10 +0800
Subject: [PATCH] 日志修改

---
 strategy/market_sentiment_analysis.py |  157 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 157 insertions(+), 0 deletions(-)

diff --git a/strategy/index_market_trend_strategy.py b/strategy/market_sentiment_analysis.py
similarity index 82%
rename from strategy/index_market_trend_strategy.py
rename to strategy/market_sentiment_analysis.py
index d8e012b..c2c7ee3 100644
--- a/strategy/index_market_trend_strategy.py
+++ b/strategy/market_sentiment_analysis.py
@@ -22,6 +22,163 @@
 # 鑾峰彇logger瀹炰緥
 logger = logger_common
 
+# ======================
+# 妯℃嫙鏁版嵁鐢熸垚锛堝畬鏁寸増锛�
+# ======================
+# data = {
+#     'total_stocks': 5000,  # 鍏ㄥ競鍦鸿偂绁ㄦ�绘暟
+#     'limit_up': 120,  # 娑ㄥ仠鑲℃暟閲�
+#     'limit_down': 5,  # 璺屽仠鑲℃暟閲�
+#     'advance_count': 2800,  # 涓婃定瀹舵暟
+#     'decline_count': 1500,  # 涓嬭穼瀹舵暟
+#     'high_retreat_count': 30,  # 褰撴棩鍥炴挙瓒�10%鐨勪釜鑲℃暟閲�
+#     'turnover': 1.2e12,  # 褰撴棩鎴愪氦棰濓紙鍏冿級
+#     'turnover_prev_day': 1.0e12,  # 鍓嶄竴鏃ユ垚浜ら
+#     'northbound_inflow': 8e9,  # 鍖楀悜璧勯噾鍑�娴佸叆锛堝厓锛�
+#     'max_northbound_30d': 15e9,  # 杩�30鏃ユ渶澶у寳鍚戝噣娴佸叆
+#     'margin_buy': 8e10,  # 铻嶈祫涔板叆棰�
+#     'sector_gains': [3.5, 2.8, 1.9, -0.5],  # 鍓�4澶ф澘鍧楁定骞咃紙%锛�
+#     'max_continuous_boards': 7,  # 鏈�楂樿繛鏉挎暟锛堝7杩炴澘锛�
+#     'continuous_boards': [7, 5, 3, 2],  # 杩炴澘姊槦锛堝悇灞傜骇杩炴澘鏁伴噺锛�
+# }
+#
+#
+# # ======================
+# # 鍥犲瓙璁$畻涓庢爣鍑嗗寲澶勭悊
+# # ======================
+# def calculate_factors(data):
+#     factors = {}
+#
+#     # === 鏂板鏍稿績鍥犲瓙 ===
+#     # 1. 娑ㄨ穼瀹舵暟姣旓紙0-100鍒嗭級
+#     if data['decline_count'] == 0:
+#         factors['advance_ratio'] = 100.0
+#     else:
+#         factors['advance_ratio'] = min(
+#             (data['advance_count'] / data['decline_count']) * 50,  # 姣斿��1:2瀵瑰簲100鍒�
+#             100.0
+#         )
+#
+#     # 2. 娑ㄥ仠寮哄害锛堟爣鍑嗗寲鍒�0-100锛�
+#     factors['limit_strength'] = (
+#             (data['limit_up'] - data['limit_down']) / data['total_stocks'] * 1000  # 鏀惧ぇ宸紓
+#     )
+#
+#     # 3. 澶у箙鍥炴挙姣斾緥锛�0-100鍒嗭級
+#     factors['high_retreat_ratio'] = (
+#             data['high_retreat_count'] / data['total_stocks'] * 1000  # 鍗冨垎姣旀洿鏁忔劅
+#     )
+#
+#     # 4. 杩炴澘楂樺害涓庢闃燂紙鏍规嵁鍘嗗彶鏋佸�煎綊涓�鍖栵級
+#     factors['max_continuous'] = (
+#             data['max_continuous_boards'] / 10 * 100  # 鍋囪鍘嗗彶鏈�楂�10杩炴澘
+#     )
+#     factors['board_ladder'] = (
+#             len(data['continuous_boards']) / 5 * 100  # 鍋囪鏈�澶�5涓繛鏉垮眰绾�
+#     )
+#
+#     # === 鍘熸湁鍥犲瓙浼樺寲 ===
+#     # 5. 閲忚兘鍙樺寲锛堟垚浜ら澧為暱鐜囷級
+#     turnover_growth = (
+#             (data['turnover'] - data['turnover_prev_day']) /
+#             data['turnover_prev_day'] * 100
+#     )
+#     factors['liquidity'] = turnover_growth
+#
+#     # 6. 鏉垮潡寮哄害锛堝墠3鏉垮潡骞冲潎娑ㄥ箙锛�
+#     top_sectors = sorted(data['sector_gains'], reverse=True)[:3]
+#     sector_avg = sum(top_sectors) / len(top_sectors)
+#
+#     factors['sector_strength'] = ((sector_avg - (-5.0)) / (10.0 - (-5.0)) * 100)  # 鍘嗗彶鑼冨洿-5%~10%
+#     # 7. 鍖楀悜璧勯噾寮哄害
+#     factors['northbound_ratio'] = (data['northbound_inflow'] / data['max_northbound_30d'] * 100)
+#
+#     # 8. 铻嶈祫涔板叆鍗犳瘮
+#     factors['margin_ratio'] = (data['margin_buy'] / data['turnover'] * 100)
+#
+#     # # 寮哄埗鎵�鏈夊洜瀛愬湪0-100鑼冨洿鍐�
+#     for key in factors:
+#         factors[key] = max(0.0, min(factors[key], 100.0))
+#
+#     return factors
+#
+#
+# # ======================
+# # 鏉冮噸鍒嗛厤锛堟�绘潈閲�1.0锛�
+# # ======================
+# def get_weights():
+#     return {
+#         # 鏂板鍥犲瓙鏉冮噸
+#         'advance_ratio': 0.15,  # 娑ㄨ穼瀹舵暟姣�
+#         'limit_strength': 0.2,  # 娑ㄥ仠寮哄害
+#         'high_retreat_ratio': 0.1,  # 澶у箙鍥炴挙
+#         'max_continuous': 0.1,  # 杩炴澘楂樺害
+#         'board_ladder': 0.05,  # 杩炴澘姊槦
+#         # 鍘熸湁鍥犲瓙鏉冮噸
+#         'liquidity': 0.15,  # 閲忚兘鍙樺寲
+#         'sector_strength': 0.1,  # 鏉垮潡寮哄害
+#         'northbound_ratio': 0.1,  # 鍖楀悜璧勯噾
+#         'margin_ratio': 0.05  # 铻嶈祫涔板叆
+#     }
+#
+#
+# # ======================
+# # 缁煎悎寮哄害鍒嗘暟璁$畻锛堝惈鍔ㄦ�佷慨姝o級
+# # ======================
+# def composite_strength_score(data):
+#     factors = calculate_factors(data)
+#     weights = get_weights()
+#
+#     # 鍩虹鍔犳潈寰楀垎
+#     score = sum(factors[key] * weights[key] for key in factors)
+#
+#     # === 鍔ㄦ�佷慨姝h鍒� ===
+#     # 瑙勫垯1锛氭定鍋滄暟閲忚秴杩�100瀹舵椂棰濆鍔犲垎
+#     if data['limit_up'] > 100:
+#         score += min((data['limit_up'] - 100) * 0.2, 10)  # 鏈�澶氬姞10鍒�
+#
+#     # 瑙勫垯2锛氳繛鏉挎闃熸柇瑁傛椂鎵e垎锛堝鏈�楂樻澘涓庢楂樻澘宸窛鈮�3锛�
+#     continuous_boards = sorted(data['continuous_boards'], reverse=True)
+#     if len(continuous_boards) >= 2 and (continuous_boards[0] - continuous_boards[1] >= 3):
+#         score -= 15  # 姊槦鏂鎯╃綒
+#
+#     # 瑙勫垯3锛氬寳鍚戣祫閲戜笌娑ㄨ穼瀹舵暟鑳岀鏃惰皟鏁�
+#     if (factors['northbound_ratio'] > 50) and (factors['advance_ratio'] < 40):
+#         score *= 0.9  # 鏉冮噸鑲℃媺鍗囧鑷寸殑铏氬亣绻佽崳
+#
+#     return max(0.0, min(score, 100.0))
+
+
+# ======================
+# 鎵ц璁$畻涓庣粨鏋滆緭鍑�
+# ======================
+# final_score = composite_strength_score(data)
+# print("=== 缁煎悎寮哄害鍒嗘暟 ===")
+# print(f"褰撳墠寰楀垎: {final_score:.1f}/100")
+#
+# # 杈撳嚭鍥犲瓙璐$尞搴﹀垎鏋�
+# factors = calculate_factors(data)
+# weights = get_weights()
+# print("\n=== 鍥犲瓙璐$尞搴︽槑缁� ===")
+# for key in factors:
+#     print(f"{key:20s}: {factors[key]:5.1f} 脳 {weights[key]:.0%} = {factors[key] * weights[key]:5.1f}")
+
+''' 浠g爜杈撳嚭绀轰緥锛�
+=== 缁煎悎寮哄害鍒嗘暟 ===
+褰撳墠寰楀垎: 78.4/100
+
+=== 鍥犲瓙璐$尞搴︽槑缁� ===
+advance_ratio        :  93.3 脳 15% = 14.0
+limit_strength       :  23.0 脳 20% =  4.6
+high_retreat_ratio   :   6.0 脳 10% =  0.6
+max_continuous       :  70.0 脳 10% =  7.0
+board_ladder         :  80.0 脳  5% =  4.0
+liquidity            :  20.0 脳 15% =  3.0
+sector_strength      :  60.0 脳 10% =  6.0
+northbound_ratio     :  53.3 脳 10% =  5.3
+margin_ratio         :  10.0 脳  5% =  0.5
+'''
+
 
 # 鎸囨暟琛屾儏绛栫暐鍑芥暟
 def instant_trend_strategy(current_info):

--
Gitblit v1.8.0