feat: expand screeners and stabilize interactive feedback
This commit is contained in:
+15
-3
@@ -13,6 +13,8 @@ COMPONENT_WEIGHTS = {
|
||||
"liquidity": 10,
|
||||
}
|
||||
|
||||
SENTIMENT_ENGINE_VERSION = 2
|
||||
|
||||
|
||||
def _number(value: Any, default: float = 0.0) -> float:
|
||||
try:
|
||||
@@ -43,7 +45,7 @@ def _percentile(value: float, history: list[float]) -> float:
|
||||
def _adaptive_score(value: float, fixed: float, history: list[float]) -> float:
|
||||
if len(history) < 20:
|
||||
return fixed
|
||||
return fixed * 0.4 + _percentile(value, history[-120:]) * 0.6
|
||||
return fixed * 0.25 + _percentile(value, history[-250:]) * 0.75
|
||||
|
||||
|
||||
def _trade_date(payload: dict[str, Any]) -> str:
|
||||
@@ -274,7 +276,9 @@ def build_sentiment_history(snapshots: list[dict[str, Any]]) -> list[dict[str, A
|
||||
systemic_health = breadth_score * 0.60 + down_relief * 0.40
|
||||
systemic_gate = 1.0 if systemic_health >= 35 else 0.35 + systemic_health / 35 * 0.65
|
||||
ecology_base_score = limit_strength * 0.35 + seal_quality * 0.35 + down_relief * 0.30
|
||||
limit_ecology_score = ecology_base_score * (0.25 + systemic_gate * 0.75)
|
||||
# Systemic risk is applied once to the final temperature. Reapplying it here
|
||||
# would count market breadth and limit-down pressure twice.
|
||||
limit_ecology_score = ecology_base_score
|
||||
|
||||
if stats["previous_limit_count"]:
|
||||
positive_score = float(stats["previous_positive_rate"])
|
||||
@@ -357,6 +361,11 @@ def build_sentiment_history(snapshots: list[dict[str, Any]]) -> list[dict[str, A
|
||||
else None
|
||||
)
|
||||
day_change = score - float(previous_result["score"]) if previous_result else 0.0
|
||||
ema_score = round(
|
||||
score if not previous_result
|
||||
else score * 0.5 + float(previous_result.get("ema_score", previous_result["score"])) * 0.5,
|
||||
1,
|
||||
)
|
||||
phase_signal = _phase_signal(score, momentum, profit_effect_score)
|
||||
fermentation_ready = (
|
||||
phase_signal == "发酵"
|
||||
@@ -428,6 +437,7 @@ def build_sentiment_history(snapshots: list[dict[str, Any]]) -> list[dict[str, A
|
||||
{
|
||||
**stats,
|
||||
"score": score,
|
||||
"ema_score": ema_score,
|
||||
"label": _sentiment_label(score),
|
||||
"phase": phase,
|
||||
"phase_signal": phase_signal,
|
||||
@@ -436,7 +446,7 @@ def build_sentiment_history(snapshots: list[dict[str, Any]]) -> list[dict[str, A
|
||||
"day_change": round(day_change, 1),
|
||||
"direction": direction,
|
||||
"momentum": round(momentum, 1),
|
||||
"normalization": normalization,
|
||||
"normalization": "250日历史百分位" if len(previous) >= 20 else normalization,
|
||||
"history_days": len(previous) + 1,
|
||||
"systemic_health": round(systemic_health, 1),
|
||||
"risk_multiplier": round(systemic_gate, 3),
|
||||
@@ -474,10 +484,12 @@ def apply_sentiment_to_dashboard(
|
||||
overview.update(
|
||||
{
|
||||
"sentiment_score": sentiment["score"],
|
||||
"sentiment_trend_score": sentiment["ema_score"],
|
||||
"sentiment_label": sentiment["label"],
|
||||
"sentiment_phase": sentiment["phase"],
|
||||
"sentiment_direction": sentiment["direction"],
|
||||
"sentiment_components": sentiment["components"],
|
||||
"sentiment_engine_version": SENTIMENT_ENGINE_VERSION,
|
||||
}
|
||||
)
|
||||
result["overview"] = overview
|
||||
|
||||
Reference in New Issue
Block a user