23 February, 2015

Why is Brownian Motion Almost Surely Continuous?

A user from the Quant StackExchange recently asked why the regularity of condition of Brownian motion, namely almost sure continuity, is what it is: almost sure?  Why can't this be upgraded to Brownian motion being surely continuous?

The answer to the latter question is that, actually, it can and very often is.  The answer to the former question is that stipulating almost sure continuity is required in order to make the defining conditions of Brownian motion axiomatic, while still encompassing all of the methods of construction.

Indeed, the most common construction of Brownian motion (or at least the most direct) is through an application of Kolmogorov's extension theorem (the details of this approach can be found in Durrett).  But due to technical issues arising from measure theory (which are actually quite natural), the resulting construction leads to realizations of Brownian motions that are discontinuous.

On the other hand, the approach to constructing Brownian motion from the limit of scaled random walks actually leads to surely continuous realizations.  There are two available routes one can go when having this approach in mind: (a) construct Brownian motion paths directly (i.e. pointwise) from scaled random walks (one common way to do this is by appropriately specifying Brownian motion on the dyadic intervals, interpolating between, and taking limits) or (b) construct Brownian motion by obtaining the Wiener measure on the space of continuous functions beginning at the origin from the induced measures on this space obtained from the scaled random walks on $\mathbb{Z}^{\infty}_{2},$ the space of sequences with values of $-1$ or $1$.

The user also asked whether an explicit example of a discontinuous Brownian motion path could be exhibited.  The following is my complete answer to this and the above questions.

____________________________

Exhibiting a counter-example is straight-forward enough.  For example, let $B_{t}(\omega)$ be a Brownian motion and $\mathcal{T}(\omega)$ a stopping time on $(\Omega,\mathbb{P})$ with a continuous distribution.
Then with
$$B'_{t}(\omega)=\left\{\begin{array}{ll}B_{t}(\omega),&t\neq\mathcal{T}(\omega)\\B_{t}(\omega)+1,&t=\mathcal{T}(\omega),\end{array}\right.$$
$B'_{t}(\omega)$ satisfies (1) and (2) below, but is discontinuous precisely when $t=T(\omega)$.  Therefore, $B_{t}(\omega)$ is a particular realization of Brownian motion that is not everywhere continuous.

There are lots of other ways to obtain a "bad" Brownian motion.  Another example is
$$B'_{t}(\omega)=B_{t}(\omega)\mathbb{1}_{\{B_{t}(\omega)\;\text{irrational}\}},$$
but this is less straight-forward to prove.

____________________________

The reason for stipulating almost sure continuity has to do with the way one constructs Brownian motion, and the issue can be completely dispensed with dependent on one's approach.
The usual presentation in finance texts is the abstract one, namely given a probably space $(\Omega,\mathbb{P})$, one has a Brownian motion $B_{t}(\omega)$ on this space if
1. For every set of times $0\leq t_{1}<t_{2}<\ldots<t_{n}$ the increments $B_{t_{1}},B_{t_{2}}-B_{t_{1}},\ldots,B_{t_{k}}-B_{t_{k-1}}$ form a mutually independent set of random variables on $(\Omega,\mathbb{P}).$
2.  The increments above are normally distributed with mean $0$ and variance $\Delta t$.
3. For almost every $\omega\in\Omega$ the path $t\mapsto B_{t}(\omega)$ is continuous.
Most texts also include a section that sketches a concrete realization of Brownian motion as the limit of scaled random walks.  If one does this rigorously, one sees that (3) upgrades to for every $\omega\in\Omega$

Indeed, if we start with $(\Omega,\mathbb{P})$ satisfying the above and let $\mathcal{P}$ denote the collection of continuous functions $[0,\infty)\to\mathbb{R}$ with $p(0)=0$, then we get from (3) the inclusion map
$$\mathcal{i}:\Omega\to\mathcal{P},$$
defined on a set $\Omega'\subset\Omega$ of full measure, and the push-forward measure of $\mathbb{P}$ onto $\mathcal{P}$ under this inclusion map turns out to be equal to the Wiener measure $\mathbb{W}$ on $\mathcal{P}$, which is unique.

