Investment Rechner
Das kannst du auch!
\[ K = K_0 \cdot (1 + r)^n + \sum_{i=1}^n M \cdot (1 + r)^{n-i} \]
- \( K \): Gesamtkapital nach der Laufzeit
- \( K_0 \): Einmalbetrag (Initialinvestition)
- \( r \): Jährliche Rendite (als Dezimalwert, z. B. 0.08 für 8%)
- \( n \): Anzahl der Jahre
- \( M \): Monatliche Einzahlung
- \( K_0 \cdot (1 + r)^n \): Der Zinseszins auf den Einmalbetrag
- \( \sum_{i=1}^n M \cdot (1 + r)^{n-i} \): Der Zinseszins auf die monatlichen Einzahlungen
Hier der Python-Code
def calculate_total_capital():
print("\nKapital-Gewinn-Rechner")
print("========================\n")
try:
# Eingabe der Werte
initial_investment = float(input("Einmalbetrag (Initialinvestition in €): "))
monthly_investment = float(input("Monatliche Einzahlung in €: "))
annual_return = float(input("Jährliche Rendite (in %): ")) / 100
years = int(input("Laufzeit (in Jahren): "))
# Berechnung
total_capital = initial_investment
total_invested = initial_investment
monthly_return = (1 + annual_return) ** (1 / 12) - 1
for i in range(years * 12):
total_capital = total_capital * (1 + monthly_return) + monthly_investment
total_invested += monthly_investment
# Gewinn berechnen
total_profit = total_capital - total_invested
# Ergebnisse ausgeben
print("\nErgebnisse:")
print(f"Gesamtes Kapital nach {years} Jahren: €{total_capital:,.2f}")
print(f"Insgesamt investiert: €{total_invested:,.2f}")
print(f"Gesamtgewinn: €{total_profit:,.2f}")
except ValueError:
print("Ungültige Eingabe. Bitte geben Sie Zahlen ein.")
# Hauptfunktion aufrufen
if __name__ == "__main__":
calculate_total_capital()