jeudi 15 août 2019

Bond CF for loop and if else loop

Hi i am trying to add the last cash flow back into the par value using a if else loop but i cant seem to do it. How do i assign a int to a specific item in the range? i am trying to make if the index is > 10 it will add the part value back in

par = 1000
coupon_rate = 3
T = 5
freq = 2


def cf_calculator(par, r, T, freq):
    for i in range(T * freq):
        if (T) < (T * freq):
            coupon = (r/100) * par/freq
            print(coupon)
        else: 
            coupon = (r/100) * par/freq + par
            print(coupon)



print(cf_calculator(1000,3,5,2))

I know my if loop is wrong is there a better way?

Aucun commentaire:

Enregistrer un commentaire