Primera build enviada

This commit is contained in:
2026-01-19 14:40:43 +01:00
parent c6be398e5a
commit b03d35194f
36 changed files with 1641 additions and 561 deletions
@@ -201,3 +201,49 @@ struct PortfolioSummary {
)
}
}
// MARK: - Portfolio Forecast
struct PortfolioForecast {
let currentValue: Decimal
let forecastValue: Decimal
let forecastDate: Date
let confidenceLower: Decimal
let confidenceUpper: Decimal
let monthlyGrowthRate: Decimal
let annualizedGrowthRate: Decimal
var formattedForecastValue: String {
CurrencyFormatter.format(forecastValue, style: .currency, maximumFractionDigits: 0)
}
var formattedCurrentValue: String {
CurrencyFormatter.format(currentValue, style: .currency, maximumFractionDigits: 0)
}
var formattedConfidenceRange: String {
let lower = CurrencyFormatter.format(confidenceLower, style: .currency, maximumFractionDigits: 0)
let upper = CurrencyFormatter.format(confidenceUpper, style: .currency, maximumFractionDigits: 0)
return "\(lower) \(upper)"
}
var formattedForecastDate: String {
forecastDate.monthYearString
}
var formattedGrowthPercentage: String {
guard currentValue > 0 else { return "+0%" }
let growthPct = ((forecastValue - currentValue) / currentValue) * 100
let prefix = growthPct >= 0 ? "+" : ""
return String(format: "\(prefix)%.1f%%", NSDecimalNumber(decimal: growthPct).doubleValue)
}
var formattedAnnualizedGrowthRate: String {
let prefix = annualizedGrowthRate >= 0 ? "+" : ""
return String(format: "\(prefix)%.1f%%", NSDecimalNumber(decimal: annualizedGrowthRate * 100).doubleValue)
}
var isPositiveGrowth: Bool {
forecastValue >= currentValue
}
}