Files
market_screener/server/domains/shared/entities/Bond.ts
T
Sai Kiran Vella 96a752ecf7 phase-9: domain-driven architecture complete
- Restructured server layer with 5 domains: shared, screener, portfolio, calls, finance
- Migrated 58 TypeScript files to domain-driven structure
- Updated CLAUDE.md with new architecture documentation
- Added .gitignore rules for .md files (except CLAUDE.md)
- Removed unused CatalystAnalyst import from app.ts
- Fixed lint errors: removed unused imports, fixed regex escape, added console suppressions
- Verified no sensitive data in git history
- Server code compiles cleanly with TypeScript strict mode
2026-06-06 18:18:22 -04:00

33 lines
945 B
TypeScript

import { CREDIT_RATING_SCALE } from '../scoring/ScoringConfig';
import { Asset } from './Asset';
import type { BondData, BondMetrics } from '../types/index';
export class Bond extends Asset {
metrics: BondMetrics;
constructor(data: BondData) {
super(data);
const creditRating = data.creditRating || 'BBB';
const creditRatingNumeric = CREDIT_RATING_SCALE[creditRating] ?? 7;
this.metrics = {
ytm: parseFloat(String(data.yieldToMaturity)) || 0,
duration: parseFloat(String(data.duration)) || 0,
creditRating,
creditRatingNumeric,
};
}
getDisplayMetrics(): Record<string, string> {
return {
Ticker: this.ticker,
Type: 'BOND',
Price: this.formatCurrency(this.currentPrice),
'YTM%': `${this.metrics.ytm.toFixed(2)}%`,
Duration: this.metrics.duration.toFixed(1),
Rating: `${this.metrics.creditRating} (${this.metrics.creditRatingNumeric})`,
};
}
}