func Calculate(config Config) MXN {
	portfolio := Portfolio{
		Investments:     make([]Investment, 0),
		PastInvestments: make([]Investment, 0),
	}
	currentDate := config.StartDate
	for ; currentDate.Before(config.EndDateInvestment); currentDate = currentDate.AddDate(0, 1, 0) {
		oldInvestments := portfolio.Refresh(currentDate)
		for _, oldInv := range oldInvestments {
			portfolio.Reinvest(oldInv)
		}

		newInvestment := Investment{
			StartDate: currentDate,
			EndDate:   currentDate.AddDate(1, 0, 0),
			Amount:    config.MonthlyInvest,
			Interest:  config.Interest,
		}
		portfolio.Invest(newInvestment)
	}
	for ; currentDate.Before(config.EndDate); currentDate = currentDate.AddDate(0, 1, 0) {
		portfolio.InsertCash(config.MonthlyInvest)
	}
	return portfolio.NetWorth
}
// Calculate calculates compound interest and returns total sum
Calculate calculates compound interest and returns total sum
// Calculate calculates compound interest and returns total sum
func Calculate(config Config) MXN {
	portfolio := Portfolio{
		Investments:     make([]Investment, 0),
		PastInvestments: make([]Investment, 0),
	}
	currentDate := config.StartDate
	for ; currentDate.Before(config.EndDateInvestment); currentDate = currentDate.AddDate(0, 1, 0) {
		oldInvestments := portfolio.Refresh(currentDate)
		for _, oldInv := range oldInvestments {
			portfolio.Reinvest(oldInv)
		}
		newInvestment := Investment{
			StartDate: currentDate,
			EndDate:   currentDate.AddDate(1, 0, 0),
			Amount:    config.MonthlyInvest,
			Interest:  config.Interest,
		}
		portfolio.Invest(newInvestment)
	}
	for ; currentDate.Before(config.EndDate); currentDate = currentDate.AddDate(0, 1, 0) {
		portfolio.InsertCash(config.MonthlyInvest)
	}
	return portfolio.NetWorth
}
func Calculate ( config Config ) MXN { portfolio := Portfolio { Investments : make ( [ ] Investment , 0 ) , PastInvestments : make ( [ ] Investment , 0 ) , } currentDate := config . StartDate for ; currentDate . Before ( config . EndDateInvestment ) ; currentDate = currentDate . AddDate ( 0 , 1 , 0 ) { oldInvestments := portfolio . Refresh ( currentDate ) for _ , oldInv := range oldInvestments { portfolio . Reinvest ( oldInv ) } newInvestment := Investment { StartDate : currentDate , EndDate : currentDate . AddDate ( 1 , 0 , 0 ) , Amount : config . MonthlyInvest , Interest : config . Interest , } portfolio . Invest ( newInvestment ) } for ; currentDate . Before ( config . EndDate ) ; currentDate = currentDate . AddDate ( 0 , 1 , 0 ) { portfolio . InsertCash ( config . MonthlyInvest ) } return portfolio . NetWorth }
Calculate calculates compound interest and returns total sum
Calculate calculates compound interest and returns total sum