phase-8:server code enhancements.
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user