CS代写 FM01 course at King’s), probability theory is defined in terms of measure t

Monte Carlo pricing
So far we have focused on pricing European call options in the Black-Scholes model. This is a good test- case for numerical methods as there is an analytic formula we can compare against, but there is no point in using a numerical method if there is an analytic formula available.
The Monte Carlo method is a powerful technique that can be used to price a very broad range of derivatives. It is easy to implement, but the reason why it works is rather deep.
We will show that the method works by using the Feynman-Kac theorem. This is a powerful theorem that shows you can solve a large family of partial differential equations by computing expectations in a particular probability model. You can calculate expectations by performing a numerical simulation of the model, and this is why we end up with a numerical method based on simulating a probability model.

Copyright By PowCoder代写 加微信 powcoder

Interestingly the fact that we can compute prices by simulating a probability model is not a consequence of the fact that we have a probability model for the stock prices, it is because we know that prices can be solved by solving a partial differential equation.
That is why we will have to consider two different probability models this week. We will label one of them P. This is the probability model that represents our beliefs about stock prices and is the model we have been using so far in the course.
We will label the new model that emerges from the Feynman Kac theorem Q. This model is an abstract model that we consider purely so we can solve PDEs using expectations.
Because we are going to start pricing derivatives where we have no analytic formula for the price, it will be much less easy to check if our code is correct. For this reason, one focus of this topic will be on testing.
When you come to do your coursework, you will want to make sure your answer is correct. So make sure you understand how to test code even when you don’t know the answer!
• We will start by studying the Feynman-Kac theorem and sketching its proof
• We will then use this to develop the theory of risk-neutral pricing
• Next we show how to price path-dependent derivatives by the Monte Carlo method
• We finish by seeing how to test our results.
• (1918-1988), (1914-1918)
• is most celebrated for his work on Quantum Electrodynamics for which he won
the for Physics.
• is famous for one of the best titles in the history of mathematics: “Can one hear the shape
of a drum?”

