XYHLF / App /routers /bonds /service.py
Mbonea's picture
initial commit
9d4bd7c
from datetime import datetime, timedelta
from typing import List
def calculate_coupon_dates(start_date: datetime, maturity_date: datetime, interval_months: int = 6) -> List[datetime]:
"""Calculate coupon payment dates for a bond.
Args:
start_date: The effective date of the bond
maturity_date: The maturity date of the bond
interval_months: Interval between coupon payments in months (default 6)
Returns:
List of coupon payment dates
"""
dates = []
current_date = start_date
while current_date < maturity_date:
if current_date.weekday() < 5: # Skip weekends
dates.append(current_date)
current_date += timedelta(days=interval_months * 30.44) # Approximate months
return dates