diff --git a/backend/app/data/market_breadth_client.py b/backend/app/data/market_breadth_client.py index e3204831..e0d2247b 100644 --- a/backend/app/data/market_breadth_client.py +++ b/backend/app/data/market_breadth_client.py @@ -24,6 +24,7 @@ logger = logging.getLogger(__name__) ZT_POOL_URL = "https://push2ex.eastmoney.com/getTopicZTPool" DT_POOL_URL = "https://push2ex.eastmoney.com/getTopicDTPool" +MIN_RELIABLE_SAMPLE_COUNT = 4500 async def get_market_breadth() -> MarketBreadth: @@ -34,7 +35,7 @@ async def get_market_breadth() -> MarketBreadth: return cached quotes = await get_a_share_realtime_ranking(page_size=6000) - if quotes and len(quotes) >= 3000: + if quotes and len(quotes) >= MIN_RELIABLE_SAMPLE_COUNT: up_count = sum(1 for q in quotes if q.get("pct_chg", 0) > 0) down_count = sum(1 for q in quotes if q.get("pct_chg", 0) < 0) flat_count = sum(1 for q in quotes if q.get("pct_chg", 0) == 0) @@ -55,7 +56,11 @@ async def get_market_breadth() -> MarketBreadth: cache.set(cache_key, breadth, ttl=60) return breadth - logger.warning("市场广度实时样本不足,quotes=%s", len(quotes)) + logger.warning( + "市场广度实时样本不足,quotes=%s,小于可靠阈值 %s,回退到基线口径", + len(quotes), + MIN_RELIABLE_SAMPLE_COUNT, + ) breadth = MarketBreadth( trade_date=today_trade_date(), total_count=len(quotes), diff --git a/backend/app/llm/strategy_selector.py b/backend/app/llm/strategy_selector.py index c91ff944..8b304033 100644 --- a/backend/app/llm/strategy_selector.py +++ b/backend/app/llm/strategy_selector.py @@ -31,6 +31,8 @@ class StrategyProfile(BaseModel): market_stance: str = "" decision_note: str = "" notes: list[str] = [] + feedback_applied: bool = False + feedback_notes: list[str] = [] generated_by: str = "rules" @@ -165,6 +167,7 @@ async def _apply_strategy_feedback(profile: StrategyProfile) -> StrategyProfile: return profile updated = profile.model_copy(deep=True) + updated.feedback_applied = True if controls.get("force_defensive"): updated.allow_trading = False @@ -180,6 +183,7 @@ async def _apply_strategy_feedback(profile: StrategyProfile) -> StrategyProfile: notes = controls.get("notes") or [] if notes: + updated.feedback_notes = notes[:3] updated.notes.extend(notes[:2]) updated.decision_note = notes[0] diff --git a/frontend/src/app/(auth)/dashboard/page.tsx b/frontend/src/app/(auth)/dashboard/page.tsx index e70ce218..fd5a7503 100644 --- a/frontend/src/app/(auth)/dashboard/page.tsx +++ b/frontend/src/app/(auth)/dashboard/page.tsx @@ -268,6 +268,7 @@ export default function DashboardPage() { void; @@ -505,6 +508,19 @@ function AdminPanel({ + {strategyProfile?.feedback_applied ? ( +
+
反馈回写已生效
+
+ {(strategyProfile.feedback_notes?.length ? strategyProfile.feedback_notes : strategyProfile.notes || []).slice(0, 3).map((note, index) => ( +
+ {note} +
+ ))} +
+
+ ) : null} +