1 The Feynman­Kac Theorem
We will give the intuition behind the Feynman-Kac theorem. A fully rigorous proof is beyond the scope of the course.
A stochastic process which on average stays still is called a martingale. Let T be either [0, ∞), [0, T ] or [0, 1, 2, . . . T ] depending if we are interested in discrete-time or continuous-time martingales.
Definition: A process Xt for t ∈ T is called a martingale if
• E(|Xt|) < ∞ for all t ∈ [0, T ] (i.e. the expectation is defined) • Et(Xt+δt)=Xt forallt,(t+δt)∈T Here Et means the expected value given all the information up to time t. Example: The Wiener process Wt is a martingale as it is as likely to move up or down and so stays still on average Example: The solution of the SDE dXt =μ(Xt,t)dt+σ(Xt,t)dWt. will be a martingale only if μ = 0 at all points that Xt might visit. It is an only if condition because you also need to check that the expectation E(Xt) actually exists. Example:LetYT bearandomvariablewhosevalueisknownatthefinaltimeT.SupposethatEt(|YT|)< ∞ for t ∈ [0,T]. Then Ut = Et(YT ) is a martingale. This follows from the tower law of conditional expectation Et(Ut+δt) = Et(Et+δt(YT )) = Et(YT ) = Ut 2 1.1 The Feynman­Kac Theorem If Xt satisfies an SDE with initial condition Xt = x we can write u(x, t) := Et (f (XT )) as this expectation will only depend upon x and t. SolongaswealwayshaveEt(|f(XT)|) < ∞,ourlastexampleofamartingaleshowsthatu(Xt,t)must beamartingale.JusttakeYT =f(XT). Let’s assume u is smooth enough to apply Ito’s Lemma. We get du(Xt,t)= ∂udt+∂uμ(Xt,t)dt+1∂2uσ2(Xt,t)dt+∂uσ(Xt,t)dWt. ∂t∂x 2∂x2 ∂x We know u(Xt, t) is a martingale, so there can’t be any drift term. ∂u +μ(x,t)∂u + 1σ2(x,t)∂2u =0 ∂t ∂x2 ∂x2 dXs =μ(Xs,s)ds+σ(Xs,s)dWs This argument gives the central idea behind the Feynman-Kac theorem. The outstanding issue is to prove that u is smooth. Theorem: (Feynman-Kac) Suppose that Xt satisfies the SDE dXt =μ(Xt,t)dt+σ(Xt,t)dWt. and that u(x,t) := Et(f(XT ) | Xt = x) < ∞, then u solves the PDE ∂u +μ(x,t)∂u + 1σ2(x,t)∂2u =0 ∂t ∂x2 ∂x2 with final condition u(x, T ) = f (x). One can also prove the converse (with appropriate growth conditions on u to ensure uniqueness of solutions). The full version of the Feynman-Kac theorem allows for slightly more complicated PDEs. For the sake of this course we would like to add in one extra term so that we can apply the theorem to the Black-Scholes PDE. Theorem: (Feynman-Kac) Suppose that Xt satisfies the SDE dXt =μ(Xt,t)dt+σ(Xt,t)dWt. and that v(x,t) := Et(e−c(T−t)f(XT ) | Xt = x) < ∞, for some constant c, then v solves the PDE ∂v+μ(x,t)∂v+1σ2(x,t)∂2v−cV =0 ∂t ∂x2 ∂x2 with final condition v(x, T ) = f (x). One can also prove the converse (with appropriate growth conditions on u to ensure uniqueness of solutions). Moral: We can solve partial differential equations by computing expectations, or we can compute expec- tations by solving partial differential equations depending upon which we find easier. 2 Exercises 2.1 Exercise IfX0 =0and then is it true that the process Xi (for i = 0,1,2,3,...T) is a martingale? Answer True or False. 2.2 Exercise Suppose that a gambler has wealth Xi at time i. They play a game of Roulette. Assume that the ball will land on a number between 1 and 32 and that all values are equally probable. If the gambler bets an amount x on the number n coming up, they receive 31x if n does come up and 0 otherwise. The gambler may place as many bets as they like at each time i. Is it True or False that X_i is a martingale? 2.3 Exercise Suppose that Xt satisfies the equation Xt = 12Xtσ2dt+σXtdWt with X0 = 1, σ a constant and Wt as in the previous question. Is it True or False that X_i is a martingale? 2.4 Exercise Suppose that Xt is as in the previous question. Is it True or False that log(Xt) is a martingale? 2.5 Exercise In the notes there are two versions stated of the Feynman-Kac theorem stated. One includes a term involving the constant c and one does not involve this constant. Prove the former from the latter. 3 Risk­Neutral Pricing Let us recap the key results we have seen. Firstly Black and Scholes used a replication argument to prove the following. Theorem: (Replication) Suppose that the stock price process St satisfies 4 Xi−1 ifεi<0 Xi + 1 otherwise dSt =St(μdt+σdWtP) then the price V (S, t) of a derivative with payoff function f (ST ) may be computed by solving the Black- Scholes PDE ∂V +1σ2S2∂2V +rS∂V −rV =0 ∂t 2 ∂S2 ∂S with final condition V (ST ,T) = f(ST ). Secondly, the Feynman-Kac theorem allows us to solve PDEs by simulating stochastic processes. Theorem: (Feynman-Kac) Suppose that v solves the PDE ∂v + μ(x,t)∂v + 1σ2(x,t)∂2v − cv = 0 ∂t ∂x2 ∂x2 with final condition v(x, T ) = f (x) then one may compute v by simulating dXt =μ(Xt,t)dt+σ(Xt,t)dWtQ. in which case we will have v(Xt,t) := EtQ(e−c(T−t)f(XT ) | Xt = x). I have been careful to label the Wiener processes as WtP when stating Black and Scholes result and WtQ when stating the Feynman-Kac theorem. This is because I want to emphasize they are two different Wiener processes defined on different probability spaces. Similarly I’ve written EtQ. The process WtP is used to model our beliefs about the future evolution of a stock price. The process WtQ is completely artificial and abstract: we use it to help us solve a PDE. 3.1 Putting it all together If we combine Black and Scholes result with the Feynman-Kac theorem we have the following result. Theorem: Suppose that the stock price process St satisfies dSt =St(μdt+σdWtP). The price V (S, t) of a derivative with payoff function f (ST ) may be computed by simulating dS ̃t =S ̃t(rdt+σdWtQ) with initial condition S ̃t = S, in which case we will have V(S,t):=Et(e−r(T−t)f(S ̃T)|S ̃t =S). In particular V (S0, 0) = Et(e−rT f(S ̃T )). When one studies probability theory formally (as is done in the FM01 course at King’s), probability theory is defined in terms of measure theory. As a result, it is standard to talk about the probability space associated with the process WtP as being equipped with “the P-measure” and the probability space associated with the process WtQ as being equipped with “the Q-measure”. You should think of the process as an entirely abstract process which you can use to compute the price of a derivative. dS ̃t =S ̃t(rdt+σdWtQ) The Q-measure is often called the pricing measure to emphasize this point. It has no other purpose than for computing prices. Another name for the pricing measure is the risk-neutral measure. In a reasonable model for stocks, you would expect that μ > r. This is because investors will only want to buy stocks if they think that they can get a better return from stocks than risk-free bonds. This is because most people are risk-averse.
However, in a hypothetical world where nobody cared about risk, you would have μ = r. So the abstract process
dS ̃t =S ̃t(rdt+σdWtQ) looks like the process for a stock price in this risk-neutral world.
Warning: In my experience, thinking about alternative worlds is not a good idea and just leads to confusion and talking nonsense. I’ve explained where the terms risk-neutral measure and risk-neutral pricing comes from, but I recommend that you don’t think about alternative worlds.
Just view the process
dS ̃t =S ̃t(rdt+σdWtQ)
as a purely mathematical device that you can use to solve the Black-Scholes PDE.
3.2 The Black­Scholes Formula
As an application of this theory we can finally see where the Black-Scholes formula comes from. So far all we have done is check that it solves the PDE, but how on earth did Black and Scholes find this solution? The honest answer is that they worked very hard on the theory of PDEs, but if they had known about simulating in the pricing measure they would have found it easy!
We now know that the price of call option at time 0 in the Black-Scholes model is given by V =E(e−rT max{S ̃T −K,0})
whereS ̃T isthesolutionoftheSDE for a Wiener process WtQ.
dS ̃t =S ̃t(rdt+σdWtQ) We know how to solve this SDE. The solution is

