phase-8:server code enhancements.

This commit is contained in:
Sai Kiran Vella
2026-06-05 22:44:04 -04:00
parent a7108b448a
commit 1e2aac7164
15 changed files with 781 additions and 94 deletions
+6 -6
View File
@@ -9,12 +9,12 @@ export class Stock extends Asset {
constructor(data: StockData) {
super(data);
this.sector = this._mapToStandardSector(data);
this.sector = this.mapToStandardSector(data);
this.metrics = {
sector: this.sector,
capCategory: this._classifyMarketCap(data.marketCap ?? null),
growthCategory: this._classifyGrowth(
capCategory: this.classifyMarketCap(data.marketCap ?? null),
growthCategory: this.classifyGrowth(
data.revenueGrowth ?? null,
data.earningsGrowth ?? null,
data.dividendYield ?? null,
@@ -52,7 +52,7 @@ export class Stock extends Asset {
// ── Market cap tier classification ──────────────────────────────────────
// Thresholds follow MSCI/Russell institutional convention.
_classifyMarketCap(marketCap: number | null): CapCategory {
classifyMarketCap(marketCap: number | null): CapCategory {
if (marketCap == null) return CAP_CATEGORY.LARGE; // safe default
if (marketCap >= 200e9) return CAP_CATEGORY.MEGA;
if (marketCap >= 10e9) return CAP_CATEGORY.LARGE;
@@ -64,7 +64,7 @@ export class Stock extends Asset {
// ── Growth / style classification ───────────────────────────────────────
// revenueGrowth and earningsGrowth are in percentage form (e.g. 15 = 15%).
// dividendYield is also in percentage form (e.g. 3.5 = 3.5%).
_classifyGrowth(
classifyGrowth(
revenueGrowth: number | null,
earningsGrowth: number | null,
dividendYield: number | null,
@@ -81,7 +81,7 @@ export class Stock extends Asset {
return GROWTH_CATEGORY.STABLE;
}
_mapToStandardSector(data: StockData): Sector {
mapToStandardSector(data: StockData): Sector {
const profile = data.assetProfile ?? {};
const industry = (profile.industry || '').toLowerCase();
const sector = (profile.sector || '').toLowerCase();