Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is a .ipynb file, please fill out the rest of the codes based on the insurance instruction (not a big project, just basic stuff):

This is a .ipynb file, please fill out the rest of the codes based on the insurance instruction (not a big project, just basic stuff):

image text in transcribedHere are other parts of the previous reference:

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Code for copy:

import numpy as np import matplotlib.pyplot as plt import seaborn as sns from scipy.stats import norm sns.set() %matplotlib inline

def StockPriceSim(S0,K,r,sigma, N_sim, T, dt): N_T = int(T/dt) t = np.linspace(0,T,N_T+1) # Generate paths for underlying asset prices innovation = np.random.randn(N_sim, N_T) BM = np.zeros([N_sim, N_T+1]) BM[:,0] = 0 BM[:,1:] = innovation BM = np.cumsum(BM,axis=1) BM *= np.sqrt(dt)

S = np.ones([N_sim, N_T+1]) S[:,0] = 0 S = S.cumsum(axis=1) S *= (r - 0.5*(sigma)**2)*dt S += sigma * BM S = S0*np.exp(S) return S

S0=100 K=100 r=0.04 sigma=0.3 N_sim=10 T=1 dt=0.1 stock = StockPriceSim(S0,K,r,sigma,N_sim,T,dt)

N_T = int(T/dt) t = np.linspace(0,T,N_T+1)

for i in range(N_sim): plt.plot(t, stock[i,:]) plt.xlabel('time') plt.ylabel('Stock Price') plt.title('Simualted Stock Price')

def option_price_MC(S0,K,sigma,r,T,N_sim=1000): dt = T stock = StockPriceSim(S0,K,r,sigma, N_sim, T, dt) stock = stock[:, -1] # only need terminal prices for European Option option_price = np.maximum(stock - K, 0)*np.exp(-r*T) return np.mean(option_price)

def option_price_BS(S0,K,sigma,r,T): d1 = (np.log(S0/K) + (r + 0.5*(sigma**2))*T)/(sigma*np.sqrt(T)) d2 = d1 - sigma * np.sqrt(T) return S0*norm.cdf(d1) - K*np.exp(-r*T)*norm.cdf(d2)

BS_price=option_price_BS(S0,K,sigma,r,T)

log_n = [2,2.5,3,3.5,4,4.5,5,5.5,6] n_sim = [int(10**k) for k in log_n]

option_price_sim = [option_price_MC(S0,K,sigma,r,T,N_sim) for N_sim in n_sim]

plt.plot(log_n, option_price_sim,label='MC') plt.scatter(log_n, option_price_sim, color='green') plt.hlines(BS_price, 2,6, linestyles='dashed', colors='red',label='BS') plt.xlabel('log(simulation #)') plt.ylabel('Option Price') plt.legend() plt.title('Option Price: Monte Carlo vs. Black Scholes')

np.mean(np.maximum(stock[:,-1]-K,0)*np.exp(-r*T))

Importance Sampling and Stock Insurance Suppose I sell you an insurance contract on the stock price for firm A. Firm A's stock price follow a log normal distribution: S(T) = So exp(oWT) Suppose current stock price is 100. My contract will pay you 100,000 if the stock price at time T is below 10, and 0 otherwise. How much do you think the contract is worth? Estimate the value of the contract using both basic Monte Carlo as well as Importance sampling. Here . So = 100 T = 1 o= 0.3 Hint: Estimate the probability that S(T)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

International Finance Transactions Policy And Regulation

Authors: Hal Scott, Anna Gelpern

20th Edition

1609303164, 978-1609303167

More Books

Students also viewed these Finance questions

Question

What is meant by the term student syndrome?

Answered: 1 week ago

Question

What factors contribute most to the comprehension of read text?

Answered: 1 week ago

Question

mple 10. Determine d dx S 0 t dt.

Answered: 1 week ago