|
@@ -0,0 +1,142 @@
|
|
|
|
|
+{
|
|
|
|
|
+ "cells": [
|
|
|
|
|
+ {
|
|
|
|
|
+ "cell_type": "code",
|
|
|
|
|
+ "execution_count": 6,
|
|
|
|
|
+ "id": "9a5b00b8-2d18-4540-80ff-cf985f653dce",
|
|
|
|
|
+ "metadata": {},
|
|
|
|
|
+ "outputs": [
|
|
|
|
|
+ {
|
|
|
|
|
+ "name": "stdout",
|
|
|
|
|
+ "output_type": "stream",
|
|
|
|
|
+ "text": [
|
|
|
|
|
+ "100 30 0.5 3 5 False\n"
|
|
|
|
|
+ ]
|
|
|
|
|
+ }
|
|
|
|
|
+ ],
|
|
|
|
|
+ "source": [
|
|
|
|
|
+ "class Bond:\n",
|
|
|
|
|
+ " def __init__(\n",
|
|
|
|
|
+ " self,\n",
|
|
|
|
|
+ " par,\n",
|
|
|
|
|
+ " term,\n",
|
|
|
|
|
+ " couponInt,\n",
|
|
|
|
|
+ " paymentFreq,\n",
|
|
|
|
|
+ " intRate,\n",
|
|
|
|
|
+ " amortizing=False):\n",
|
|
|
|
|
+ " self.par=par\n",
|
|
|
|
|
+ " self.term=term\n",
|
|
|
|
|
+ " self.couponInt=couponInt\n",
|
|
|
|
|
+ " self.paymentFreq=paymentFreq\n",
|
|
|
|
|
+ " self.intRate=intRate\n",
|
|
|
|
|
+ " self.amortizing=amortizing\n",
|
|
|
|
|
+ " \n",
|
|
|
|
|
+ " def calculate(self):\n",
|
|
|
|
|
+ " if self.amortizing==True:\n",
|
|
|
|
|
+ " self.par*self.couponInt\n",
|
|
|
|
|
+ " \n",
|
|
|
|
|
+ " print(self.par,self.term,self.couponInt,self.paymentFreq,self.intRate,self.amortizing)\n",
|
|
|
|
|
+ "\n",
|
|
|
|
|
+ "Ex1=Bond(100, 30,0.5, 3,5, False)\n",
|
|
|
|
|
+ "Ex1.calculate()"
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "cell_type": "code",
|
|
|
|
|
+ "execution_count": 1,
|
|
|
|
|
+ "id": "7d04967a-d8b9-46f1-8bd4-60b38370a956",
|
|
|
|
|
+ "metadata": {},
|
|
|
|
|
+ "outputs": [],
|
|
|
|
|
+ "source": [
|
|
|
|
|
+ "#Price = ( Coupon × 1 − ( 1 + r ) − n r ) + Par Value ( 1 + r ) n"
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "cell_type": "code",
|
|
|
|
|
+ "execution_count": 1,
|
|
|
|
|
+ "id": "365a82d5-7799-4ef0-9735-8f6eb0da9e67",
|
|
|
|
|
+ "metadata": {},
|
|
|
|
|
+ "outputs": [],
|
|
|
|
|
+ "source": [
|
|
|
|
|
+ "#Bond Premium Amortized= P x R – N x Y\n",
|
|
|
|
|
+ "#P = Bond issue price, R = Market Rate of interest, N = Nominal or face value and, Y = coupon rate of interest/ Yield."
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "cell_type": "code",
|
|
|
|
|
+ "execution_count": 10,
|
|
|
|
|
+ "id": "f0143155-7445-417a-ac26-4a7bab893295",
|
|
|
|
|
+ "metadata": {},
|
|
|
|
|
+ "outputs": [
|
|
|
|
|
+ {
|
|
|
|
|
+ "data": {
|
|
|
|
|
+ "text/plain": [
|
|
|
|
|
+ "1375.7049230300258"
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ "execution_count": 10,
|
|
|
|
|
+ "metadata": {},
|
|
|
|
|
+ "output_type": "execute_result"
|
|
|
|
|
+ }
|
|
|
|
|
+ ],
|
|
|
|
|
+ "source": [
|
|
|
|
|
+ "class Bond:\n",
|
|
|
|
|
+ " def __init__(\n",
|
|
|
|
|
+ " self,\n",
|
|
|
|
|
+ " par,\n",
|
|
|
|
|
+ " term,\n",
|
|
|
|
|
+ " couponInt,\n",
|
|
|
|
|
+ " paymentFreq,\n",
|
|
|
|
|
+ " intRate,\n",
|
|
|
|
|
+ " amortizing=False):\n",
|
|
|
|
|
+ " self.par=par\n",
|
|
|
|
|
+ " self.term=term\n",
|
|
|
|
|
+ " self.couponInt=couponInt\n",
|
|
|
|
|
+ " self.paymentFreq=paymentFreq\n",
|
|
|
|
|
+ " self.intRate=intRate\n",
|
|
|
|
|
+ " self.amortizing=amortizing\n",
|
|
|
|
|
+ " \n",
|
|
|
|
|
+ " def calculate(self):\n",
|
|
|
|
|
+ " if self.amortizing==False:\n",
|
|
|
|
|
+ " price=(((self.par*self.couponInt)*(1-(1+self.intRate)**-self.paymentFreq)/self.intRate)+(self.par/(1+self.intRate)**self.term))\n",
|
|
|
|
|
+ " return(price)\n",
|
|
|
|
|
+ " else:\n",
|
|
|
|
|
+ " 1==1\n",
|
|
|
|
|
+ " \n",
|
|
|
|
|
+ "\n",
|
|
|
|
|
+ "Ex1 = Bond(1000, 4, .25, 4, .125, False)\n",
|
|
|
|
|
+ "Ex1.calculate()\n",
|
|
|
|
|
+ "\n"
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "cell_type": "code",
|
|
|
|
|
+ "execution_count": null,
|
|
|
|
|
+ "id": "34384d3e-b1e7-42e3-9654-acc894492eb6",
|
|
|
|
|
+ "metadata": {},
|
|
|
|
|
+ "outputs": [],
|
|
|
|
|
+ "source": []
|
|
|
|
|
+ }
|
|
|
|
|
+ ],
|
|
|
|
|
+ "metadata": {
|
|
|
|
|
+ "kernelspec": {
|
|
|
|
|
+ "display_name": "Python 3 (ipykernel)",
|
|
|
|
|
+ "language": "python",
|
|
|
|
|
+ "name": "python3"
|
|
|
|
|
+ },
|
|
|
|
|
+ "language_info": {
|
|
|
|
|
+ "codemirror_mode": {
|
|
|
|
|
+ "name": "ipython",
|
|
|
|
|
+ "version": 3
|
|
|
|
|
+ },
|
|
|
|
|
+ "file_extension": ".py",
|
|
|
|
|
+ "mimetype": "text/x-python",
|
|
|
|
|
+ "name": "python",
|
|
|
|
|
+ "nbconvert_exporter": "python",
|
|
|
|
|
+ "pygments_lexer": "ipython3",
|
|
|
|
|
+ "version": "3.10.7"
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ "nbformat": 4,
|
|
|
|
|
+ "nbformat_minor": 5
|
|
|
|
|
+}
|