Conversely, one can construct $(\mathcal{P},\mathbb{W})$ directly by starting with the set $\mathcal{P}$ (where every element of this set is continuous a priori) and demonstrating that the measures $\mu_{N}$ on $\mathbb{Z}^{\infty}_{2}$ arising from the appropriately scaled random walks $S_{t}^{N}(\omega)$ ($\omega\in\mathbb{Z}^{\infty}_{2})$ induce a collection of tight measures on $\mathcal{P}$ which converge weakly to $\mathbb{W}$:
$$\mu_{N}\Longrightarrow\mathbb{W}\;\text{(weakly)}$$
One then defines
$$\tilde{B}_{t}(\omega):=p(t)\in\mathcal{P}$$
and readily shows that under $\mathbb{W}$, $\tilde{B}_{t}$ satisfies (1)-(3) and that therefore
$$\tilde{B}_{t}(\omega)=B_{t}(\omega),$$
but that now *every* Brownian motion is continuous.

The equivalence of the implications above show the existence of Brownian motion is essentially tantamount to the existence of a Wiener measure on $\mathbb{W}$ arising from the sequence of measures arising naturally from the scaled random walks.  If one starts from the goal of obtaining this measure, one gets continuity for *every* Brownian motion $p(t)=B_{t}(\omega)$.

____________________________

Other constructions of Brownian motion require us stipulate almost sure continuity due to technicalities arising from measure theory on product spaces.  The quickest construction of Brownian motion in this direction is by applying Kolmogorov's extension theorem on a suitable class of processes; details can be found in Durrett.

21 February, 2015

A Simple Monte Carlo Simulator for European Call Options

In this post I will present a procedural C++ implementation of a simple Monte Carlo simulator for the pricing of a European call option.  Subsequent articles will make significant improvements such as the pricing of puts and different types of options, improved sampling, incorporation of jump processes, etc.

