Add src/lib/types/mutual-fund.ts

This commit is contained in:
2026-03-07 09:21:32 +00:00
parent 64061dc26a
commit 8c217c27c1

View File

@@ -0,0 +1,282 @@
/**
* Mutual Fund Data Types and Database Schema
* Comprehensive type definitions for fund schemes, performance metrics, and investment requirements
*/
/**
* Fund Scheme Types
*/
export enum FundCategory {
EQUITY = "EQUITY", DEBT = "DEBT", HYBRID = "HYBRID", MONEY_MARKET = "MONEY_MARKET", LIQUID = "LIQUID", COMMODITY = "COMMODITY", INTERNATIONAL = "INTERNATIONAL"}
export enum RiskProfile {
LOW = "LOW", LOW_TO_MODERATE = "LOW_TO_MODERATE", MODERATE = "MODERATE", MODERATE_TO_HIGH = "MODERATE_TO_HIGH", HIGH = "HIGH"}
export enum InvestmentType {
SIP = "SIP", LUMP_SUM = "LUMP_SUM", BOTH = "BOTH"}
/**
* Fund Scheme Database Schema
*/
export interface FundScheme {
// Identification
id: string;
schemeCode: string;
schemeName: string;
fundHouseName: string;
ISIN: string;
category: FundCategory;
subCategory?: string;
// Fund Details
riskProfile: RiskProfile;
launchDate: Date;
fundSize: number; // in crores
unitPrice: number; // current NAV
portfolioComposition?: PortfolioComposition;
// Description
description: string;
investmentObjective: string;
targetInvestors?: string[];
fundManager: string;
fundManagerName?: string;
fundManagerExperience?: number; // in years
// Flags
isActive: boolean;
isNew: boolean;
isPopular: boolean;
}
/**
* Portfolio Composition
*/
export interface PortfolioComposition {
equityPercentage: number;
debtPercentage: number;
goldPercentage?: number;
internationalPercentage?: number;
cashPercentage: number;
otherPercentage?: number;
}
/**
* Performance Metrics
*/
export interface PerformanceMetrics {
id: string;
fundSchemeId: string;
asOfDate: Date;
// Returns
oneMonthReturn?: number;
threeMonthReturn?: number;
sixMonthReturn?: number;
oneYearReturn: number;
threeYearReturn?: number;
fiveYearReturn?: number;
tenYearReturn?: number;
sinceInceptionReturn?: number;
// CAGR (Compound Annual Growth Rate)
oneYearCAGR?: number;
threeYearCAGR?: number;
fiveYearCAGR?: number;
tenYearCAGR?: number;
// YTD and Period-specific
ytdReturn: number;
quarterlyReturn?: number;
calendarYearReturn?: number;
// Benchmark comparison
benchmarkIndex?: string;
benchmarkReturn?: number;
alpha?: number; // excess return
beta?: number; // volatility relative to benchmark
}
/**
* Risk and Ratio Metrics
*/
export interface RiskAndRatioMetrics {
id: string;
fundSchemeId: string;
asOfDate: Date;
// Volatility Metrics
standardDeviation: number; // annualized volatility
variance?: number;
// Risk-Adjusted Returns
sharpeRatio: number;
sortinoRatio?: number;
calmarRatio?: number;
treynorRatio?: number;
// Duration and Maturity (for debt funds)
modifiedDuration?: number;
effectiveDuration?: number;
averageMaturity?: number;
// Credit Metrics (for debt funds)
creditQualityScore?: number; // AAA, AA, A, etc.
defaultRisk?: number; // percentage
// Fund Health Metrics
turnover?: number; // portfolio turnover ratio
expenseRatio: number;
entryLoad?: number;
exitLoad?: number;
managementFeePercentage?: number;
}
/**
* Investment Requirements and Eligibility
*/
export interface InvestmentRequirements {
id: string;
fundSchemeId: string;
// Investment Minimums
minimumLumpSum: number;
minimumSIP: number; // monthly SIP minimum
minimumAdditionalInvestment?: number;
maximumSIPAmount?: number;
// Investment Types Allowed
allowedInvestmentTypes: InvestmentType[];
// SIP Details
sipFrequencies?: SIPFrequency[]; // MONTHLY, QUARTERLY, etc.
sipDuration?: number; // minimum lock-in period in months
// Lock-in Period
lockInPeriod?: number; // in days
lockInType?: 'ELSS' | 'NONE'; // ELSS funds have 3-year lock-in
// Eligibility
minimumAge?: number;
maximumAge?: number;
residencyRequirement?: string; // NRI, RESIDENT, etc.
kycRequired: boolean;
accountTypeEligibility?: string[]; // INDIVIDUAL, JOINT, HUF, etc.
// Additional Requirements
panRequired: boolean;
aadharRequired?: boolean;
bankAccountRequired: boolean;
documentRequirements?: string[];
}
export enum SIPFrequency {
WEEKLY = "WEEKLY", FORTNIGHTLY = "FORTNIGHTLY", MONTHLY = "MONTHLY", QUARTERLY = "QUARTERLY", HALF_YEARLY = "HALF_YEARLY", YEARLY = "YEARLY"}
/**
* Fund Distribution and Dividend Information
*/
export interface DividendInformation {
id: string;
fundSchemeId: string;
// Dividend Options
optionType: 'GROWTH' | 'DIVIDEND' | 'BONUS';
dividendFrequency?: string; // Annual, Half-yearly, etc.
lastDividendAmount?: number;
lastDividendDate?: Date;
// Dividend History
annualDividendYield?: number;
payoutRatio?: number;
consecutiveDividendPayments?: number; // streak
}
/**
* Fee and Expense Breakdown
*/
export interface FeeStructure {
id: string;
fundSchemeId: string;
// Direct Fees
directExpenseRatio: number; // for direct plans
regularExpenseRatio?: number; // for regular plans (includes commission)
managementFee: number;
administrationFee?: number;
custodyFee?: number;
auditFee?: number;
otherFees?: number;
// Load Structure
entryLoad?: number; // percentage
exitLoad?: number; // percentage
exitLoadPeriod?: number; // days after purchase
// Rebate Structure
rebates?: RebateStructure[];
}
export interface RebateStructure {
investmentAmount: number;
rebatePercentage: number;
}
/**
* Fund Company/House Information
*/
export interface FundHouse {
id: string;
houseName: string;
registrationNumber: string;
establishmentYear: number;
website?: string;
phone?: string;
email?: string;
address?: string;
assetsUnderManagement: number; // in crores
numberOfSchemes: number;
regulatoryStatus: 'ACTIVE' | 'SUSPENDED' | 'CLOSED';
}
/**
* Scheme Holding and Portfolio Information
*/
export interface PortfolioHolding {
id: string;
fundSchemeId: string;
holdingId: string; // stock/security identifier
holdingName: string;
quantity?: number;
percentage: number; // % of total fund value
sector?: string;
holdingType: 'EQUITY' | 'DEBT' | 'DERIVATIVE' | 'CASH';
rating?: string; // credit rating for debt securities
}
/**
* Historical Data for Trends
*/
export interface HistoricalNAV {
id: string;
fundSchemeId: string;
date: Date;
nav: number;
navChange?: number;
navChangePercentage?: number;
}
/**
* Database Schema Summary
*/
export interface MutualFundDatabase {
fundSchemes: FundScheme[];
performanceMetrics: PerformanceMetrics[];
riskAndRatioMetrics: RiskAndRatioMetrics[];
investmentRequirements: InvestmentRequirements[];
dividendInformation: DividendInformation[];
feeStructures: FeeStructure[];
fundHouses: FundHouse[];
portfolioHoldings: PortfolioHolding[];
historicalNAV: HistoricalNAV[];
}