Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions src/agent_loop/confidence_calibrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,18 @@ def calibrate(

Adjustments applied in order:
1. Historical accuracy-based adjustment (per-action)
2. Per-sector accuracy adjustment
3. Regime-based adjustment
2. Regime-based adjustment

``sector`` is accepted but not yet used — per-sector calibration needs
sector metadata on the decisions table, which does not exist yet.
"""
adjustment = 0.0

# 1. Action-level calibration
action_adj = self._action_calibration(action)
adjustment += action_adj

# 2. Sector-level calibration
if sector:
sector_adj = self._sector_calibration(sector)
adjustment += sector_adj

# 3. Regime adjustment
# 2. Regime adjustment
regime_adj = self._regime_adjustment(regime, action)
adjustment += regime_adj

Expand All @@ -83,13 +80,12 @@ def calibrate(

if abs(adjustment) > 0.01:
logger.debug(
"Calibration %s %s: %.2f → %.2f (action=%.3f sector=%.3f regime=%.3f)",
"Calibration %s %s: %.2f → %.2f (action=%.3f regime=%.3f)",
action,
symbol,
raw_confidence,
calibrated,
action_adj,
sector_adj if sector else 0.0,
regime_adj,
)

Expand Down Expand Up @@ -263,12 +259,6 @@ def _action_calibration(self, action: str) -> float:
finally:
conn.close()

def _sector_calibration(self, sector: str) -> float:
"""Compute confidence adjustment based on sector-level accuracy."""
# Sector tracking would require joining decisions with thesis/symbol metadata.
# For now, return 0 — will be enhanced when we add sector to decisions table.
return 0.0

def _regime_adjustment(self, regime: str, action: str) -> float:
"""Apply regime-based confidence adjustment."""
adjustments = self._regime_adjustments.get(regime, {})
Expand Down
50 changes: 0 additions & 50 deletions src/prediction/analysis_frameworks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,56 +15,6 @@
import math
from typing import Any

# ---------------------------------------------------------------------------
# Legacy frameworks — DEPRECATED
# Use SEVEN_DIMENSION_FRAMEWORK (full analysis) or QUICK_DIMENSION_FRAMEWORK
# (quick insights) instead. Kept only for backward compatibility.
# ---------------------------------------------------------------------------

PROFESSIONAL_ANALYSIS_FRAMEWORK = """\
You are a professional A-share analyst combining multi-school investment methodologies. \
Follow this framework strictly when analyzing.
Write all output text in Chinese.

## Analysis Methodology

### 1. Quantitative Factor Analysis (AQR / Two Sigma style)
- **Momentum factor**: Recent trend direction, MA alignment (bullish 多头 / bearish 空头 / converging 粘合)
- **Volatility factor**: Recent amplitude changes, Bollinger Band width
- **Volume factor**: Volume ratio changes, price-volume correlation

### 2. Value Investing Check (Buffett framework)
- **Margin of safety**: Is the current valuation level reasonable?
- **Trend confirmation**: Does the medium-to-long term trend support the current judgment?

### 3. Contrarian Thinking Check (Munger framework)
- **Inversion analysis**: What scenarios would invalidate the current judgment?
- **Psychological bias check**: Recency bias (recent moves distorting objectivity), anchoring (fixation on historical highs/lows), herding (is the sector overheated?)
- **Multi-factor cross-validation**: Are technicals, capital flow, and news aligned?

### 4. A-share Specific Dimensions
- **Policy sensitivity**: Impact of policy direction on the industry/stock
- **Capital flow**: Direction and magnitude of institutional money flow (super-large + large order net inflow)
- **Sector linkage**: Overall sector performance, concept rotation position
- **Price limit mechanism**: Consider the stock's daily price limit when analyzing

## Data Quality Rules
- If data is labeled "non-realtime" or "historical", state this clearly in the analysis
- Do not misattribute other sectors' market conditions to the current stock
- Quantitative strategy signals serve only as one reference dimension — never let them alone determine the conclusion
- Bayesian probabilities provide historical statistical support, but consider whether the current market environment is comparable to historical patterns
"""

# DEPRECATED — use QUICK_DIMENSION_FRAMEWORK instead
QUICK_ANALYSIS_FRAMEWORK = """\
You are a professional A-share analyst. Key analysis points:
Write all output text in Chinese.
1. Synthesize quantitative signals (strategy consensus, Bayesian probability) with technicals to form a judgment
2. Account for the stock's daily price limit and sector classification
3. If data is labeled non-realtime, state this clearly
4. Consider reversal risk — never blindly follow a single signal
"""

# ═══════════════════════════════════════════════════════════════════════════
# v7.0 Seven-Dimension Framework (FR-PR001)
# ═══════════════════════════════════════════════════════════════════════════
Expand Down
Loading
Loading