Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

A05 Busqueda Binaria y Arboles Binomiales (Opcional)

Due Jul 6 at 5:35pm Points 100.32 Questions 33 Time Limit None


Allowed Attempts 4

Instructions
Este quiz consta de preguntas de opción múltiple, principalmente para reforzar los conceptos teóricos vistos en clase y
repasar algunas partes de programación importantes para el caso de uso estudiado.

Si alguna pregunta contiene código, es perfectamente válido utilizar R Studio para verificar la respuesta. La mayoría del
contenido ya se vio en clase, pero si hay algo nuevo tenderá a ser algo de código que pueden probar por su cuenta.

Tienes cuatro intentos para resolver este quiz y se debe terminar ANTES de la próxima sesión.

Take the Quiz Again

Attempt History
Attempt Time Score
KEPT Attempt 3 10 minutes 100.32 out of 100.32

LATEST Attempt 3 10 minutes 100.32 out of 100.32

Attempt 2 23 minutes 97.28 out of 100.32

Attempt 1 24 minutes 88.16 out of 100.32

 Answers will be shown after your last attempt

Score for this attempt: 100.32 out of 100.32


Submitted Jun 28 at 11:56am
This attempt took 10 minutes.

Question 1 3.04 / 3.04 pts

What is the result of the following code?

A <- matrix(NA, 3, 3)
for (j in 1:3)
{
A[,j] <- 1:3
}
A

1 1 1
2 2 2
3 3 3

3 2 1
3 2 1
3 2 1

1 2 3
1 2 3
1 2 3

3 3 3
2 2 2
1 1 1

Question 2 3.04 / 3.04 pts

Which of the following is correct regarding p & q in the context of using binomial trees
to valuate options?

p is usually greater than 1 and q is usually lower than 1

p is the final put price and q is the final call price

p & q are risk neutral probabilities for the price movements up and down, respectively

p & q are always between 0 and 1 and represent the factor that the price moves either up
or down

Question 3 3.04 / 3.04 pts

What is the result of the following code?


M <- matrix(0,5,5)
for (i in 1:5)
{
for (j in 1:5)
{
if (i == j) M[i,j]<-1
if (i < j) M[i,j]<-2
if (i > j) M[i,j]<-3
}
}

A matrix with 1's in the last column, while the rest of has 2's in the top-half & 3's in the
bottom-half

A matrix with 1's in the diagonal, 2's in the top-half & 3's in the bottom-half

A matrix with 1's in the diagonal, 3's in the top-half & 2's in the bottom-half

A matrix with 1's in the first column, while the rest of has 2's in the top-half & 3's in the
bottom-half

Question 4 3.04 / 3.04 pts

In the following code, what do the variables "epic" and "rap" do?

-----------------------------------------------------------------------------------------------------------

binomial<-function(n=10,epic="c",rap="e",s0=42,k=40,t=0.5,vol=0.20,r=0.10)
{

dt<-t/n
u<-exp(vol*sqrt(dt))
d<-1/u
p<-(exp(r*dt)-d)/(u-d)
q<-1-p

st<-matrix(0,n+1,n+1)
for(i in 1:(n+1))
{
for (j in i:(n+1))
{
st[i,j]<-s0*u^(j-i)*d^(i-1)
}
}

op<-matrix(0,n+1,n+1)
for(i in 1:(n+1))
{
if(epic == "c") op[i,n+1]<-max(st[i,n+1] - k, 0)
if(epic == "p") op[i,n+1]<-max(k - st[i,n+1], 0)
}
for(j in n:1)
{
for (i in 1:j)
{
op[i,j]<-(op[i,j+1]*p+op[i+1,j+1]*q)*exp(-r*dt)
if(rap == "a" && epic == "c") op[i,j]<-max(op[i,j],st[i,j]-k)
if(rap == "a" && epic == "p") op[i,j]<-max(op[i,j],k - st[i,j])
}
}
return(op[1,1])
}