S ̃t =S0exp((r−12σ2)t+σWtQ). YoucaneasilyworkoutthedistributionofST now-itwillbelognormallydistributed.Thismakesiteasy
(Exercise: how do we know this?) to compute
V =E(e−rT maxS ̃T −K,0),
at least in principle. You just need to write down the pdf of the normal distribution and then compute the
A trick that makes the computations a bit simpler is to work with Z ̃T := log(S ̃t) as this will be normally distributed.
So the price of a call option is given by
V =E(e−rT max{eZ ̃T −K,0})
where Z ̃T is normally distributed with mean A := log(S0)+(r− 12 σ2)T and standard deviation B := σ√T .
(Exercise: how do we know this?)
It follows that V is given by the following integral ∫∞
√ e− 2B2 dz
e−rT(ez −K) Thelaststepusesthefactthatez −K≥0ifandonlyifz≥log(K).
1 (z−A)2 e−rT max{ez −K,0} √ e− 2B2 dz
3.3 Evaluating the integral
You can compute this integral in terms of N(x) yourself using the techniques we have seen for evaluating integrals involving the exponential of a quadratic (we did this way back in Topic 2!).
For fun, let’s get sympy to do all the hard work.
It is important to tell sympy that all our terms are real and which are positive, otherwise the integral becomes impossible for it to do.
from sympy import *
r, z = symbols(‘r z’, real=True)
K, T, S, sigma = symbols(‘K T S sigma’, real=True, positive=True)
B = sigma * sqrt(T)
A = log(S) + (r-sigma**2/2)*T
integrand = exp(-r*T)*(exp(z)-K)*(1/(B*sqrt(2*pi)))*exp(-(z-A)**2/(2*B**2)) integrand

