WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

Wall Street Quant · Financial Models · question 107 of 155

Write a Monte Carlo simulation in Python or R to price a European call option.?

📕 Buy this interview preparation book: 155 Wall Street Quant questions & answers — PDF + EPUB for $5

Below is some Python code to perform Monte Carlo simulation to price a European call option. In this example, I’ll use the Black-Scholes model for stock price dynamics.

Assumptions for the Black-Scholes model are:

1. The stock price follows a Geometric Brownian Motion (GBM).

2. The risk-free rate is constant.

3. The stock’s volatility (sigma) is constant.

The equation for the stock price at time ‘t‘ following GBM is:


$$S_t = S_0 e^{(r - \frac{1}{2} \sigma^2) t + \sigma \sqrt{t} Z}$$

Where:

- St = stock price at time ‘t‘

- S0 = initial stock price

- r = risk-free interest rate

- σ = stock’s volatility

- t = time period

- Z = standard Normal random variable

Now, let’s simulate to get the call option price. The call option payoff is:


Call Payoff = max(St − K, 0)

Where:

- K = strike price of the option

We will then calculate the expected payoff and discount it back to the present value, as the option price:


European Call Option Price = e − rT * E[Call Payoff]

Here’s the Python code:

import numpy as np
import math

# Parameters
S0 = 100          # initial stock price
K = 110           # strike price
T = 1             # time to maturity (1 year)
r = 0.05          # risk-free interest rate
sigma = 0.20      # stock's volatility
num_simulations = 1000000  # number of Monte Carlo simulations

# Set a random seed for reproducibility
np.random.seed(1234)

# Generate stock prices at time T using GBM model
Z = np.random.normal(0, 1, num_simulations)
St = S0 * np.exp((r - 0.5 * sigma**2) * T + sigma * math.sqrt(T) * Z)

# Calculate the call option's payoff at time T
call_payoff = np.maximum(St - K, 0)

# Discount the expected payoff to obtain the option price
call_price = np.average(call_payoff) * np.exp(-r * T)

print("European Call Option Price:", call_price)

This code prices a European call option using Monte Carlo simulation based on the given parameters. You can change these parameters to get the option price under different conditions.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic Wall Street Quant interview — then scores it.
📞 Practice Wall Street Quant — free 15 min
📕 Buy this interview preparation book: 155 Wall Street Quant questions & answers — PDF + EPUB for $5

All 155 Wall Street Quant questions · All topics