Title: | Financial Mathematics for Actuaries |
---|---|
Description: | Contains financial math functions and introductory derivative functions included in the Society of Actuaries and Casualty Actuarial Society 'Financial Mathematics' exam, and some topics in the 'Models for Financial Economics' exam. |
Authors: | Kameron Penn [aut, cre], Jack Schmidt [aut] |
Maintainer: | Kameron Penn <[email protected]> |
License: | GPL-2 |
Version: | 0.1.1 |
Built: | 2024-11-06 06:19:45 UTC |
Source: | CRAN |
Solves for either the number of payments, the payment amount, or the amount of a loan. The payment amount, interest paid, principal paid, and balance of the loan are given for a specified period.
amort.period(Loan=NA,n=NA,pmt=NA,i,ic=1,pf=1,t=1)
amort.period(Loan=NA,n=NA,pmt=NA,i,ic=1,pf=1,t=1)
Loan |
loan amount |
n |
the number of payments/periods |
pmt |
value of level payments |
i |
nominal interest rate convertible ic times per year |
ic |
interest conversion frequency per year |
pf |
the payment frequency- number of payments per year |
t |
the specified period for which the payment amount, interest paid, principal paid, and loan balance are solved for |
Effective Rate of Interest:
Balance at the end of period t:
Interest paid at the end of period t:
Principal paid at the end of period t:
Returns a matrix of input variables, calculated unknown variables, and amortization figures for the given period.
Assumes that payments are made at the end of each period.
One of n, pmt, or Loan must be NA (unknown).
If pmt is less than the amount of interest accumulated in the first period, then the function will stop because the loan will never be paid off due to the payments being too small.
If the pmt is greater than the loan amount plus interest accumulated in the first period, then the function will stop because one payment will pay off the loan.
t cannot be greater than n.
Kameron Penn and Jack Schmidt
amort.period(Loan=100,n=5,i=.01,t=3) amort.period(n=5,pmt=30,i=.01,t=3,pf=12) amort.period(Loan=100,pmt=24,ic=1,i=.01,t=3)
amort.period(Loan=100,n=5,i=.01,t=3) amort.period(n=5,pmt=30,i=.01,t=3,pf=12) amort.period(Loan=100,pmt=24,ic=1,i=.01,t=3)
Produces an amortization table for paying off a loan while also solving for either the number of payments, loan amount, or the payment amount. In the amortization table the payment amount, interest paid, principal paid, and balance of the loan are given for each period. If n ends up not being a whole number, outputs for the balloon payment, drop payment and last regular payment are provided. The total interest paid, and total amount paid is also given. It can also plot the percentage of each payment toward interest vs. period.
amort.table(Loan=NA,n=NA,pmt=NA,i,ic=1,pf=1,plot=FALSE)
amort.table(Loan=NA,n=NA,pmt=NA,i,ic=1,pf=1,plot=FALSE)
Loan |
loan amount |
n |
the number of payments/periods |
pmt |
value of level payments |
i |
nominal interest rate convertible ic times per year |
ic |
interest conversion frequency per year |
pf |
the payment frequency- number of payments per year |
plot |
tells whether or not to plot the percentage of each payment toward interest vs. period |
Effective Rate of Interest:
Balance at the end of period t:
Interest paid at the end of period t:
Principal paid at the end of period t:
Total Paid
Total Interest Paid
If where
is an integer and
:
Last regular payment (at period )
Drop payment (at period )
Balloon payment (at period )
A list of two components.
Schedule |
A data frame of the amortization schedule. |
Other |
A matrix of the input variables and other calculated variables. |
Assumes that payments are made at the end of each period.
One of n, Loan, or pmt must be NA (unknown).
If pmt is less than the amount of interest accumulated in the first period, then the function will stop because the loan will never be paid off due to the payments being too small.
If pmt is greater than the loan amount plus interest accumulated in the first period, then the function will stop because one payment will pay off the loan.
Kameron Penn and Jack Schmidt
amort.table(Loan=1000,n=2,i=.005,ic=1,pf=1) amort.table(Loan=100,pmt=40,i=.02,ic=2,pf=2,plot=FALSE) amort.table(Loan=NA,pmt=102.77,n=10,i=.005,plot=TRUE)
amort.table(Loan=1000,n=2,i=.005,ic=1,pf=1) amort.table(Loan=100,pmt=40,i=.02,ic=2,pf=2,plot=FALSE) amort.table(Loan=NA,pmt=102.77,n=10,i=.005,plot=TRUE)
Solves for the present value, future value, number of payments/periods, amount of the first payment, the payment increment amount per period, and/or the interest rate for an arithmetically growing annuity. It can also plot a time diagram of the payments.
annuity.arith(pv=NA,fv=NA,n=NA,p=NA,q=NA,i=NA,ic=1,pf=1,imm=TRUE,plot=FALSE)
annuity.arith(pv=NA,fv=NA,n=NA,p=NA,q=NA,i=NA,ic=1,pf=1,imm=TRUE,plot=FALSE)
pv |
present value of the annuity |
fv |
future value of the annuity |
n |
number of payments/periods |
p |
amount of the first payment |
q |
payment increment amount per period |
i |
nominal interest frequency convertible ic times per year |
ic |
interest conversion frequency per year |
pf |
the payment frequency- number of payments per year |
imm |
option for annuity immediate or annuity due, default is immediate (TRUE) |
plot |
option to display a time diagram of the payments |
Effective Rate of Interest:
Annuity Immediate:
Annuity Due:
Returns a matrix of the input variables, and calculated unknown variables.
At least one of pv, fv, n, p, q, or i must be NA (unknown).
pv and fv cannot both be specified, at least one must be NA (unknown).
Kameron Penn and Jack Schmidt
annuity.arith(pv=NA,fv=NA,n=20,p=100,q=4,i=.03,ic=1,pf=2,imm=TRUE) annuity.arith(pv=NA,fv=3000,n=20,p=100,q=NA,i=.05,ic=3,pf=2,imm=FALSE)
annuity.arith(pv=NA,fv=NA,n=20,p=100,q=4,i=.03,ic=1,pf=2,imm=TRUE) annuity.arith(pv=NA,fv=3000,n=20,p=100,q=NA,i=.05,ic=3,pf=2,imm=FALSE)
Solves for the present value, future value, number of payments/periods, amount of the first payment, the payment growth rate, and/or the interest rate for a geometrically growing annuity. It can also plot a time diagram of the payments.
annuity.geo(pv=NA,fv=NA,n=NA,p=NA,k=NA,i=NA,ic=1,pf=1,imm=TRUE,plot=FALSE)
annuity.geo(pv=NA,fv=NA,n=NA,p=NA,k=NA,i=NA,ic=1,pf=1,imm=TRUE,plot=FALSE)
pv |
present value of the annuity |
fv |
future value of the annuity |
n |
number of payments/periods for the annuity |
p |
amount of the first payment |
k |
payment growth rate per period |
i |
nominal interest rate convertible ic times per year |
ic |
interest conversion frequency per year |
pf |
the payment frequency- number of payments/periods per year |
imm |
option for annuity immediate or annuity due, default is immediate (TRUE) |
plot |
option to display a time diagram of the payments |
Effective Rate of Interest:
Annuity Immediate:
j != k:
j = k:
Annuity Due:
j != k:
j = k:
Returns a matrix of the input variables and calculated unknown variables.
At least one of pv, fv, n, pmt, k, or i must be NA (unknown).
pv and fv cannot both be specified, at least one must be NA (unknown).
annuity.geo(pv=NA,fv=100,n=10,p=9,k=.02,i=NA,ic=2,pf=.5,plot=TRUE) annuity.geo(pv=NA,fv=128,n=5,p=NA,k=.04,i=.03,pf=2)
annuity.geo(pv=NA,fv=100,n=10,p=9,k=.02,i=NA,ic=2,pf=.5,plot=TRUE) annuity.geo(pv=NA,fv=128,n=5,p=NA,k=.04,i=.03,pf=2)
Solves for the present value, future value, number of payments/periods, interest rate, and/or the amount of the payments for a level annuity. It can also plot a time diagram of the payments.
annuity.level(pv=NA,fv=NA,n=NA,pmt=NA,i=NA,ic=1,pf=1,imm=TRUE,plot=FALSE)
annuity.level(pv=NA,fv=NA,n=NA,pmt=NA,i=NA,ic=1,pf=1,imm=TRUE,plot=FALSE)
pv |
present value of the annuity |
fv |
future value of the annuity |
n |
number of payments/periods |
pmt |
value of the level payments |
i |
nominal interest rate convertible ic times per year |
ic |
interest conversion frequency per year |
pf |
the payment frequency- number of payments/periods per year |
imm |
option for annuity immediate or annuity due, default is immediate (TRUE) |
plot |
option to display a time diagram of the payments |
Effective Rate of Interest:
Annuity Immediate:
Annuity Due:
Returns a matrix of the input variables and calculated unknown variables.
At least one of pv, fv, n, pmt, or i must be NA (unknown).
pv and fv cannot both be specified, at least one must be NA (unknown).
annuity.level(pv=NA,fv=101.85,n=10,pmt=8,i=NA,ic=1,pf=1,imm=TRUE) annuity.level(pv=80,fv=NA,n=15,pf=2,pmt=NA,i=.01,imm=FALSE)
annuity.level(pv=NA,fv=101.85,n=10,pmt=8,i=NA,ic=1,pf=1,imm=TRUE) annuity.level(pv=80,fv=NA,n=15,pf=2,pmt=NA,i=.01,imm=FALSE)
Gives a table and graphical representation of the payoff and profit of a bear call spread for a range of future stock prices.
bear.call(S,K1,K2,r,t,price1,price2,plot=FALSE)
bear.call(S,K1,K2,r,t,price1,price2,plot=FALSE)
S |
spot price at time 0 |
K1 |
strike price of the short call |
K2 |
strike price of the long call |
r |
yearly continuously compounded risk free rate |
t |
time of expiration (in years) |
price1 |
price of the short call with strike price K1 |
price2 |
price of the long call with strike price K2 |
plot |
tells whether or not to plot the payoff and profit |
Stock price at time t
For : payoff
For : payoff
For : payoff
payoff = profit + (price1 - price2)
A list of two components.
Payoff |
A data frame of different payoffs and profits for given stock prices. |
Premiums |
A matrix of the premiums for the call options and the net cost. |
K1 must be less than S, and K2 must be greater than S.
Kameron Penn and Jack Schmidt
bear.call(S=100,K1=70,K2=130,r=.03,t=1,price1=20,price2=10,plot=TRUE)
bear.call(S=100,K1=70,K2=130,r=.03,t=1,price1=20,price2=10,plot=TRUE)
Gives a table and graphical representation of the payoff and profit of a bear call spread for a range of future stock prices. Uses the Black Scholes equation for the call prices.
bear.call.bls(S,K1,K2,r,t,sd,plot=FALSE)
bear.call.bls(S,K1,K2,r,t,sd,plot=FALSE)
S |
spot price at time 0 |
K1 |
strike price of the short call |
K2 |
strike price of the long call |
r |
yearly continuously compounded risk free rate |
t |
time of expiration (in years) |
sd |
standard deviation of the stock (volatility) |
plot |
tells whether or not to plot the payoff and profit |
Stock price at time t
For : payoff
For : payoff
For : payoff
payoff = profit
A list of two components.
Payoff |
A data frame of different payoffs and profits for given stock prices. |
Premiums |
A matrix of the premiums for the call options and the net cost. |
K1 must be less than S, and K2 must be greater than S.
Kameron Penn and Jack Schmidt
bear.call.bls(S=100,K1=70,K2=130,r=.03,t=1,sd=.2)
bear.call.bls(S=100,K1=70,K2=130,r=.03,t=1,sd=.2)
Gives the price and first order greeks for call and put options in the Black Scholes equation.
bls.order1(S,K,r,t,sd,D=0)
bls.order1(S,K,r,t,sd,D=0)
S |
spot price at time 0 |
K |
strike price |
r |
continuously compounded yearly risk free rate |
t |
time of expiration (in years) |
sd |
standard deviation of the stock (volatility) |
D |
continuous dividend yield |
A matrix of the calculated greeks and prices for call and put options.
Cannot have any inputs as vectors.
t cannot be negative.
Either both or neither of S and K must be negative.
Kameron Penn and Jack Schmidt
x <- bls.order1(S=100, K=110, r=.05, t=1, sd=.1, D=0) ThetaPut <- x["Theta","Put"] DeltaCall <- x[2,1]
x <- bls.order1(S=100, K=110, r=.05, t=1, sd=.1, D=0) ThetaPut <- x["Theta","Put"] DeltaCall <- x[2,1]
Solves for the price, premium/discount, and Durations and Convexities (in terms of periods). At a specified period (t), it solves for the full and clean prices, and the write up/down amount. Also has the option to plot the convexity of the bond.
bond(f,r,c,n,i,ic=1,cf=1,t=NA,plot=FALSE)
bond(f,r,c,n,i,ic=1,cf=1,t=NA,plot=FALSE)
f |
face value |
r |
coupon rate convertible cf times per year |
c |
redemption value |
n |
the number of coupons/periods for the bond |
i |
nominal interest rate convertible ic times per year |
ic |
interest conversion frequency per year |
cf |
coupon frequency- number of coupons per year |
t |
specified period for which the price and write up/down amount is solved for, if not NA |
plot |
tells whether or not to plot the convexity |
Effective Rate of Interest:
coupon (per period)
price = coupon
Price (for period t):
If t is an integer: price =coupon
If t is not an integer then where
is an integer and
:
full price coupon
clean price = full pricecoupon
If price > c :
premium = price
Write-down amount (for period t) coupon
If price < c :
discount price
Write-up amount (for period t) coupon
A matrix of all of the bond details and calculated variables.
t must be less than n.
To make the duration in terms of years, divide it by cf.
To make the convexity in terms of years, divide it by .
bond(f=100,r=.04,c=100,n=20,i=.04,ic=1,cf=1,t=1) bond(f=100,r=.05,c=110,n=10,i=.06,ic=1,cf=2,t=5)
bond(f=100,r=.04,c=100,n=20,i=.04,ic=1,cf=1,t=1) bond(f=100,r=.05,c=110,n=10,i=.06,ic=1,cf=2,t=5)
Gives a table and graphical representation of the payoff and profit of a bull call spread for a range of future stock prices.
bull.call(S,K1,K2,r,t,price1,price2,plot=FALSE)
bull.call(S,K1,K2,r,t,price1,price2,plot=FALSE)
S |
spot price at time 0 |
K1 |
strike price of the long call |
K2 |
strike price of the short call |
r |
yearly continuously compounded risk free rate |
t |
time of expiration (in years) |
price1 |
price of the long call with strike price K1 |
price2 |
price of the short call with strike price K2 |
plot |
tells whether or not to plot the payoff and profit |
Stock price at time t
For : payoff
For : payoff
For : payoff
profit = payoff + (price2 - price1)
A list of two components.
Payoff |
A data frame of different payoffs and profits for given stock prices. |
Premiums |
A matrix of the premiums for the call options and the net cost. |
K1 must be less than S, and K2 must be greater than S.
bull.call(S=115,K1=100,K2=145,r=.03,t=1,price1=20,price2=10,plot=TRUE)
bull.call(S=115,K1=100,K2=145,r=.03,t=1,price1=20,price2=10,plot=TRUE)
Gives a table and graphical representation of the payoff and profit of a bull call spread for a range of future stock prices. Uses the Black Scholes equation for the call prices.
bull.call.bls(S,K1,K2,r,t,sd,plot=FALSE)
bull.call.bls(S,K1,K2,r,t,sd,plot=FALSE)
S |
spot price at time 0 |
K1 |
strike price of the long call |
K2 |
strike price of the short call |
r |
yearly continuously compounded risk free rate |
t |
time of expiration (in years) |
sd |
standard deviation of the stock (volatility) |
plot |
tells whether or not to plot the payoff and profit |
Stock price at time t
For : payoff
For : payoff
For : payoff
profit = payoff
A list of two components.
Payoff |
A data frame of different payoffs and profits for given stock prices. |
Premiums |
A matrix of the premiums for the call options and the net cost. |
K1 must be less than S, and K2 must be greater than S.
bull.call.bls(S=115,K1=100,K2=145,r=.03,t=1,sd=.2)
bull.call.bls(S=115,K1=100,K2=145,r=.03,t=1,sd=.2)
Gives a table and graphical representation of the payoff and profit of a long butterfly spread for a range of future stock prices.
butterfly.spread(S,K1,K2=S,K3,r,t,price1,price2,price3,plot=FALSE)
butterfly.spread(S,K1,K2=S,K3,r,t,price1,price2,price3,plot=FALSE)
S |
spot price at time 0 |
K1 |
strike price of the first long call |
K2 |
strike price of the two short calls |
K3 |
strike price of the second long call |
r |
continuously compounded yearly risk free rate |
t |
time of expiration (in years) |
price1 |
price of the long call with strike price K1 |
price2 |
price of one of the short calls with strike price K2 |
price3 |
price of the long call with strike price K3 |
plot |
tells whether or not to plot the payoff and profit |
Stock price at time t
For : payoff
For : payoff
For : payoff
For : payoff
profit = payoffprice2 - price1 - price3
A list of two components.
Payoff |
A data frame of different payoffs and profits for given stock prices. |
Premiums |
A matrix of the premiums for the call options and the net cost. |
K2 must be equal to S.
K3 and K1 must both be equidistant to K2 and S.
K1 < K2 < K3 must be true.
butterfly.spread(S=100,K1=75,K2=100,K3=125,r=.03,t=1,price1=25,price2=10,price3=5)
butterfly.spread(S=100,K1=75,K2=100,K3=125,r=.03,t=1,price1=25,price2=10,price3=5)
Gives a table and graphical representation of the payoff and profit of a long butterfly spread for a range of future stock prices. Uses the Black Scholes equation for the call prices.
butterfly.spread.bls(S,K1,K2=S,K3,r,t,sd,plot=FALSE)
butterfly.spread.bls(S,K1,K2=S,K3,r,t,sd,plot=FALSE)
S |
spot price at time 0 |
K1 |
strike price of the first long call |
K2 |
strike price of the two short calls |
K3 |
strike price of the second long call |
r |
continuously compounded yearly risk free rate |
t |
time of expiration (in years) |
sd |
standard deviation of the stock (volatility) |
plot |
tells whether or not to plot the payoff and profit |
Stock price at time t
For : payoff
For : payoff
For : payoff
For : payoff
profit = payoff
A list of two components.
Payoff |
A data frame of different payoffs and profits for given stock prices. |
Premiums |
A matrix of the premiums for the call options and the net cost. |
K2 must be equal to S.
K3 and K1 must both be equidistant to K2 and S.
K1 < K2 < K3 must be true.
butterfly.spread.bls(S=100,K1=75,K2=100,K3=125,r=.03,t=1,sd=.2)
butterfly.spread.bls(S=100,K1=75,K2=100,K3=125,r=.03,t=1,sd=.2)
Calculates the present value, macaulay duration and convexity, and modified duration and convexity for given cash flows. It also plots the convexity and time diagram of the cash flows.
cf.analysis(cf,times,i,plot=FALSE,time.d=FALSE)
cf.analysis(cf,times,i,plot=FALSE,time.d=FALSE)
cf |
vector of cash flows |
times |
vector of the periods for each cash flow |
i |
interest rate per period |
plot |
tells whether or not to plot the convexity |
time.d |
tells whether or not to plot the time diagram of the cash flows |
A matrix of all of the calculated values.
The periods in t must be positive integers.
cf.analysis(cf=c(1,1,101),times=c(1,2,3),i=.04,time.d=TRUE) cf.analysis(cf=c(5,1,5,45,5),times=c(5,4,6,7,5),i=.06,plot=TRUE)
cf.analysis(cf=c(1,1,101),times=c(1,2,3),i=.04,time.d=TRUE) cf.analysis(cf=c(5,1,5,45,5),times=c(5,4,6,7,5),i=.06,plot=TRUE)
Gives a table and graphical representation of the payoff and profit of a collar strategy for a range of future stock prices.
collar(S,K1,K2,r,t,price1,price2,plot=FALSE)
collar(S,K1,K2,r,t,price1,price2,plot=FALSE)
S |
spot price at time 0 |
K1 |
strike price of the long put |
K2 |
strike price of the short call |
r |
yearly continuously compounded risk free rate |
t |
time of expiration (in years) |
price1 |
price of the long put with strike price K1 |
price2 |
price of the short call with strike price K2 |
plot |
tells whether or not to plot the payoff and profit |
Stock price at time t
For : payoff
For : payoff
For : payoff
profit = payoff + (price2 - price1)
A list of two components.
Payoff |
A data frame of different payoffs and profits for given stock prices. |
Premiums |
A matrix of the premiums for the call and put options and the net cost. |
collar(S=100,K1=90,K2=110,r=.05,t=1,price1=5,price2=15,plot=TRUE)
collar(S=100,K1=90,K2=110,r=.05,t=1,price1=5,price2=15,plot=TRUE)
Gives a table and graphical representation of the payoff and profit of a collar strategy for a range of future stock prices. Uses the Black Scholes equation for the call and put prices.
collar.bls(S,K1,K2,r,t,sd,plot=FALSE)
collar.bls(S,K1,K2,r,t,sd,plot=FALSE)
S |
spot price at time 0 |
K1 |
strike price of the long put |
K2 |
strike price of the short call |
r |
yearly continuously compounded risk free rate |
t |
time of expiration (in years) |
sd |
standard deviation of the stock (volatility) |
plot |
tells whether or not to plot the payoff and profit |
Stock price at time t
For : payoff
For : payoff
For : payoff
profit = payoff
A list of two components.
Payoff |
A data frame of different payoffs and profits for given stock prices. |
Premiums |
A matrix of the premiums for the call and put options and the net cost. |
collar.bls(S=100,K1=90,K2=110,r=.05,t=1,sd=.2)
collar.bls(S=100,K1=90,K2=110,r=.05,t=1,sd=.2)
Gives a table and graphical representation of the payoff and profit of a covered call strategy for a range of future stock prices.
covered.call(S,K,r,t,sd,price=NA,plot=FALSE)
covered.call(S,K,r,t,sd,price=NA,plot=FALSE)
S |
spot price at time 0 |
K |
strike price |
r |
continuously compounded yearly risk free rate |
t |
time of expiration (in years) |
sd |
standard deviation of the stock (volatility) |
price |
specified call price if the Black Scholes pricing is not desired (leave as NA to use the Black Scholes pricing) |
plot |
tells whether or not to plot the payoff and profit |
Stock price at time t
For : payoff
For : payoff
profit = payoff + price
A list of two components.
Payoff |
A data frame of different payoffs and profits for given stock prices. |
Premium |
The price of the call option. |
Finds the put price by using the Black Scholes equation by default.
covered.call(S=100,K=110,r=.03,t=1,sd=.2,plot=TRUE)
covered.call(S=100,K=110,r=.03,t=1,sd=.2,plot=TRUE)
Gives a table and graphical representation of the payoff and profit of a covered put strategy for a range of future stock prices.
covered.put(S,K,r,t,sd,price=NA,plot=FALSE)
covered.put(S,K,r,t,sd,price=NA,plot=FALSE)
S |
spot price at time 0 |
K |
strike price |
r |
continuously compounded yearly risk free rate |
t |
time of expiration (in years) |
sd |
standard deviation of the stock (volatility) |
price |
specified put price if the Black Scholes pricing is not desired (leave as NA to use the Black Scholes pricing) |
plot |
tells whether or not to plot the payoff and profit |
Stock price at time t
For : payoff
For : payoff
profit = payoff + price
A list of two components.
Payoff |
A data frame of different payoffs and profits for given stock prices. |
Premium |
The price of the put option. |
Finds the put price by using the Black Scholes equation by default.
covered.put(S=100,K=110,r=.03,t=1,sd=.2,plot=TRUE)
covered.put(S=100,K=110,r=.03,t=1,sd=.2,plot=TRUE)
Gives a table and graphical representation of the payoff of a forward contract, and calculates the forward price for the contract.
forward(S,t,r,position,div.structure="none",dividend=NA,df=1,D=NA,k=NA,plot=FALSE)
forward(S,t,r,position,div.structure="none",dividend=NA,df=1,D=NA,k=NA,plot=FALSE)
S |
spot price at time 0 |
t |
time of expiration (in years) |
r |
continuously compounded yearly risk free rate |
position |
either buyer or seller of the contract ("long" or "short") |
div.structure |
the structure of the dividends for the underlying ("none", "continuous", or "discrete") |
dividend |
amount of each dividend, or amount of first dividend if k is not NA |
df |
dividend frequency- number of dividends per year |
D |
continuous dividend yield |
k |
dividend growth rate per df |
plot |
tells whether or not to plot the payoff |
Stock price at time t
Long Position: payoff = - forward price
Short Position: payoff = forward price -
If div.structure = "none"
forward price
If div.structure = "discrete"
Number of dividends:
if k = NA: forward price dividend
if k != j: forward price dividend
if k = j: forward price dividend
If div.structure = "continuous"
forward price
A list of two components.
Payoff |
A data frame of different payoffs for given stock prices. |
Price |
The forward price of the contract. |
Leave an input variable as NA if it is not needed (ie. k=NA if div.structure="none").
forward(S=100,t=2,r=.03,position="short",div.structure="none") forward(S=100,t=2,r=.03,position="long",div.structure="discrete",dividend=3,k=.02) forward(S=100,t=1,r=.03,position="long",div.structure="continuous",D=.01)
forward(S=100,t=2,r=.03,position="short",div.structure="none") forward(S=100,t=2,r=.03,position="long",div.structure="discrete",dividend=3,k=.02) forward(S=100,t=1,r=.03,position="long",div.structure="continuous",D=.01)
Gives a table and graphical representation of the payoff of a prepaid forward contract, and calculates the prepaid forward price for the contract.
forward.prepaid(S,t,r,position,div.structure="none",dividend=NA,df=1,D=NA, k=NA,plot=FALSE)
forward.prepaid(S,t,r,position,div.structure="none",dividend=NA,df=1,D=NA, k=NA,plot=FALSE)
S |
spot price at time 0 |
t |
time of expiration (in years) |
r |
continuously compounded yearly risk free rate |
position |
either buyer or seller of the contract ("long" or "short") |
div.structure |
the structure of the dividends for the underlying ("none", "continuous", or "discrete") |
dividend |
amount of each dividend, or amount of first dividend if k is not NA |
df |
dividend frequency- number of dividends per year |
D |
continuous dividend yield |
k |
dividend growth rate per df |
plot |
tells whether or not to plot the payoff |
Stock price at time t
Long Position: payoff = - prepaid forward price
Short Position: payoff = prepaid forward price -
If div.structure = "none"
forward price
If div.structure = "discrete"
Number of dividends:
if k = NA: prepaid forward price dividend
if k != j: prepaid forward price dividend
if k = j: prepaid forward price dividend
If div.structure = "continuous"
prepaid forward price
A list of two components.
Payoff |
A data frame of different payoffs for given stock prices. |
Price |
The prepaid forward price of the contract. |
Leave an input variable as NA if it is not needed (ie. k=NA if div.structure="none").
forward.prepaid(S=100,t=2,r=.04,position="short",div.structure="none") forward.prepaid(S=100,t=2,r=.03,position="long",div.structure="discrete", dividend=3,k=.02,df=2) forward.prepaid(S=100,t=1,r=.05,position="long",div.structure="continuous",D=.06)
forward.prepaid(S=100,t=2,r=.04,position="short",div.structure="none") forward.prepaid(S=100,t=2,r=.03,position="long",div.structure="discrete", dividend=3,k=.02,df=2) forward.prepaid(S=100,t=1,r=.05,position="long",div.structure="continuous",D=.06)
Calculates internal rate of return for a series of cash flows, and provides a time diagram of the cash flows.
IRR(cf0,cf,times,plot=FALSE)
IRR(cf0,cf,times,plot=FALSE)
cf0 |
cash flow at period 0 |
cf |
vector of cash flows |
times |
vector of the times for each cash flow |
plot |
option whether or not to provide the time diagram |
The internal rate of return.
Periods in t must be positive integers.
Uses polyroot function to solve equation given by series of cash flows, meaning that in the case of having a negative IRR, multiple answers may be returned.
Kameron Penn and Jack Schmidt
IRR(cf0=1,cf=c(1,2,1),times=c(1,3,4)) IRR(cf0=100,cf=c(1,1,30,40,50,1),times=c(1,1,3,4,5,6))
IRR(cf0=1,cf=c(1,2,1),times=c(1,3,4)) IRR(cf0=100,cf=c(1,1,30,40,50,1),times=c(1,1,3,4,5,6))
Calculates the net present value for a series of cash flows, and provides a time diagram of the cash flows.
NPV(cf0,cf,times,i,plot=FALSE)
NPV(cf0,cf,times,i,plot=FALSE)
cf0 |
cash flow at period 0 |
cf |
vector of cash flows |
times |
vector of the times for each cash flow |
i |
interest rate per period |
plot |
tells whether or not to plot the time diagram of the cash flows |
The NPV.
The periods in t must be positive integers.
The lengths of cf and t must be equal.
NPV(cf0=100,cf=c(50,40),times=c(3,5),i=.01) NPV(cf0=100,cf=50,times=3,i=.05) NPV(cf0=100,cf=c(50,60,10,20),times=c(1,5,9,9),i=.045)
NPV(cf0=100,cf=c(50,40),times=c(3,5),i=.01) NPV(cf0=100,cf=50,times=3,i=.05) NPV(cf0=100,cf=c(50,60,10,20),times=c(1,5,9,9),i=.045)
Gives a table and graphical representation of the payoff and profit of a long or short call option for a range of future stock prices.
option.call(S,K,r,t,sd,price=NA,position,plot=FALSE)
option.call(S,K,r,t,sd,price=NA,position,plot=FALSE)
S |
spot price at time 0 |
K |
strike price |
r |
continuously compounded yearly risk free rate |
t |
time of expiration (in years) |
sd |
standard deviation of the stock (volatility) |
price |
specified call price if the Black Scholes pricing is not desired (leave as NA to use the Black Scholes pricing) |
position |
either buyer or seller of option ("long" or "short") |
plot |
tells whether or not to plot the payoff and profit |
Stock price at time t
Long Position:
payoff = max
profit = payoff - price
Short Position:
payoff = -max
profit = payoff + price
A list of two components.
Payoff |
A data frame of different payoffs and profits for given stock prices. |
Premium |
The price for the call option. |
Finds the call price by using the Black Scholes equation by default.
Kameron Penn and Jack Schmidt
option.call(S=100,K=110,r=.03,t=1.5,sd=.2,price=NA,position="short") option.call(S=100,K=100,r=.03,t=1,sd=.2,price=10,position="long")
option.call(S=100,K=110,r=.03,t=1.5,sd=.2,price=NA,position="short") option.call(S=100,K=100,r=.03,t=1,sd=.2,price=10,position="long")
Gives a table and graphical representation of the payoff and profit of a long or short put option for a range of future stock prices.
option.put(S,K,r,t,sd,price=NA,position,plot=FALSE)
option.put(S,K,r,t,sd,price=NA,position,plot=FALSE)
S |
spot price at time 0 |
K |
strike price |
r |
continuously compounded yearly risk free rate |
t |
time of expiration (in years) |
sd |
standard deviation of the stock (volatility) |
price |
specified put price if the Black Scholes pricing is not desired (leave as NA to use the Black Scholes pricing) |
position |
either buyer or seller of option ("long" or "short") |
plot |
tells whether or not to plot the payoff and profit |
Stock price at time t
Long Position:
payoff = max
profit = payoff
Short Position:
payoff = -max
profit = payoff
A list of two components.
Payoff |
A data frame of different payoffs and profits for given stock prices. |
Premium |
The price of the put option. |
Finds the put price by using the Black Scholes equation by default.
Kameron Penn and Jack Schmidt
option.put(S=100,K=110,r=.03,t=1,sd=.2,price=NA,position="short") option.put(S=100,K=110,r=.03,t=1,sd=.2,price=NA,position="long")
option.put(S=100,K=110,r=.03,t=1,sd=.2,price=NA,position="short") option.put(S=100,K=110,r=.03,t=1,sd=.2,price=NA,position="long")
Solves for the present value, amount of the first payment, the payment increment amount per period, or the interest rate for an arithmetically growing perpetuity.
perpetuity.arith(pv=NA,p=NA,q=NA,i=NA,ic=1,pf=1,imm=TRUE)
perpetuity.arith(pv=NA,p=NA,q=NA,i=NA,ic=1,pf=1,imm=TRUE)
pv |
present value of the annuity |
p |
amount of the first payment |
q |
payment increment amount per period |
i |
nominal interest rate convertible ic times per year |
ic |
interest conversion frequency per year |
pf |
the payment frequency- number of payments per year |
imm |
option for annuity immediate or annuity due, default is immediate (TRUE) |
Effective Rate of Interest:
Perpetuity Immediate:
Perpetuity Due:
Returns a matrix of input variables, and calculated unknown variables.
One of pv, p, q, or i must be NA (unknown).
Kameron Penn and Jack Schmidt
perpetuity.arith(100,p=1,q=.5,i=NA,ic=1,pf=1,imm=TRUE) perpetuity.arith(pv=NA,p=1,q=.5,i=.07,ic=1,pf=1,imm=TRUE) perpetuity.arith(pv=100,p=NA,q=1,i=.05,ic=.5,pf=1,imm=FALSE)
perpetuity.arith(100,p=1,q=.5,i=NA,ic=1,pf=1,imm=TRUE) perpetuity.arith(pv=NA,p=1,q=.5,i=.07,ic=1,pf=1,imm=TRUE) perpetuity.arith(pv=100,p=NA,q=1,i=.05,ic=.5,pf=1,imm=FALSE)
Solves for the present value, amount of the first payment, the payment growth rate, or the interest rate for a geometrically growing perpetuity.
perpetuity.geo(pv=NA,p=NA,k=NA,i=NA,ic=1,pf=1,imm=TRUE)
perpetuity.geo(pv=NA,p=NA,k=NA,i=NA,ic=1,pf=1,imm=TRUE)
pv |
present value |
p |
amount of the first payment |
k |
payment growth rate per period |
i |
nominal interest rate convertible ic times per year |
ic |
interest conversion frequency per year |
pf |
the payment frequency- number of payments and periods per year |
imm |
option for perpetuity immediate or due, default is immediate (TRUE) |
Effective Rate of Interest:
Perpetuity Immediate:
j > k:
Perpetuity Due:
j > k:
Returns a matrix of the input variables and calculated unknown variables.
One of pv, p, k, or i must be NA (unknown).
perpetuity.geo(pv=NA,p=5,k=.03,i=.04,ic=1,pf=1,imm=TRUE) perpetuity.geo(pv=1000,p=5,k=NA,i=.04,ic=1,pf=1,imm=FALSE)
perpetuity.geo(pv=NA,p=5,k=.03,i=.04,ic=1,pf=1,imm=TRUE) perpetuity.geo(pv=1000,p=5,k=NA,i=.04,ic=1,pf=1,imm=FALSE)
Solves for the present value, interest rate, or the amount of the payments for a level perpetuity.
perpetuity.level(pv=NA,pmt=NA,i=NA,ic=1,pf=1,imm=TRUE)
perpetuity.level(pv=NA,pmt=NA,i=NA,ic=1,pf=1,imm=TRUE)
pv |
present value |
pmt |
value of level payments |
i |
nominal interest rate convertible ic times per year |
ic |
interest conversion frequency per year |
pf |
the payment frequency- number of payments per year |
imm |
option for perpetuity immediate or annuity due, default is immediate (TRUE) |
Effective Rate of Interest:
Perpetuity Immediate:
Perpetuity Due:
Returns a matrix of the input variables and calculated unknown variables.
One of pv, pmt, or i must be NA (unknown).
Kameron Penn and Jack Schmidt
perpetuity.level(pv=100,pmt=NA,i=.05,ic=1,pf=2,imm=TRUE) perpetuity.level(pv=100,pmt=NA,i=.05,ic=1,pf=2,imm=FALSE)
perpetuity.level(pv=100,pmt=NA,i=.05,ic=1,pf=2,imm=TRUE) perpetuity.level(pv=100,pmt=NA,i=.05,ic=1,pf=2,imm=FALSE)
Gives a table and graphical representation of the payoff and profit of a protective put strategy for a range of future stock prices.
protective.put(S,K,r,t,sd,price=NA,plot=FALSE)
protective.put(S,K,r,t,sd,price=NA,plot=FALSE)
S |
spot price at time 0 |
K |
strike price |
r |
continuously compounded yearly risk free rate |
t |
time of expiration (in years) |
sd |
standard deviation of the stock (volatility) |
price |
specified put price if the Black Scholes pricing is not desired (leave as NA to use the Black Scholes pricing) |
plot |
tells whether or not to plot the payoff and profit |
Stock price at time t
For : payoff
For : payoff
profit = payoff - price
A list of two components.
Payoff |
A data frame of different payoffs and profits for given stock prices. |
Premium |
The price of the put option. |
Finds the put price by using the Black Scholes equation by default.
Kameron Penn and Jack Schmidt
protective.put(S=100,K=100,r=.03,t=1,sd=.2) protective.put(S=100,K=90,r=.01,t=.5,sd=.1)
protective.put(S=100,K=100,r=.03,t=1,sd=.2) protective.put(S=100,K=90,r=.01,t=.5,sd=.1)
Converts given rate to desired nominal interest, discount, and force of interest rates.
rate.conv(rate, conv=1, type="interest", nom=1)
rate.conv(rate, conv=1, type="interest", nom=1)
rate |
current rate |
conv |
how many times per year the current rate is convertible |
type |
current rate as one of "interest", "discount" or "force" |
nom |
desired number of times the calculated rates will be convertible |
A matrix of the interest, discount, and force of interest conversions for effective, given and desired conversion rates.
The row named 'eff' is used for the effective rates, and the nominal rates are in a row named 'nom(x)' where the rate is convertible x times per year.
Kameron Penn and Jack Schmidt
rate.conv(rate=.05,conv=2,nom=1) rate.conv(rate=.05,conv=2,nom=4,type="discount") rate.conv(rate=.05,conv=2,nom=4,type="force")
rate.conv(rate=.05,conv=2,nom=1) rate.conv(rate=.05,conv=2,nom=4,type="discount") rate.conv(rate=.05,conv=2,nom=4,type="force")
Gives a table and graphical representation of the payoff and profit of a long or short straddle for a range of future stock prices.
straddle(S,K,r,t,price1,price2,position,plot=FALSE)
straddle(S,K,r,t,price1,price2,position,plot=FALSE)
S |
spot price at time 0 |
K |
strike price of the call and put |
r |
continuously compounded yearly risk free rate |
t |
time of expiration (in years) |
price1 |
price of the long call with strike price K |
price2 |
price of the long put with strike price K |
position |
either buyer or seller of option ("long" or "short") |
plot |
tells whether or not to plot the payoff and profit |
Stock price at time t
Long Position:
For : payoff
For : payoff
profit = payoff - (price1 + price2)
Short Position:
For : payoff
For : payoff
profit = payoff + (price1 + price2)
A list of two components.
Payoff |
A data frame of different payoffs and profits for given stock prices. |
Premiums |
A matrix of the premiums for the call and put options, and the net cost. |
straddle(S=100,K=110,r=.03,t=1,price1=15,price2=10,position="short")
straddle(S=100,K=110,r=.03,t=1,price1=15,price2=10,position="short")
Gives a table and graphical representation of the payoff and profit of a long or short straddle for a range of future stock prices. Uses the Black Scholes equation for the call and put prices.
straddle.bls(S,K,r,t,sd,position,plot=FALSE)
straddle.bls(S,K,r,t,sd,position,plot=FALSE)
S |
spot price at time 0 |
K |
strike price of the call and put |
r |
continuously compounded yearly risk free rate |
t |
time of expiration (in years) |
sd |
standard deviation of the stock (volatility) |
position |
either buyer or seller of option ("long" or "short") |
plot |
tells whether or not to plot the payoff and profit |
Stock price at time t
Long Position:
For : payoff
For : payoff
profit = payoff
Short Position:
For : payoff
For : payoff
profit = payoff
A list of two components.
Payoff |
A data frame of different payoffs and profits for given stock prices. |
Premiums |
A matrix of the premiums for the call and put options, and the net cost. |
straddle.bls(S=100,K=110,r=.03,t=1,sd=.2,position="short") straddle.bls(S=100,K=110,r=.03,t=1,sd=.2,position="long",plot=TRUE)
straddle.bls(S=100,K=110,r=.03,t=1,sd=.2,position="short") straddle.bls(S=100,K=110,r=.03,t=1,sd=.2,position="long",plot=TRUE)
Gives a table and graphical representation of the payoff and profit of a long strangle spread for a range of future stock prices.
strangle(S,K1,K2,r,t,price1,price2,plot=FALSE)
strangle(S,K1,K2,r,t,price1,price2,plot=FALSE)
S |
spot price at time 0 |
K1 |
strike price of the long put |
K2 |
strike price of the long call |
r |
continuously compounded yearly risk free rate |
t |
time of expiration (in years) |
price1 |
price of the long put with strike price K1 |
price2 |
price of the long call with strike price K2 |
plot |
tells whether or not to plot the payoff and profit |
Stock price at time t
For : payoff
For : payoff
For : payoff
profit = payoff - (price1 + price2)
A list of two components.
Payoff |
A data frame of different payoffs and profits for given stock prices. |
Premiums |
A matrix of the premiums for the call and put options, and the net cost. |
K1 < S < K2 must be true.
Kameron Penn and Jack Schmidt
strangle(S=105,K1=100,K2=110,r=.03,t=1,price1=10,price2=15,plot=TRUE)
strangle(S=105,K1=100,K2=110,r=.03,t=1,price1=10,price2=15,plot=TRUE)
Gives a table and graphical representation of the payoff and profit of a long strangle spread for a range of future stock prices. Uses the Black Scholes equation for the call prices.
strangle.bls(S,K1,K2,r,t,sd,plot=FALSE)
strangle.bls(S,K1,K2,r,t,sd,plot=FALSE)
S |
spot price at time 0 |
K1 |
strike price of the long put |
K2 |
strike price of the long call |
r |
continuously compounded yearly risk free rate |
t |
time of expiration (in years) |
sd |
standard deviation of the stock (volatility) |
plot |
tells whether or not to plot the payoff and profit |
Stock price at time t
For : payoff
For : payoff
For : payoff
profit = payoff
A list of two components.
Payoff |
A data frame of different payoffs and profits for given stock prices. |
Premiums |
A matrix of the premiums for the call and put options, and the net cost. |
K1 < S < K2 must be true.
Kameron Penn and Jack Schmidt
strangle.bls(S=105,K1=100,K2=110,r=.03,t=1,sd=.2) strangle.bls(S=115,K1=50,K2=130,r=.03,t=1,sd=.2)
strangle.bls(S=105,K1=100,K2=110,r=.03,t=1,sd=.2) strangle.bls(S=115,K1=50,K2=130,r=.03,t=1,sd=.2)
Solves for the fixed swap price, given the variable prices and interest rates (either as spot rates or zero coupon bond prices).
swap.commodity(prices, rates, type="spot_rate")
swap.commodity(prices, rates, type="spot_rate")
prices |
vector of variable prices |
rates |
vector of variable rates |
type |
rates defined as either "spot_rate" or "zcb_price" |
For spot rates:
For zero coupon bond prices:
Where fixed swap price.
The fixed swap price.
Length of the price vector and rate vector must be of the same length.
Kameron Penn and Jack Schmidt
swap.commodity(prices=c(103,106,108), rates=c(.04,.05,.06)) swap.commodity(prices=c(103,106,108), rates=c(.9615,.907,.8396),type="zcb_price") swap.commodity(prices=c(105,105,105), rates=c(.85,.89,.80),type="zcb_price")
swap.commodity(prices=c(103,106,108), rates=c(.04,.05,.06)) swap.commodity(prices=c(103,106,108), rates=c(.9615,.907,.8396),type="zcb_price") swap.commodity(prices=c(105,105,105), rates=c(.85,.89,.80),type="zcb_price")
Solves for the fixed interest rate given the variable interest rates (either as spot rates or zero coupon bond prices).
swap.rate(rates, type="spot_rate")
swap.rate(rates, type="spot_rate")
rates |
vector of variable rates |
type |
rates as either "spot_rate" or "zcb_price" |
For spot rates:
For zero coupon bond prices:
Where fixed swap rate.
The fixed interest rate swap.
swap.rate(rates=c(.04, .05, .06), type = "spot_rate") swap.rate(rates=c(.93,.95,.98,.90), type = "zcb_price")
swap.rate(rates=c(.04, .05, .06), type = "spot_rate") swap.rate(rates=c(.93,.95,.98,.90), type = "zcb_price")
Solves for the present value, future value, time, or the interest rate for the accumulation of money earning compound interest. It can also plot the time value for each period.
TVM(pv=NA,fv=NA,n=NA,i=NA,ic=1,plot=FALSE)
TVM(pv=NA,fv=NA,n=NA,i=NA,ic=1,plot=FALSE)
pv |
present value |
fv |
future value |
n |
number of periods |
i |
nominal interest rate convertible ic times per period |
ic |
interest conversion frequency per period |
plot |
tells whether or not to produce a plot of the time value at each period |
Returns a matrix of the input variables and calculated unknown variables.
Exactly one of pv, fv, n, or i must be NA (unknown).
TVM(pv=10,fv=20,i=.05,ic=2,plot=TRUE) TVM(pv=50,n=5,i=.04,plot=TRUE)
TVM(pv=10,fv=20,i=.05,ic=2,plot=TRUE) TVM(pv=50,n=5,i=.04,plot=TRUE)
Calculates the dollar weighted yield.
yield.dollar(cf, times, start, end, endtime)
yield.dollar(cf, times, start, end, endtime)
cf |
vector of cash flows |
times |
vector of times for when cash flows occur |
start |
beginning balance |
end |
ending balance |
endtime |
end time of comparison |
The dollar weighted yield.
Time of comparison (endtime) must be larger than any number in vector of cash flow times.
Length of cashflow vector and times vector must be equal.
yield.dollar(cf=c(20,10,50),times=c(.25,.5,.75),start=100,end=175,endtime=1) yield.dollar(cf=c(500,-1000),times=c(3/12,18/12),start=25200,end=25900,endtime=21/12)
yield.dollar(cf=c(20,10,50),times=c(.25,.5,.75),start=100,end=175,endtime=1) yield.dollar(cf=c(500,-1000),times=c(3/12,18/12),start=25200,end=25900,endtime=21/12)
Calculates the time weighted yield.
yield.time(cf,bal)
yield.time(cf,bal)
cf |
vector of cash flows |
bal |
vector of balances |
The time weighted yield.
Length of cash flows must be one less than the length of balances.
If lengths are equal, it will not use final cash flow.
Kameron Penn and Jack Schmidt
yield.time(cf=c(0,200,100,50),bal=c(1000,800,1150,1550,1700))
yield.time(cf=c(0,200,100,50),bal=c(1000,800,1150,1550,1700))