They define the style and type of option, respectively

They define the type and style of option, respectively

They define the option premiums and underlier prices trees, respectively

They define the underlier prices and option premiums trees, respectively

Question 5 3.04 / 3.04 pts

What is the result of the following code?

A <- matrix(0,3,3)
counter <- 0
for (j in 1:3)
{
for (i in 1:3)
{
counter<-counter+1
A[i,j]<-counter
}
}

1 2 3
4 5 6
7 8 9

1 4 7
2 5 8
3 6 9

3 2 1
6 5 4
9 8 7

7 4 1
8 5 2
9 6 3

Question 6 3.04 / 3.04 pts

What is the result of the following code?

m <- matrix(1,5,4)

A matrix m, full of 1's, with 4 rows and 5 columns

A matrix m, full of 1's, with 5 rows and 4 columns

A matrix m, full of 5's, with 1 row and 4 columns

A matrix m, full of 4's, with 1 row and 5 columns

Question 7 3.04 / 3.04 pts


The following function works for only one type and style of option... which one?

binomial <- function(n=10, s0=42, k=40, t=0.5, vol=0.20, r=0.10)


{

dt <- t/n
u <- exp(vol*sqrt(dt))
d <- 1/u
p <- (exp(r*dt) - d)/(u - d)
q <- 1 - p

st <- matrix(0, n+1, n+1)


for(i in 1:(n+1))
{
for (j in i:(n+1))
{
st[i,j] <- s0*u^(j-i)*d^(i-1)
}
}

op <- matrix(0, n+1, n+1)


for(i in 1:(n+1))
{
op[i,n+1] <- max(k - st[i, n+1], 0)
}
for(j in n:1)
{
for (i in 1:j)
{
op[i,j] <- (op[i, j+1]*p + op[i+1, j+1]*q)*exp(-r*dt)
}
}
return(op[1, 1])
}

European Call

American Put

American Call

European Put
Question 8 3.04 / 3.04 pts

In the context of Option Pricing with Binomial Trees, if we increase the number of steps
(n)

the simulated underlier prices become less extreme.

we increase the time-period modelled.

we increase the number of simulated price paths.

the resulting option price becomes less stable.

Question 9 3.04 / 3.04 pts

The following function works for only one type and style of option... which one?

binomial <- function(n=10, s0=42, k=40, t=0.5, vol=0.20, r=0.10)


{

dt <- t/n
u <- exp(vol*sqrt(dt))
d <- 1/u
p <- (exp(r*dt) - d)/(u - d)
q <- 1 - p

st <- matrix(0, n+1, n+1)


for(i in 1:(n+1))
{
for (j in i:(n+1))
{
st[i,j] <- s0*u^(j-i)*d^(i-1)
}
}

op <- matrix(0, n+1, n+1)


for(i in 1:(n+1))
{
op[i,n+1] <- max(st[i, n+1] - k, 0)
}
for(j in n:1)
{
for (i in 1:j)
{
op[i,j] <- (op[i, j+1]*p + op[i+1, j+1]*q)*exp(-r*dt)
}
}
return(op[1, 1])
}

European Call

European Put

American Call

American Put

Question 10 3.04 / 3.04 pts

What is the result of the following code?

A <- matrix(NA, 3, 3)
for (i in 1:3)
{
A[i,] <- 1:3
}

1 2 3
1 2 3
1 2 3

3 2 1
3 2 1
3 2 1

3 3 3
2 2 2
1 1 1
1 1 1
2 2 2
3 3 3

Question 11 3.04 / 3.04 pts

In the context of option pricing using binomial trees, which of the following code
portions calculates the payoff of a put option in the last column of an option prices tree?
Consider that s is the tree of simulated spot prices, op is the tree of option premiums, k
is the strike price and n is the number of steps.

op<-matrix(0,n+1,n+1)
for (i in 1:(n+1))
{
op[i,n+1]<-max(s[i,n+1]-k,0)
}

