phase-7: code restructure
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { Sector } from './constants.js';
|
||||
import type { ScoringRulesShape } from '../types';
|
||||
|
||||
// ── Credit rating scale (S&P convention) ─────────────────────────────────
|
||||
// Bond.ts converts letter ratings to these numbers; BondScorer uses them for gate checks.
|
||||
@@ -17,26 +17,8 @@ export const CREDIT_RATING_SCALE: Record<string, number> = {
|
||||
};
|
||||
|
||||
// ── Scoring rule shape ────────────────────────────────────────────────────
|
||||
|
||||
interface GateSet extends Record<string, number> {}
|
||||
interface WeightSet extends Record<string, number> {}
|
||||
interface ThresholdSet extends Record<string, number> {}
|
||||
|
||||
interface RuleBlock {
|
||||
gates: GateSet;
|
||||
weights: WeightSet;
|
||||
thresholds: ThresholdSet;
|
||||
}
|
||||
|
||||
interface StockRules extends RuleBlock {
|
||||
SECTOR_OVERRIDE: Partial<Record<Sector, Partial<RuleBlock>>>;
|
||||
}
|
||||
|
||||
interface ScoringRulesShape {
|
||||
STOCK: StockRules;
|
||||
ETF: RuleBlock;
|
||||
BOND: RuleBlock;
|
||||
}
|
||||
// Structural shapes (GateSet/WeightSet/ThresholdSet/RuleBlock/StockRules/
|
||||
// ScoringRulesShape) live in server/types/asset.model.ts.
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// Fundamental baseline — Graham / value-investing style.
|
||||
@@ -58,6 +40,8 @@ export const ScoringRules: ScoringRulesShape = {
|
||||
peg: 2, // valuation relative to growth
|
||||
revenue: 2, // revenue growth
|
||||
fcf: 3, // FCF is the most manipulation-resistant quality signal
|
||||
analyst: 2, // Wall Street consensus (1=Strong Buy … 5=Strong Sell, inverted in scorer)
|
||||
dcf: 2, // DCF margin of safety: positive = undervalued vs intrinsic value
|
||||
},
|
||||
thresholds: {
|
||||
marginHigh: 15, // 15% net margin is genuinely excellent across most sectors
|
||||
@@ -72,6 +56,12 @@ export const ScoringRules: ScoringRulesShape = {
|
||||
revMed: 5,
|
||||
fcfHigh: 5,
|
||||
fcfMed: 2,
|
||||
// Analyst consensus thresholds (Yahoo recommendationMean scale: 1=Strong Buy, 5=Strong Sell)
|
||||
analystBuy: 2.0, // ≤ 2.0 → consensus is Buy or better
|
||||
analystHold: 3.0, // ≤ 3.0 → consensus is Hold or better
|
||||
// DCF margin-of-safety thresholds (% undervaluation vs intrinsic value)
|
||||
dcfUndervalued: 20, // ≥ 20% margin of safety → undervalued
|
||||
dcfFairValue: 0, // 0–20% → fairly valued; negative → overvalued
|
||||
},
|
||||
|
||||
SECTOR_OVERRIDE: {
|
||||
|
||||
Reference in New Issue
Block a user