fix: canonicalize score brackets and assessments
This commit is contained in:
@@ -7,6 +7,8 @@ import sys
|
||||
from collections import defaultdict
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from scoring.policy import SCORE_BRACKETS, SCORE_VERSION, score_in_bracket
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
@@ -16,14 +18,7 @@ HISTORY_PATH = os.path.join(BASE_DIR, "data", "history.json")
|
||||
CACHE_PATH = os.path.join(BASE_DIR, "data", "cache.json")
|
||||
|
||||
# Score brackets matching the dashboard assessment levels
|
||||
BRACKETS = [
|
||||
(0, 20, "Extreme Caution"),
|
||||
(21, 40, "Caution"),
|
||||
(41, 55, "Neutral"),
|
||||
(56, 70, "Moderate Opportunity"),
|
||||
(71, 85, "Strong Accumulation"),
|
||||
(86, 100, "Extreme Accumulation"),
|
||||
]
|
||||
BRACKETS = SCORE_BRACKETS
|
||||
|
||||
# Scoring thresholds — load from config/thresholds.json (single source of truth)
|
||||
import os as _os
|
||||
@@ -322,7 +317,7 @@ def run_backtest(ml_mode=False):
|
||||
# --- Bracket statistics ---
|
||||
bracket_stats = []
|
||||
for low, high, label in BRACKETS:
|
||||
days_in = [d for d in daily_scores if low <= d["score"] <= high]
|
||||
days_in = [d for d in daily_scores if score_in_bracket(d["score"], (low, high, label))]
|
||||
if not days_in:
|
||||
bracket_stats.append({
|
||||
"range": f"{low}-{high}", "label": label, "days": 0,
|
||||
@@ -506,6 +501,7 @@ def run_backtest(ml_mode=False):
|
||||
"current_context": current_context,
|
||||
"chart_data": chart_data,
|
||||
"ml_mode": ml_mode,
|
||||
"score_version": SCORE_VERSION,
|
||||
"computed_at": datetime.utcnow().isoformat() + "Z",
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user