op<-matrix(0,n+1,n+1)
for (i in 1:(n+1))
{
op[i,n+1]<-max(k-s[i,n+1],0)
}

op<-matrix(0,n+1,n+1)
for (i in 1:(n+1))
{
op[n+1,i]<-max(k-s[n+1,i],0)
}

op<-matrix(0,n+1,n+1)
for (i in 1:(n+1))
{

for (j in 1:i)

op[i,j]<-max(k-s[i,j],0)

}
}

Question 12 3.04 / 3.04 pts


If we use the following code to find the implied volatility and assume that the
blackscholes function is correctly defined, which variable determines the precision
within which the true searched value will be found?

--------------------------------------------------------------------------------------------------------------------

impvol<-function(type="c", mkt_price=4.759422, k=40, t=0.5, r=0.10, s=42) {


tolerance <- 0.00001
maxiter <- 10000
ub <- 1
lb <- 0
counter <- 0
guess_price <- 0

while (abs(mkt_price - guess_price)>tolerance & counter<maxiter){


guess_vol <- (lb+ub)/2
guess_price <- blackscholes(type = type, s = s, k = k, t = t ,v = guess_vol , r = r)
if (guess_price < mkt_price) lb <- guess_vol
if (guess_price > mkt_price) ub <- guess_vol
counter <- counter + 1
}

if (abs(mkt_price - guess_price)<=tolerance) {
return(guess_vol)
} else return("Implied volatility not found, iterations limit reached")
}

guess_vol

counter

tolerance

maxiter

Question 13 3.04 / 3.04 pts

Which of the following is correct regarding the trees used in the context of the binomial
trees method to valuate options?
The first tree simulates underlier prices and and the second tree calculates option prices

The first tree is built from right-to-left and the second tree is built from left-to-right

As long as each tree is built properly, it doesn't matter which is built first

The first tree simulates option prices and the second tree calculates underlier prices

Question 14 3.04 / 3.04 pts

In the context of the Binomial Trees method for options valuation, what does the
following equation do?

op[i,j] <- max((op[i,j+1]*p + op[i+1,j+1]*q)*exp(-r*dt), st[i,j] - k)

where:

st: underlier prices tree

op: option prices tree

p & q: probability of the movements up & down respectively

dt: the time-length of each step

r: the risk-free rate

i & j: row and column numbers respectively

Evaluates the payoffs at the last column of the option prices tree

Discounts the average payoff of the next two nodes to the current node

Chooses the greater between the expected future payoff or the payoff of exercising the
call option immediately

Chooses the greater between the expected future payoff or the payoff of exercising the
put option immediately
Question 15 3.04 / 3.04 pts

In the context of option pricing using binomial trees, which of the following code
portions calculates the payoff of a call option in the last column of an option prices
tree? Consider that s is the tree of simulated spot prices, op is the tree of option
premiums, k is the strike price and n is the number of steps.

op<-matrix(0,n+1,n+1)
for (i in 1:(n+1))
{
op[i,n+1]<-max(k-s[i,n+1],0)
}

op<-matrix(0,n+1,n+1)
for (i in 1:(n+1))
{

for (j in 1:i)

op[i,j]<-max(s[i,j]-k,0)

}
}

op<-matrix(0,n+1,n+1)
for (i in 1:(n+1))
{
op[i,n+1]<-max(s[i,n+1]-k,0)
}

op<-matrix(0,n+1,n+1)
for (i in 1:(n+1))
{
op[n+1,i]<-max(s[n+1,i]-k,0)
}

Question 16 3.04 / 3.04 pts

Which of the following commands stores the length of a one-dimensional array (B) in
variable (n)?

B<-1:5

n<-nrow(B)
n<-ncol(B)

n<-length(B)

ncol(B)<-n

Question 17 3.04 / 3.04 pts