Recall that we model a stock price $S$ as a stochastic process $\{S_{t}:0\leq t\leq T\}$ governed by the stochastic differential equation (geometric Brownian motion)
$$(1)\;\;\;\;dS_{t}=\mu S_{t}dt+\sigma S_{t}dW_{t}$$
where $\mu$ is the drift or expected return on the stock, $W_{t}$ is a Weiner process $(dW_{t}=N(0,1)\sqrt{dt}$ where $N(0,1)$ is the standard normal distribution), and $\sigma$ is the volatility of the stock (a measure of the variance since $\sigma N(0,1)=N(\sigma^{2},1)$).  Using arbitrage arguments (Merton's method) we arrive at the (linear) Black-Scholes-Merton partial differential equation
$$(2)\;\;\;\;V_{t}+\frac{1}{2}\sigma^{2}S^{2}V_{ss}+rSV_{s}-rV=0.$$ The price $V$ of any derivative must satisfy this equation, and conversely, any solution to (2) gives the price of some derivative based on the boundary conditions used (for European call options, the boundary conditions at the expiry time $T$ are $V(\cdot,T)=\max(S_{T}-K,0)$ where $K$ is the strike price of the option and $S_{T}$ is the value of the (random) stock price at time $T$).  Pricing methods for derivatives based on (2) are known as PDE methods in mathematical finance, and usually consist of numerically solving (2) using finite difference methods (since the domain of definition is rectangular in the $(S,t)$ coordinate system).  This can be difficult, however, since the varied boundary conditions must be taken into account and issues of convergence, stability, etc. enter in.

A different (and more recently popular) approach is probabilistic and involves sampling the randomness in the geometric Brownian motion model (1) of the stock price multiple times and taking an average.  Indeed, an application of the Feynman-Kac formula shows that when discounted appropriately, solutions to (1) are martingales and this implies that $V$ is simply the expected value of the discounted payoff of the derivative.  For a European call option, the payoff is $f(S)=\max(S-K,0)$ and so we get
$$(3)\;\;\;\;V_{\text{EuroCall}}=e^{-rT}\mathcal{E}[f(S_{T})]$$
where $r$ is the riskless return, $\mathcal{E}$ is taken under the risk-neutral probability measure, and $S_{T}$ is the final value of the stochastic process $\{S_{t}\}$ at expiry of the option $T$.  (From now on, $V$ is for the price of a European call option.)  Thus, beginning with (1), passing to the logarithm, applying Ito's Lemma and then applying (3) we get
\begin{align*} &dS_{t}=rS_{t}\;dt+\sigma S_{t}dW_{t}\\ \Longrightarrow&d\log S_{t}=(r-\frac{1}{2}\sigma^{2})dt+\sigma dW_{t}\\ \Longrightarrow&\log S_{t}=\log S_{0}+(r-\frac{1}{2}\sigma^{2})t+\sigma W_{t}\\ \Longrightarrow&S_{t}=S_{0}\exp\left\{\left(r-\frac{1}{2}\sigma^{2}\right)t+\sigma\sqrt{T}N(0,1)\right\}\\ \Longrightarrow&V=e^{-rT}\mathcal{E}\left[f\left(S_{0}\exp\left\{\left(r-\frac{1}{2}\sigma^{2}\right)t+\sigma\sqrt{T}N(0,1)\right\}\right)\right]\\ (4) \Longrightarrow&V=e^{-rT}\mathcal{E}\left[\max\left(S_{0}\exp\left\{\left(r-\frac{1}{2}\sigma^{2}\right)t+\sigma\sqrt{T}N(0,1)\right\}-K,0\right)\right]\\ \end{align*}

(Recall that $dW_{t}=N(0,1)\sqrt{dt}$ and so $W_{T}=N(0,1)\sqrt{T}$).  The above computations are somewhat complicated when carried out in detail, and while the explanation for how (2) is derived from (1) is relatively straight-forward, the derivation of (3) from (1) (and thus the previous computations) is significantly more subtle but far more important in the theory of mathematical finance.  A full explanation of the concepts involved (properties of Weiner processes, stochastic integration and Ito's lemma, risk-neutral valuation and the risk-neutral measure, change of numeraire, etc.) is beyond the scope of this post but will be elaborated on in subsequent posts.  In any event, we only need to take faith that (4) is equivalent to (2) for pricing European call options.

The idea of Monte Carlo simulation is now evident. We simulate $N$ paths of $S_{T}$ by sampling from the standard normal distribution $N(0,1)$ and then compute $f(S^{n}_{T})$.  Since each sampling is independent, the random variables $\{f(S_{T}^{n})\}_{n}$ are independent and identically distributed and so the law of large numbers implies
$$\frac{1}{N}\sum_{n=1}^{N}f(S^{n}_{T})\to\mathcal{E}[f(S_{T})]\;\text{as}\;N\to\infty$$
pointwise (and of course, in probability).  We then then discount at $e^{-rT}$ and this is our estimate on the price $V$.

The following implementation is coded procedurally in C++ and prices a European call option using the method explained above.  The only part which may require explanation is the method in which $N(0,1)$ is sampled.  While there are several ways to do this, a simple yet accurate/efficient method is known as the Box Muller algorithm, implemented here.

MonteCarloMethod_Source.cpp
#include <iostream>
#include <cmath>

using namespace std;

double BoxMullerGaussian();
double MonteCarloSimulator(double Expiry, double Strike, double Spot, double Vol, double Riskless, unsigned long N);

int main(void) {
double Expiry, Strike, Spot, Vol, Riskless, N = 0;
cout << "Enter: Expiry, Strike, Spot, Vol, Riskless, # Trials" << endl;
cin >> Expiry >> Strike >> Spot >> Vol >> Riskless >> N;

cout <<  "The price of the option is "
<< MonteCarloSimulator(Expiry, Strike, Spot, Vol, Riskless, N)
<< endl;

double pause;
cin >> pause;

return 0;
}

double BoxMullerGaussian() {
double x,y;

double sizeSquared;
do {
x = 2.0*rand()/(double)(RAND_MAX) - 1;
y = 2.0*rand()/(double)(RAND_MAX) - 1;
sizeSquared = x*x + y*y;
} while(sizeSquared >= 1.0);

return x*sqrt(-2*log(sizeSquared)/sizeSquared);
}

double MonteCarloSimulator(double Expiry, double Strike, double Spot, double Vol, double Riskless, unsigned long N) {
double var = Vol*Vol*Expiry;
double std = sqrt(var);
double itoCorrection = -0.5*var;
double movedSpot = Spot*exp(Riskless*Expiry + itoCorrection);
double _Spot = 0;
double runningSum = 0;

for (unsigned long i=0; i<N; i++) {
double _Gaussian = GetOneGaussianByBoxMuller();
_Spot = movedSpot*exp(std*_Gaussian);
double _Payoff = _Spot - Strike;
_Payoff = _Payoff>0 ? _Payoff : 0;
runningSum += _Payoff;
}

return exp(-Riskless*Expiry)*(runningSum/N); // expectation
}
As an example, we consider Microsoft's stock. Today it closed at 41.35, so $\text{Spot}=41.35$ (the spot price in option pricing is $S_{0}$, which is not random, but $S_{t}$ is for $t>0$ upto $t=T=\text{Expiry}$). We write the option with a strike price $\text{Strike}=40.00$ so that the option is in the money initially (for the buyer). If the time to expiry is 6 mo., then $\text{Expiry}=0.5$. The 6mo. risk-free rate is $\text{Riskless}=0.33$ (taken to be the LIBOR rate quoted this week). The implied 6mo. volatility for Microsoft options is around $\text{Vol}=0.22$. With these parameters and $N=100$ trials, we get $$V_{\text{MSFTEuroCall}}=8.98$$

18 February, 2015

Put-Call Parity

Put-Call Parity for European Options.  Fix $t>0$ and let $T>t$ be a fixed future time. Denote the continuously compounded risk-free interest rate of tenor $T-t$ at time $t$ by $r_{t}(t,T)$, and let $K$ be the strike price on some asset $S$ negotiated at time $t=0$, whose price at time $t\geq0$ is denoted by $S_{t}$.  Then if $c_{t}(K,T)$ and $p_{t}(K,T)$ are the respective prices of European call and put options on $S$ with strike $K$ and expiry $T$, then we have the following result: $$c_{t}(K,T)-p_{t}(K,T)=e^{-r_{t}(t,T)(T-t)}\left(F_{t}(T)-K\right),$$ where $F_{t}(T)$ is the price of a forward contract on $S$ expiring at time $T$, calculated at time $t$. Theoretically, $$F_{t}(T)=S_{t}e^{-r_{t}(t,T)(T-t)}.$$ We are assuming throughout that the asset $S$ pays no income and has no further funding/carrying cost over the period $[t,T]$ beyond the risk-free rate $r_{t}(t,T)$.  The usual adjustments apply if there are dividends, storage costs, etc., with income benefiting the short party and funding/carrying costs benefiting the long party.
Proof.  The proof consists of a simple replication argument.  Let $V_{t}=c_{t}-p_{t}$ be the value of the portfolio at time $t$ consisting of a long position on $c$ and a short position on $p$.  At time $T$ the payoff from our portfolio is
$$V_{T}=c_{T}-p_{T}=\max(S_{T}-K,0)-\max(K-S_{T},0)=S_{T}-K.$$
Therefore, the payoff from our contract is equal to a long forward position on $S$.  If we took opposite positions, then we would have a short forward position.

Thus our portfolio replicates the payoff of a forward contract on $S$.  It follows that

If the value of a derivative is known at time $T$ with certainty, then the value at any previous time $t$ is equal to the value at time $T$ discounted back to time $t$.  In particular, since $V_{T}$ is known with certainty,
$$V_{t}=e^{-r_{t}(T-t)}(S_{T}-K)\;\;\;\;0\leq t\leq T.$$
This assertion follows from the fact that forward contracts have a certain known payoff at their time of expiration, the fact that our portfolio is equal to this payoff, and the principle of Rational Pricing.  It follows that
$$V_{t}=e^{-r_{t}(T-t)}(F_{t}(T)-K)\;\;\;\;0\leq t\leq T.$$

14 February, 2015

Overview of the Black-Scholes Model and PDE

In this post we take the PDE approach to pricing derivatives in the Black-Scholes universe.  In a subsequent approach we will cover the risk-neutral valuation approach; the two are essentially equivalent by the Feynman-Kac formula.

I. ASSUMPTIONS

We will assume that our market consists soley of an equity (stock ) $S$, a risk-free money market account (bond) $B$ with return $r\geq0$, and any number of derivatives with $S$ as the underlying.  We will make several non-technical assumptions about $S$ and our market, collectively termed the "Black Scholes market."

1. Infinite liquidity.  Market participants can buy or sell $S$ at any time.
2. Infinite depth.  The buying and selling of $S$ does not affect the price of $S$, no matter the transaction size.
3.  No friction.  It costs nothing to buy or sell $S$ (i.e. trading $S$ incurs no transaction costs).  In particular, the price paid by the buyer and seller is the same (i.e. bid-offer spread it $0$).
4. Constant risk-free rate. $r\equiv\text{const}.$
5. No arbitrage.  There do not exist portfolios of assets where the portfolio is riskless and earns more than the risk-free money account $B$.
6. Infinite divisibility. Market participants can buy $S$ in any amount $\Delta\in\mathbb{R}$.
7. Short selling is possible.  Market participants can short (borrow) $S$ at no cost.
8. No storage costs.  Market participants can hold $S$ at no cost.

It is possible to relax several of these assumptions in various ways.  Short selling is generally permitted in US markets (cf. SEC up-tick rule) and there are of course no storage costs for equities except for the payment of dividends if one has shorted a dividend paying stock.

One can factor variable risk-free interest rates directly into the model by allowing $r$ to be a deterministic function of time, or even to follow a stochastic process.  There is a tremendous amount of on-going research in dealing with  transaction costs, but let us just say that most institutional investors in derivative contracts (e.g. market makers/banks) take huge positions and therefore the effect of transaction costs is minimized (as we will see below, it is the frequency of trades in $S$ in a process termed dynamic hedging that is the source of transaction costs, not the quantity/volume of a single trade).  For similar reasons, the divisibility assumption is also relatively minor when large numbers are involved, since the fractional component of the quantity in a transaction is small relative to the whole number quantity.

The assumption of infinite liquidity is generally not an issue for plain vanilla contracts that actively trade on exchanges, as there are always counter-parties available to take opposing positions.  The assumption becomes more dubious when one moves to the over-the-counter market where exotic contracts are traded; however, the existence of market makers willing to take positions in essentially any contract that can be hedged essentially validates the assumption.  The non-zero bid-offer spread of course then violates the no friction assumption.

The assumption which is most arguable, however, is that of infinite depth, which violates the law of supply and demand.  At the end of the day however, our goal is to develop a model which is both simple and provides a good approximation to reality, and these assumptions will lead us to such a model which is generally good enough, and can be perfected in various ways as needed.

II. ASSET PRICE MODEL - QUANTITATIVE ANALYSIS APPROACH

In order to price derivatives dependent on a stock $S$ (or any underlying for that matter), it is necessary to first come up with a mathematical model for the price movements of $S$.  This is where the approaches of fundamental and quantitative analysis diverge markedly.  Whereas fundamental analysis attempts to predict stock (asset) price movements through a careful analysis of a company's financial statements and other qualitative sources of information like press releases, general market sentiment, new product launches, etc. (this process is often termed equity research and is the method used by traditional long-term value investors), quantitative analysis models stock (asset) price movements with a stochastic model which we now discuss, and attempts to make predictions on future stock price movements through statistical significance analysis/econometrics, which we will not discuss in any detail here.  Incidentally, a third approach, known as technical analysis, attempts to use past data and trends in order to predict the price in the future.  As we will see, the validity of such an approach represents a direct contradiction to the quantitative model we are about to develop, and we therefore assume it is invalid.  There is in fact, little evidence to suggest that technical analysis leads to reliably predictable results of any degree.

We assume the existence of a probability space $(\Omega,\mathbb{P},\mathcal{F})$ and an associated filtration $\{\mathcal{F}\}_{t\geq0}$ that supports a Brownian motion $\{W(\omega,t)\}_{\omega\in\Omega,t\geq0}.$  We will assume that the reader is familiar with the construction and basic properties of $W(\omega,t)$.

Associated to any process $\Delta(\omega,t)\in L^{2}(\Omega\times\mathbb{R}_{t})$ is an integral called the Ito integral
$$I(\omega,t)=\int_{0}^{t}\Delta(\omega,t)\;dW(\omega,t),$$
which we also assume the reader is familiar with (it is defined for each fixed $\omega\in\Omega$ just like the usual Riemann-Stieltjes integral, except that the sample point in the approximating sum is always taken to be the left-end of each partition interval).  In what follows, we will generally suppress reference to $\omega\in\Omega$ and sometimes use the more customary subscript notation $W_{t}, I_{t}, \Delta_{t},$ etc.

An Ito process is a stochastic process $\{X_{t}\}_{t\geq0}$ defined by the stochastic integral equation (SDE)
$$X(t)=X(0)+\int_{0}^{t}a(X(s),s)\;ds+\int_{0}^{t}b(X(s),s)\;dW(s).$$
Note that the terminology stochastic refers to the fact that the equation involves an Ito integral; however, the solution to an SDE is a random process, and so the method of solution of an SDE in principle does not involve any probability theory.  It is the fact that $W(s)$ is almost surely non-differentiable that complicates any proposed solution method (this is expressed by Ito's lemma, which is a resultantly more complicated version of the chain rule).

For $\mu,\sigma\geq0$, if $a=\mu X$ and $b=\sigma X$, we get (with $S=X$)
$$S(t)=S(0)+\mu\int_{0}^{t}S(s)\;ds+\sigma\int_{0}^{t}S(s)\;dW(s).$$

This is our model for stock-price movements, and it is often called geometric Brownian motion.  It is often expressed locally in "differential" form as
$$dS=\mu Sdt+\sigma SdW$$
or
$$\frac{dS}{S}=\mu dt+\sigma dW.$$

There is no harm in doing this as long as one understands vividly that the differential form has no rigorous meaning attached to it, whereas the integral form is well-defined mathematically.  In fact, the entire topics of SDE's should be replaced by SIE's, since $W$ is no-where differentiable and so differential equations involving it really make no sense.  Nonetheless, the convention pervades the subject, and in particular mathematical finance, and so one must get accustomed to it.

There are two reasons why the differential representation of geometric Brownian motion is used.  First, it provides better intuition for why the model is a good model for stock price movements, as we will explain shortly.  Second, as we will see through the remainder of this article, the it facilitates the computations which come up in quantitative finance, in particular those involving Ito's lemma.

Why is geometric Brownian motion a good model for stock price movements?  The two parameters $\mu$ and $\sigma$ represent drift (expected return) and standard deviation per unit time (volatility), respectively.

Geometric Brownian motion captures the intuitive idea that asset prices should drift according to the expected return $\mu$; the riskier the asset, the higher the expected return demanded by investors, and therefore the greater drift in the asset price, regardless of any random fluctuations.  The expected return on an asset is also independent of the stock price, i.e. investors will demand $\mu$ whether the asset trades at $50$ or $5$.  This is modeled by the $\mu\int_{0}^{t}S(s)ds$ term, or $\mu Sdt.$  If there was no stochastic component to the model, then we would have
$$S(t)=S(0)+\mu\int_{0}^{t}S(s)\;ds,$$
or by the fundamental theorem of calculus
$$S'(t)=\mu S(t),$$
which has the solution
$$S(t)=S(0)e^{\mu t}.$$
This is how we would expect the price of a riskless asset with return $\mu$ to grow.

Of course, asset prices are anything but deterministic, and it is natural to assume the presence of an unbiased (i.e. centered at $0$) white noise weighted according to the perceived volatility of the asset (volatility is not a risk-meaure; it is, among other things, directly tied to the liquidity of the asset and how trading affects its price).  The asset price swings should also be directly proportional the the price of the asset itself.  For instance, a stock that trades around $1$ will have price swings markedly lower than an asset that trades around $100.$  This combined with the volatility of the asset is modeled by the $\sigma\int_{0}^{t}S(s)\;dW(s)$ term, or $\sigma SdW.$

If $\mu=0$, then we would have
$$S(t)=S(0)+\sigma\int_{0}^{t}S(s)\;dW(s).$$
There is no corresponding fundamental theorem of calculus for the Ito integral; however, we will see how to solve this below by using Ito's lemma.  In any event, if we combine these two terms, we recover the geometric Brownian motion model
$$S(t)=S(0)+\mu\int_{0}^{t}S(s)\;ds+\sigma\int_{0}^{t}S(s)\;dW(s).$$

III.  EXTENDING THE MODEL TO DERIVATIVES

The extension of the model to derivatives, that is functions of the asset price $S$ and time $t$, involves a technical theorem known as Ito's lemma.  An expository article on its motivation and rigorous proof can be found on one of my previous posts entitled a rigorous proof of Ito's lemma.

If $V=V(S(t),t)$ is the value of a contingent claim on $S$, then we have from Ito's lemma (appropriately extended to handle geometric Brownian motion) that $V$ follows the process
\begin{align*} V(t)&=V(0)+\int_{0}^{t}V_{t}(S(s),t)\;ds+\int_{0}^{t}V_{S}(S(s),s)\;dW(s)+\frac{1}{2}\int_{0}^{t}V_{SS}(S(s),s)\;ds\\ &=V(0)+\mu\int_{0}^{t}S(s)V_{S}(S(s),s)\;ds+\sigma\int_{0}^{t}S(s)V_{S}(S(s),s)\;dW(s)+\int_{0}^{t}V_{t}(S(s),s)\;ds+\frac{1}{2}\sigma^{2}\int_{0}^{t}S^{2}(s)V_{SS}(S(s),s)\;ds\\ &=V(0)+\int_{0}^{t}\left(\mu S(s)V_{S}+\frac{1}{2}\sigma^{2}S^{2}(s)V_{SS}(S(s),s)+V_{t}(S(s),s)\right)\;ds+\sigma\int_{0}^{t}S(s)V_{S}(S(s),s)\;dW(s).\end{align*}

In the more usual differential form, we have then
$$dV=\left(\mu SV_{S}+\frac{1}{2}\sigma^{2}S^{2}V_{SS}+V_{t}\right)dt+\sigma SV_{S}dW.$$

We again point out that the differential form is just a short-hand for the integral form above, which is the only mathematically meaningful expression.