[1]: ((2) )2
−T r− 2 +z−log(S)
2(−K +ez)e−Tre− 2Tσ2 2√π√T σ
V = integrate( integrand, (z,log(K),oo) ).simplify()
(√ ( 2 (S2 ))) (√ ( 2 (S2 ))) −Kerf 2 2Tr−Tσ +log K2 −K+SeTrerf 2 2Tr+Tσ +log K2
+SeTr e−Tr
It is standard for symbolic integration routines to use the “error function” to express Gaussian integrals, but convention dictates that you should use the cdf of the standard normal instead when writing down the Black-Scholes formula.
By definition:
so this is just a trivial substitution. We get sympy to do all the work with the replace function.
−KN √ K2  + SN
Theorem: (Black-Scholes formula) The price of a call option at time 0 in the Black-Scholes model is given by
4 Exercises
4.1 Exercise
You should use the Q-measure for only one purpose. What is that purpose?
( 2 )  S
( 2 )  S
2Tr−Tσ2 +log
erf(x) = 2N( 2x) − 1
N = Function(‘N’)
w = Wild(‘w’)
V = V.replace(erf(w),2*N(sqrt(2)*w)-1)
V = V.simplify()
2Tr+Tσ2 +log
√ K2 eTre−Tr
V = SN(d1) − e−rT KN(d2)
d1:=σ√T(log(S/K)+(r+2σ) T) 1 12√
1. Computing expected utilities 2. Calculating prices
3. Computing Value at Risk
d2:=σ√T(log(S/K)+(r−2σ) T).

4. Computing Expected Shortfall
5. Testing whether delta-hedging works in practice.
4.2 Exercise
In the lecture notes it is claimed that the solution of the SDE
How do we know this?
4.3 Exercise
dS ̃t =S ̃t(rdt+σdWtQ)
S ̃t =S0exp((r−12σ2)t+σWtQ).
In the lecture notes it is claimed that if
dS ̃t =S ̃t(rdt+σdWtQ)
thenZ ̃T :=log(S ̃t)isnormallydistributedwithmeanA:=log(S0)+(r−1σ2)Tandstandarddeviation
B:=σ T.Howdoweknowthis? 4.4 Exercise
A digital call option with strike K and maturity T pays out 1 if ST > K and 0 otherwise. Compute an analytic formula for the price of a digital call option in the Black-Scholes model by following the same procedure we used to compute the Black-Scholes formula.
Use this to write a function black_scholes_digital_call_price. 4.5 Exercise
Last week we made a dubious argument to justify an estimate of the price of a call option on the top bound- ary.
We noted that if we wish to price a call option in the Black-Scholes model and St is much greater than K, thentheprobabilitythatST ≤Kwillbenegligible.Thiswastrue,butitdidn’treallytellusanythingabout the price of the option. This is because we were talking about the P-measure probability. What we really neededtoknowwasthattheQ-measureprobabilitythatS ̃T ≤Kisnegligible,butthiswillalsobetrue.
We can then argue that
Justify the final line of this computation.
V =EtQ(e−r(T−t)max{S ̃T −K,0}) ≈EQ(e−r(T−t)(S ̃T −K))
= S ̃ t − e − r ( T − t ) K .

5 Monte Carlo Pricing
5.1 Path­dependent derivatives
So far in this course we have considered only derivatives whose payoff at maturity T is given by a function of the final price ST .
Path-dependent derivatives have a payoff which depends upon the whole stock price path St ∈ [0, T ]. Here are some examples:
An Asian call option with maturity T and strike K whose payoff is given by max{S − K, 0} where S is the average value of S.
An up-and-out knock-out call option with maturity T and strike K and barrier B whose payoff is given by {
A one-touch option with strike K > S0 and maturity T pays off
max{ST −K,0} St Bforallt∈[0,T] 0 otherwise.
An up-and-in knock-in call option with maturity T and strike K and barrier B whose payoff is given
0 St CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com