The volatility for which the Black-Scholes price equals the market price:

Annualized volatility

Vega

Daily volatility

Implied volatility

Question 18 3.04 / 3.04 pts

Which of the following is correct regarding n (number of steps) in the context of


European options pricing using binomial trees?

As n increases, the Binomial Trees model approximates the Black-Scholes model

As n decreases, the Binomial Trees model approximates the Black-Scholes model

As n increases, the time to maturity increases

As n decreases, the size of each "time-slice" (delta-t) decreases too

Question 19 3.04 / 3.04 pts

In the context of the Binomial Trees method for options valuation, what does the
following equation do?
op[i,j] <- max((op[i,j+1]*p + op[i+1,j+1]*q)*exp(-r*dt), k - st[i,j])

where:

st: underlier prices tree

op: option prices tree

p & q: probability of the movements up & down respectively

dt: the time-length of each step

r: the risk-free rate

i & j: row and column numbers respectively

Discounts the average payoff of the next two nodes to the current node

Chooses the greater between the expected future payoff or the payoff of exercising the
put option immediately

Chooses the greater between the expected future payoff or the payoff of exercising the
call option immediately

Evaluates the payoffs at the last column of the option prices tree

Question 20 3.04 / 3.04 pts

Which of the following is correct regarding the types (Call vs Put) and styles (European
vs American) of options that can be valuated using binomial trees?

The option type and style don't affect the underlier prices tree, only the calculation of the
option prices tree changes

Both trees change depending on the option type and style

Only American options can be valuated using Binomial Trees

The number of steps of each tree can be different


Question 21 3.04 / 3.04 pts

If we use the following code to find the implied volatility and assume that the
blackscholes function is correctly defined, which variable serves as a limit of trials to
avoid an infinite loop in case no solution is found?

--------------------------------------------------------------------------------------------------------------------

impvol<-function(type="c", mkt_price=4.759422, k=40, t=0.5, r=0.10, s=42) {


tolerance <- 0.00001
maxiter <- 10000
ub <- 1
lb <- 0
counter <- 0
guess_price <- 0

while (abs(mkt_price - guess_price)>tolerance & counter<maxiter){


guess_vol <- (lb+ub)/2
guess_price <- blackscholes(type = type, s = s, k = k, t = t ,v = guess_vol , r = r)
if (guess_price < mkt_price) lb <- guess_vol
if (guess_price > mkt_price) ub <- guess_vol
counter <- counter + 1
}

if (abs(mkt_price - guess_price)<=tolerance) {
return(guess_vol)
} else return("Implied volatility not found, iterations limit reached")
}

guess_vol

maxiter

lb

ub

Question 22 3.04 / 3.04 pts

What is the result of the following code?


A <- matrix(0,3,3)
counter <- 0
for (j in 1:3)
{
for (i in 1:j)
{
counter<-counter+1
A[i,j]<-counter
}
}

1 2 3
0 4 5
0 0 6

4 2 1
5 3 0
6 0 0

3 2 1
5 4 0
6 0 0

1 2 4
0 3 5
0 0 6

Question 23 3.04 / 3.04 pts

What is the result of the following code?

m <- matrix("a",5,4)

ncol(m)

5
NULL

20

Question 24 3.04 / 3.04 pts

In the context of the Option Pricing Methods we reviewed, what is the following code
portion doing?

----------------------------------------------

st<-matrix(0,n+1,n+1)
for(i in 1:(n+1))
{
for (j in i:(n+1))
{
st[i,j]<-s0*u^(j-i)*d^(i-1)
}
}

Prices an option via Monte Carlo Simulation

Calculates the underlier prices tree

Prices an option using Black-Scholes formula

Calculates the option premiums tree

Question 25 3.04 / 3.04 pts

What is the result of the following code?

A <- matrix(0,3,3)
counter <- 0
for (i in 1:3)
{
for (j in 1:3)
{
counter<-counter+1
A[i,j]<-counter
}
}

