Professional Documents
Culture Documents
FinancialMathematics Lab 9
FinancialMathematics Lab 9
Basics of Numpy
In [1]: import numpy as np
[1 4 5]
[[4 5 6]
[1 2 3]]
3
Out[15]:
In [16]: np.size(arr)
3
Out[16]:
In [17]: len(arr)
3
Out[17]:
(3,)
Out[23]:
In [25]: np.shape(arr1)
(2, 3)
Out[25]:
Displaying Rows
In [27]: arr1[0]
array([4, 5, 6])
Out[27]:
In [28]: arr1[1]
array([1, 2, 3])
Out[28]:
50
Out[34]:
In [80]: np.sum(arr_3,axis=0)
60
Out[80]:
In [52]: np.trace(arr3)
60
Out[52]:
In [57]: np.trace(arr4)
9
Out[57]:
In [76]: a = np.array([10,15,20])
b = np.array([25,30,35])
In [73]: sum(a+b)
135
Out[73]:
In [75]: c = np.array([[10,15,20],[25,30,35]])
np.sum(c)
135
Out[75]:
In [86]: np.concatenate([a,b])
In [93]: np.vstack((a,b))
In [95]: np.hstack((a,b))
In [97]: np.square(arr6)
In [103… np.square(arr6)*arr6
In [104… np.power(arr6,3)
LAB - 3
In [2]: import numpy as np
import matplotlib.pyplot as plt
import math
from array import *
Question 1: In what time will a sum of Rs. 12,000 become Rs. 18,000 at 10% pa. compund interest payable half yearly?
In [6]: print("Solution")
P = 12000
A = 18000
r = i_eff(0.12, 0.5)
N= math.log(A/P)/math.log(1+r)
print("In", N, "years the sum will become 18.000 at effective rate of interest", r*100)
Solution
In 3.7698155144575485 years the sum will become 18.000 at effective rate of interest 11.355287256600445
Question 2: Find Amount of Rs.3,000 lent for 10 years at 15% p.a. compund interest quarterly
In [16]: print("Solution")
P = 3000
N = 10
r = i_eff(0.15, 4)
A = P*(1+r)**N
print("The amount will be Rs.",A, "with effective rate of interest ", r*100)
Solution
The amount will be Rs. 13081.13627687616 with effective rate of interest 15.865041503906285
Question 3: Find the nominal rare and effective rate in each of the following.
(i) Rs.40,000 invested at 16% p.a. interest payable monthly.
In [21]: print("Solution")
P = 40000
T = 100000
r1 = i_nom(0.16, 12)
r2 = i_eff(0.16, 12)
r3 = i_nom(0.08, 1)
r4 = i_eff(0.08, 1)
Solution
(i) Rs.40,000 invested at 16% p.a. interest payable monthly:
Nominal rate is 14.93416550365616
Effective rate is 17.227079825887692
(ii) Rs.1,00,000 lent at 8% p.a. interest payable annually:
Nominal rate is 8.000000000000007
Effective rate is 8.000000000000007
Question 4: Find the nominal and effective rates and also find the realtion between them for the following cases:
1. Rs 20,000 lent at 20% p.a. interest payable half yearly.
In [9]: print("Solution:")
P = 20000
T = 45000
r1 = i_nom(0.2, 2)
r2 = i_eff(0.2, 2)
r3 = i_nom(0.12, 4)
r4 = i_eff(0.12, 4)
print("Relation between Nominal and Effective Rate is:", i_nom(r4,4)*100, ",i.e. rate of interest p.a.")
Solution:
(i) Rs.20.000 invested at 20% p.a. interest payable half yearly:
Nominal rate is 19.08902300206643
Effective rate is 21.000000000000018
Relation between Nominal and Effective Rate is: 20.000000000000018 ,1.e. rate of interest p.a.
Lab 4
def due(A,i,n):
D = A/i*(1+i)*((1+i)**n -1)
P = A/i*(1+i)*(1 - (1+i)**(-n))
print("Accumulated Value of the annuity due is: Rs.", D)
print("Present Value of the annuity due is: Rs.", P)
return D
def imme(A,i,n):
D = A/i*((1+i)**n -1)
P = A/i*(1 - (1+i)**(-n))
print("Accumulated Value of the annuity immediate is: Rs.", D)
print("Present Value of the annuity immediate is: Rs.", P)
return D
Q1: Find the amount of the 15 monthly payments of Rs. 2500 made at the beginning of the each period that earn interest 12% p.a. compunded monthly.
In [11]: due(2500,0.01,15)
Q2: Find the present and accumulated value of an annuity due of Rs. 500 payable at the beginning of each month for 2 years if the money is worth 8% p.a. compunded annually.
Question 3: I will invest Rs. 500 per quarter for my retirement at 7.3% compounding quarterly for 32 years. I have a choice of making that payment of Rs. 500 at the beginning or the
end of the quarter (regular annuity or annuity due). In which account will I have more money and by how much? Which account will earn the most interest and by how much?
print(a)
print(b)
print("Ammount of Interest earned in annuity immediate is: Rs.",o)
print("Ammount of Interest earned in annuity due is: Rs.",e)
if (o<e):
print("Ammount of Interest earned in annuity due is more than in annuity immediate.")
elif(o>e):
print("Ammount of Interest earned in annuity immediate is more than in annuity due.")
else:
print("Ammount of Interest earned in annuity due and annuity immediate is same.")
Q4: How much worth of an annuity due should be there to have a present value of at least Rs. 20,00,000 at 10% p.a. compunded quarterly for 46 years.
LAB-5
In [1]: from datetime import date
today = date.today()
print("Today's date:", today)
Annuities
Annuity due is an annuity in which the cash flows, or payments, occur at the beginning of the period.
A
D(n) =
i
(1 + i)[(1 + i)
n
− 1] #Matured Ammount
A
P (n) =
i
(1 + i)[1 − (1 + i)
−n
] #Present Value
Question 1: Find the amount of the 15 monthly payments of Rs. 2500 made at the beginning of the each period that earn interest 12%
p.a. compunded monthly.
In [5]: due(2500,0.01,15)
Question 2: Find the present and accumulated value of an annuity due of Rs. 500 payable at the beginning of each month for 2 years if
the money is worth 8% p.a. compunded annually.
In [4]: due(500, 0.0067, 24)
Question 3: I will invest Rs. 500 per quarter for my retirement at 7.3% compounding mquarterly for 32 years. I have a choice of making
that payment of Rs. 500 at the beginning or the end of the quarter (regular annuity or annuity due). In which account will I have more
money and by how much? Which account will earn the most interest and by how much?
In [7]: a = imme(500, 0.073, 32)
b = due(500, 0.073, 32)
o = a - 500
e = b - 500
print(a)
print(b)
print("Ammount of Interest earned in annuity immediate is: Rs.",o)
print("Ammount of Interest earned in annuity due is: Rs.",e)
if (o<e):
print("Ammount of Interest earned in annuity due is more than in annuity immediate.")
elif(o>e):
print("Ammount of Interest earned in annuity immediate is more than in annuity due.")
else:
print("Ammount of Interest earned in annuity due and annuity immediate is same.")
Question 4: How much worth of an annuity due should be there to have a present value of at least Rs. 20,00,000 at 10% p.a.
compunded quarterly for 46 years.
In [8]: dues(2000000, 0.01, 46)
LAB-6
Deferred Annuity
Deffered Annuity is an ordinary annuity in which the 3rst payment is post poned until the expiry of certain time payment. If the 3rst payment in an ordinary annuity is made at the end of (k+1) period
abd thereafter the paymements are made regularly for n periods, then it is called a deffered annuity
Question 1:
A man paid his advance payment for house construction in equal installments of ₹25000 semiannually in 10 years. If the money was worth 8% p.a. compunded semi annually and payments started
after 5 years. Find the accumulated value and present value of annuity.
In [3]: deffered(25000,0.04,20,10)
Question 2:
An annuity consists of 30 semi-annual payments of Rs. 500. the 3rst being payable at the end of 4.5 years. Find the accumulated ammount and present value of annuity if the money is worth 12%
p.a. compounded semi annually.
In [5]: deffered(500,0.06,22,8)
Question 3:
A land is sold for ₹ 1,50,000 down payments and 120 monthly installments of ₹ 5,000 each. If 3rst due is three years hence, 3nd the cash value of the house if money worth is 18% p.a. compunded
monthly. Also, find the accumulated value of the land.
In [7]: deffered(5000,0.015,85,35)
Question 4:
An annuity consists of 4 annual payments ₹ 1,500 each. First payment being made at the end of sixth year. Find the accumulated and present value of the annuity if the worth is 10% effective rate.
In [15]: deffered(1500,0.1,9,5)
Conclusion:We conclude that we can find the amount due and present matured amount using the concept deffered annuity.
LAB - 7
Perpetual Annuity
Aim: To implement the concept of perpetual annuity in Python
Perpetuity: Perpetuity is an annuity whose payments continue forever. Let P ve the discounted value of an ordinary simple perpetuity (OSP) which is an infinte series of equal payments made at the
end of interest periods.
P = A/i
Question 1: How much money is needed to establish a scholorship fund paying ₹10,000 annually if the fund will earn a rate of interest of 12% p.a. and if the first payment will be made at the end of
first period?
In [10]: per(10000,0.12)
Question 2:
A certain stock is expected to pay divident of ₹ 75,000 at the end of each quater for an indefinite period in the future. If an investor wishes to realise an effective yield of 10% p.a., how much should
he pay for the stock?
Question 3:
A scholorship fund is established by a recognised body of ₹ 2,00,00,000 invested at 10% p.a. compund interest. What payment will this fund provide at the end of every two years?
Amount to be paid at the end of every 2 years for the scholorship fund: 4000000.0
Question 4:
A certain stock is expected to pay a dovident of ₹10,000 at the end of each quater for an indefinite period in the future. If an investor wishes an annual effective yeild of 12% p.a., how much should
be paid in the stock?
Conclusion:We conclude that we can find present value of a perpetuity which is the discounted value of an ordinary simple perpetuity (OSP) using python.
LAB - 8
Implement the Concept of Outstanding Loan Balance
In [17]: from sympy import *
from numpy import *
L = Symbol('L')
OLB_k = Symbol('OLB_k')
k = Symbol('k')
i = Symbol('i')
Q = Symbol('Q')
s_ki = Symbol('s_ki')
v = Symbol('v')
a_k = Symbol('a_k')
K = Eq(OLB_k, L*a_k - Q*s_ki)
pprint(K)
In [19]: OLB(450000,372,5109.03,0.01125)
v = 0.015582068931547323
a_k = 64.17633013902336
a_ki = 87.50381609497357
s_ki = 5615.67379013541
OLB_k 188702.69854500145