tfloorach.py

Created by matthieumorvant

Created on February 09, 2024

1.54 KB


def calculer_Floor(montant_emprunt, taux_plancher, tx_prime, hypotheses):
    # Calcul de la prime
    prime = tx_prime * montant_emprunt
    print("\nCalcul de la prime: {:.2%} * {:.2f} € = {:.2f} €".format(tx_prime, montant_emprunt, prime))

    # Traitement de chaque hypothèse
    for i, tam in enumerate(hypotheses, 1):
        print("\nHypothèse {} - TAM: {:.2%}".format(i, tam))
        print("Prime payée en début de période: {:.2f} €".format(prime))

        if tam < taux_plancher:
            differentiel = montant_emprunt * (taux_plancher - tam)
            print("Exercice de l'option car TAM < Taux plancher garanti")
            print("Différentiel reçu: {:.2f} €".format(differentiel))
            print("Calcul du différentiel: {:.2f} € * ({:.2%} - {:.2%}) = {:.2f} €".format(montant_emprunt, taux_plancher, tam, differentiel))
        else:
            print("Aucun différentiel reçu car TAM >= Taux plancher garanti")

# Paramètres d'entrée
montant_emprunt = float(input("Montant de l'emprunt : "))
taux_plancher = float(input("Taux plancher garanti (%) : ")) / 100  # Conversion en pourcentage
tx_prime = float(input("Taux de la prime (%) : ")) / 100  # Conversion en pourcentage
nombre_hypotheses = int(input("Nombre d'hypothèses : "))

hypotheses = []
for _ in range(nombre_hypotheses):
    tam = float(input("Taux d'intérêt variable (TAM) pour l'hypothèse (%) : ")) / 100  # Conversion en pourcentage
    hypotheses.append(tam)

# Exécution du calcul
calculer_Floor(montant_emprunt, taux_plancher, tx_prime, hypotheses)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.