1 2 3
4 5 6
7 8 9

1 4 7
2 5 8
3 6 9

7 4 1
8 5 2
9 6 3

3 2 1
6 5 4
9 8 7

Question 26 3.04 / 3.04 pts

In the context of the Binomial Trees method for options valuation, what does the
following equation do?

op[i,j] <- (op[i,j+1]*p + op[i+1,j+1]*q)*exp(-r*dt)

where:

op: option prices tree

p & q: probability of the movements up & down respectively

dt: the time-length of each step

r: the risk-free rate

Verifies if it is better to hold the option or to exercise it, at a given node


Evaluates the payoffs at the last column of the option prices tree

Discounts the average payoff of the next up and down nodes to the current node

Simulates the underlier prices for the rest of the tree

Question 27 3.04 / 3.04 pts

What method did we use to find the Implied Volatlity in an Option Price, according to
the Black-Scholes formula?

Binary Search

Implied YTM

Binomial Trees

Monte Carlo Simulation

Question 28 3.04 / 3.04 pts

After building the option premiums tree, we find out the fair value of the option. Which
variable contains such option price?

Assume that we are using a coding language where matrices begin at (1,1)

s is the tree of simulated underlier prices

o is the tree of option premiums

s[0,0]

s[1,1]

o[n+1,n+1]

o[1,1]
Question 29 3.04 / 3.04 pts

Which of the following patterns wouldn't work when calculating the underlier's spot
prices tree?

Calculate the payoffs at the last column and then discount their expected values to the
present

Assign s0 to the top-left position, calculate the first row by multiplying the previous price
by u, then the rest of the diagonals by multiplying each previous element by d

Assign s0 to the top-left position, calculate the main diagonal by multiplying the previous
element by d, then the rest of the row elements by multiplying each previous element by u

Multiply s0 by u elevated to the power of "columns - rows" and by d elevated to the power
of "rows" if the matrix positions start with (0,0) or "rows - 1" if the matrix positions start with
(1,1)

Question 30 3.04 / 3.04 pts

American options are always worth _____ than European options.

the same or more

more

the same or less

less

Question 31 3.04 / 3.04 pts


Which of the following is correct regarding u & d in the context of using binomial trees
to valuate options?

u & d are risk neutral probabilities for the price movements up and down, respectively

u should be greater than 1 and d should be lower than 1 since they are the factors that the
price moves either up or down

u is the final underlier price and d is the final option price

u & d are always between 0 and 1

Question 32 3.04 / 3.04 pts

If we use the following code to find the implied volatility and assume that
the blackscholes function is correctly defined, what code lines should replace the words
"metal" and "rap"?

--------------------------------------------------------------------------------------------------------------------

impvol<-function(type="c", mkt_price=4.759422, k=40, t=0.5, r=0.10, s=42) {


tolerance <- 0.00001
maxiter <- 10000
ub <- 1
lb <- 0
counter <- 0
guess_price <- 0

while (abs(mkt_price - guess_price)>tolerance & counter<maxiter){


guess_vol <- (lb+ub)/2
guess_price <- blackscholes(type = type, s = s, k = k, t = t ,v = guess_vol , r = r)
if (guess_price > mkt_price) metal
if (guess_price < mkt_price) rap
counter <- counter + 1
}

if (abs(mkt_price - guess_price)<=tolerance) {
return(guess_vol)
} else return("Implied volatility not found, iterations limit reached")
}
metal: lb <- guess_price & rap: ub <- guess_price

metal: ub <- guess_price & rap: lb <- guess_price

metal: lb <- guess_vol & rap: ub <- guess_vol

metal: ub <- guess_vol & rap: lb <- guess_vol

Question 33 3.04 / 3.04 pts

What is the result of the following code?

m <- matrix("a",5,4)

nrow(m)

NULL

20

Quiz Score: 100.32 out of 100.32

You might also like