Notebook 7

Special Topic:  Stochastic Finance

Content

NOTE: All  Exercises are REQUIRED
CHAPTER I.   A BRIEF INTRODUCTION TO FINANCE
I.1  Finance, the Finance System and Financial Assets
I.2  Important Financial Concepts
       I.2.1. Time Value of Money
       I.2.2. Risk and Return
       I.2.3. Valuation
I.3  Derivatives and Risk Management
       I.3.1  The Functions of Derivatives
       I.3.2  Futures Pricing
       I.3.3  Option Pricing 
       I.3.4  Risk Management
        
CHAPTER II.   COMPUTATIONAL FINANCE IN GENERAL 
II.1  Computational Finance 
II.2  Some Active Fields 
        II.2.1  Stochastic Modeling and Simulation 
        II.2.2  Complexity Theory
        II.2.3  Agent-Based  Simulation
        II.2.4  Neural Networks 
II.3  Mathematica in Finance
        II.3.1  Symbolic Computation Systems in Finance
        II.3.2  Examples of Mathematica Implementation 
                   II.3.2.1 Black-Scholes  Model
                   II.3.2.2 Value at Risk    
                                   
CHAPTER III.   STOCHASTIC MODELING AND SIMULATION IN FINANCE 
III.1  Stochastic Modeling 
         III.1.1  The Random Nature of the Financial Market
         III.1.2  Modeling with Stochastic Calculus  
III.2  Stochastic Simulation 
         III.2.1  The Principle of Monte Carlo Simulation for Finance
         III.2.2  Application Examples Implemented in Mathematica 
                     III.2.2.1  Simulation of Stock Price Behavior
                     III.2.2.2  Monte Carlo European Option Pricing
                     III.2.2.3  Monte Carlo Asian Option Pricing
                     III.2.2.4  Monte Carlo Value at Risk

APPENDIX 
              A.1  The Derivation of Ito's lemma
              A.2  The Derivation of Black-Scholes  Formula

REFERENCE

Chapter I  A Brief Introduction to Finance

I.1  Finance, the Finance System and Financial Assets

Finance is defined as the practice of manipulating and managing money.  It is concerned with the process, institutions, markets, and instruments involved in the transfer of money among and between individuals, businesses, and governments. Financial decisions are with two distinctive features: spreading over time, and with uncertainty.
To implement their financial decisions, people make use of the financial system, which is defined as the set of markets and other institutions used for financial contracting and the exchange of assets and risks. The financial system includes the markets for stocks, bonds, and other financial instruments; financial intermediaries (such as banks and insurance companies); financial-service firms (such as financial advisory firms); and the regulatory bodies that govern all of these institutions.    
The basic types of financial assets are bond, stock, etc and derivatives - forward, futures and option, etc. They are categorized into underlying assets and derivative assets.
◼ Underlying Assets
The underlying assets can be stocks, bonds, currency, commodities, and other financial assets, or combinations of these.  The traditional stock and bond markets raise necessary capital for corporations and governments, and the foreign exchange market facilitates international trade and investment. 
▪ Stocks
Stocks represent the claim of the owners of a firm. Stocks are issued by corporations and can be traded in the stock market. Common stock usually entitles the shareholder to vote in the election of directors and other matters. Preferred stock generally does not confer voting rights but it has a prior claim on assets and earnings: dividends must be paid on preferred stock before any can be paid on common stock.
▪ Bonds
Bonds are issued by anyone who borrows money - firms, governments, etc.  They are fixed-income instruments because they promise to pay fixed sums of cash in the future. Bondholders have an IOU (I owe you) from the issuer, but no corporate ownership privileges, as stockholders do.
◼ Derivative Assets
Derivatives are financial instruments that derive their value from the prices of one or more other assets such as stocks, bonds, foreign currencies, or commodities. Derivatives serve as tools for managing risks associated with these underlying assets. The most common types of derivatives are options and futures. 
▪ Forwards and Futures
A forward is a financial contract in which two parties agree to buy and sell a certain amount of the underlying commodity or financial asset at a prespecified price at a specified time in the future. The specified time is called the time-to-maturity of the forward contract and the price specified in the contract is called the forward price. 
A futures contract is a standardized forward contract traded in an exchange. To avoid the shortcomings of the forwards that each party cannot change his/her mind to reverse the position specified in the contract, in a futures contract, both the time to maturity and the amount of the underlying asset to be delivered in each contract are standardized so that the futures contract can be traded in a market place. Thus, if one party wants to change position, he/she can buy or sell in the futures market.
▪ Options 
An option is a financial contract, which provides the holder with the right to buy or sell a certain amount of the underlying asset at a prespecified price at or before a specified time in the future. Similar to the forward and futures contracts, the time specified in an option contract is called the time-to-maturity of the option. The price specified in the contract is called the exercise price or the strike price of the option. 
Unlike a forward or futures contract, an option contract gives its holder the right, but not the obligation to buy or sell the underlying asset. The two most common types of options are calls and puts. A call option is an option to purchase the underlying asset, while a put option is an option to sell.
Everyone would like to hold options because they provide a positive likelihood for the holder to make a profit. But he/she has to pay the price. The cost for this likelihood is the money paid by the buyer of option to the seller to compensate the latter's possible losses. This money is called the premium of the option, or simply the option price.
The following example may help you to understand some of the concepts of derivatives:
You decide to buy a new car and you go to the dealer's showroom. You select a certain type of car, and the dealer tells you that if you place the order today and place a deposit, then you can take delivery of the car in 3 months time. If in 3 months time the price of the model has decreased or increased, it doesn't matter. When the agreement between you and the dealer is reached, you have entered into a forward contract: you have the right and also the obligation to buy the car in 3 months.
Instead, suppose the car you selected is on offer at $ 30,000 but you must buy it today. You don't have that amount of cash today and it will take a week to organize a loan. You could offer the dealer a deposit, for example $200, if he will just keep the car for a week and hold the price. During the week, you might discover a second dealer offering an identical model for a lower price, then you don't take up your option with the first dealer. At the end of the week the $ 200 is the dealer's whether you buy the car, or not. In this case, you have entered an option contract, a call option here. It means that you have the right to buy the car in a week, but not the obligation. The expiration time is one week from now, the strike price is $30,000.          
In this example, for both the forwards and option contracts described, delivery of the car is for a future date and the prices of the deposit and option are based on the underlying asset - the car.

I.2  Important Financial Concepts

I.2.1. Time Value of Money
Time value of money refers to the fact that money in hand today is worth more than the expectation of the same amount to be received in the future. Money has a time value because of the opportunity to earn interest or the cost of paying interest on borrowed capital.
We begin our study of the time value of money with the concept of compounding - the process of going from today's value, or present value (PV ), to future value (FV ). Future value is the amount of money an investment will grow to at some date in the future by earning interest at some compound rate. If i is the interest rate and n is the number of years, the future value of a present value is given by:

                                                                                   FV=((PV( 1+i ))^n)
Calculating the present values of given future amounts is called discounting, the reverse of compounding.    
The time-value-of -money concept provides a tool for making investment decisions. The most common decision rule is the net- present- value ( NPV ) rule, which is a way of comparing the value of money now with the value of money in the future. The NPV is the difference between the present value of all future cash inflows minus the present value of all investments. The rule says that accept any project if its NPV is positive; reject a project if its NPV is negative.

I.2.2. Risk and Return
In the most basic sense, risk can be defined as the chance of financial loss or, more formally, the variability of returns associated with a given asset. Most financial decision-makers are risk-averse because they require higher expected returns as compensation for taking greater risk.
Risk can be assessed from a behavioral point of view using sensitivity analysis and probability distributions. Sensitivity analysis uses the range of estimated return to obtain a sense of the variability among outcomes. The greater the range for a given asset, the more variability, or risk, it is said to have. Although the use of sensitivity analysis is rather crude, it does provide decision-makers with a feel for the behavior of returns. This behavioral insight can be used to assess roughly the risk involved. 
In addition to the range, the risk of an asset can be measured quantitatively using statistics.
Probability distributions of outcome provide a more quantitative, yet behavioral, insight into an asset's risk.   Here we consider two statistics: the standard deviation σ and the coefficient of variation CV, which measures the dispersion around the expected value of a return \(TraditionalForm\`k\&_\).                               

                                                                                     \(TraditionalForm\`k\&_ = ∑\+\(i = 1\)\%n k\_i×p\_i\)
where                                                             (Subscript[k, i])= return for the ith outcome
                                                                       (Subscript[p, i])= probability of occurrence of the ith outcome
                                                                        n = number of outcomes considered   
                      
                                                                       \(TraditionalForm\`σ = \@\(∑\+\(i = 1\)\%n\((\ k\_i - k\&_\ )\)\^2×p\_i\)\)       

                                                                                      CV= \(TraditionalForm\`σ\_k/\ k\&_\)    
The two statistics can be used to measure the risk (i.e., variability) of asset returns. In general, the higher the standard deviation and the coefficient of variation, the greater the risk.                                                                                                            
The return on a portfolio is calculated as a weighted average of the returns on the individual assets from which it is formed. Letting (Subscript[w, j])equals the proportion of the portfolio's total dollar value represented by asset j, and (Subscript[k, j])equals the return on asset j, the portfolio return, (Subscript[k, p])is

                                                  \(TraditionalForm\`k\_p = \(\((\ w\_1×k\_1)\) + \((\ 
              w\_2×k\_2)\) + ⋯ + \((\ 
              w\_n×k\_n)\) = ∑\+\(j = 0\)\%n w\_j×k\_j\)\)                                                

I.2.3. Valuation
Asset valuation is the process of estimating how much an asset is worth, and is at the heart of much of financial decision-making. 
The book value of an asset or a liability as reported in a firm's financial statements often differs from its current market value. In making most financial decisions, it is a good idea to start by assuming that for assets that are bought and sold in competitive markets, price is a pretty accurate reflection of fundamental value. This assumption is generally warranted precisely because there are many well-informed professionals looking for mispriced assets who profit by eliminating discrepancies between the market prices and the fundamental values of assets. This process is called arbitrage, the purchase and immediate sale of equivalent assets in order to earn a sure profit from a difference in their prices. 
Valuation process links risk and return to determine the worth of an asset. The key inputs to the valuation process include cash flows (returns), timing, and the required return (risk compensation). 
Because risk describes the chance that an expected outcome will not be realized, the level of risk associated with a given cash flow can significantly affect its value. In general, the greater the risk of a cash flow, the lower its value. Turning to the opposite point of view, to compensate the risk, the holders of the assets require greater return rate, or discount rate in terms of present value calculation. 
Here we show the basic valuation model. Simply stated, the value of any asset is the present value of all future cash flows it is expected to provide over the relevant time period. The value of an asset is therefore determined by discounting the expected cash flows back to their present value, using the required return as the appropriate discount rate. Utilizing the present value techniques, we can express the value of any asset at time zero, (Subscript[V, 0]), as 

                                                                 (Subscript[V, 0])=((Subscript[CF, 1])/((( 1 + k ))^1))+((Subscript[CF, 2])/((( 1 + k ))^2))+⋯+(((Subscript[CF, n]))/(((( 1 + k ))^n)))                                                             
where                                                       (Subscript[V, 0]) = value of the asset at time zero
                                                                  C(Subscript[F, t])= cash flow expected at the end of year t 
                                                                  k = appropriate required return (discount rate)  
                                                                  n = relevant time period   
The principle of this basic valuation model can be applied into the valuation of bond and stock:
▪ Bond Valuation
Bonds are long-term debt instruments used by business and government to raise large sums of money, typically from a diverse group of lenders. The value of a bond is the present value of the contractual payments its issuer is obligated to make from the current time until it matures. The appropriate discount rate would be the required return, (Subscript[k, b]), which depends on prevailing interest rates and risk. The basic equation for the value, (Subscript[B, 0]), of a bond is given by

                                                             (Subscript[B, 0])=I×[(∑_(t = 1)^n)(1/((((1 +  (Subscript[k, b])))^t)))]+M×[(1/((((1 +  (Subscript[k, b])))^n)))]
where                                                          (Subscript[B, 0])= value of the bond at time zero
                                                                     I = annual interest 
                                                                     n = number of years to maturity
                                                                    M = par value of the bond
                                                                    (Subscript[k, b])= required return on a bond
The value of a bond in the marketplace is rarely equal to its par value. A variety of forces in the economy as well as the passage of time tend to affect value, which are really in no way controlled by bond issuer or investors. When the required return is greater than the interest rate on the bond, the bond value will be less than its par value. In this case, the bond is said to be sold at a discount. On the other hand, when the required return falls below the coupon interest rate, the bond value will be greater than par. In this situation the bond is said to be sold at a premium.
▪ Common Stock Valuation
Like bonds, the value of a share of common stock is equal to the present value of all future benefits it is expected to provide. Simply stated, the value of a share of common stock is equal to the present value of all future dividends it is expected to provide over an infinite time horizon:
       
                                                                (Subscript[S, 0])=((Subscript[D, 1])/((( 1  +  (Subscript[k, s]) ))^1))+((Subscript[D, 2])/((( 1  +  (Subscript[k, s]) ))^2))+⋯+(((Subscript[D, ∞]))/((( 1  +  (Subscript[k, s]) ))^∞))
where                                                      (Subscript[S, 0])= value of common stock at time zero
                                                                (Subscript[D, t])= per share dividend expected at the end of year t  
                                                                (Subscript[k, s]) = required return on a common stock   
From the formula, we can see that any action of increasing the level of expected return without changing risk should increase share value, and vice versa. Similarly, any action that increases risk (required return) will reduce share value, and vice versa.

I.3  Derivatives and Risk Management

I.3.1  The Functions of Derivatives
The most obvious function of derivatives is to facilitate the reallocation of exposure to risk among market participants. Basically there are two strategies to implement the risk reallocation: hedging and speculating.  
Hedging can be generally understood as a financial activity to either reduce or eliminate the risk of an underlying asset by making the appropriate offsetting derivative transaction. Such activities may involve certain costs, i.e. the cost for buying the futures or options.
Let us take the above car-purchasing example. If during the week you discover a second dealer offering an identical model for $ 29,000 then you don't take up your option with the first dealer. The total cost of buying the car is now $29,000 + $200 = 29,200: cheaper than the first price you were offered, i.e $300,000. If you cannot find the car at a cheaper price and buy the car from the first dealer, then the car will cost a total of $300,200. If you decide not to buy at all you will lose $200 to the car dealer. But anyway, in this example, both in the forward contract case and the option one, you are hedging against a price rise in the car - it eliminates the risk of buying a car more expensive than $300,000. 
Speculating is somewhat the opposite activity to hedging. Whereas the aim of hedging is to reduce or eliminate risk by sacrificing some capital, the aim of speculating is to obtain higher returns by taking higher risks.
Again take the above example. Suppose that the car you have bought a call option for is very much in demand and there is a sudden price rise to $33,000. One colleague of yours also wants the same car and hears that you have an option to buy the car for $30,000 in a week's time. You can sell the option to your colleague for $400. This means that the car dealer still gets his sale, your friend gets the car he wants and you make $200 on selling your option. In this case you have speculated on your contract and made a 200%. 
In the following we present the pricing principles and methods for futures and options. Fortunately, the prices of forwards and futures contracts on the same underlying assets with the same time to expiration are generally very close to each other, although they are normally different because of taxes, transaction costs, and other factors. Thus, here we can simply regard futures as the same as forward contracts for convenience of understanding and analysis.

I.3.2.  Futures Pricing
Different from some of their underlying assets, such like copper, etc, futures can be produced and stored at very low cost, so we can ignore those costs completely in deriving parity relations between spot (current) and future prices.
Consider a futures contract (or simply futures) on a share of a stock that pays no dividend. The contract is the promise to deliver a share at some specified delivery date at a specified delivery price. Let us denote this future price by F, and the spot price at the beginning of the stock is S. The relation between F and S is

                                                                                    S = F / ((( 1+r ))^T) 
where r is the risk-free  interest rate, such as the interest rate offered by a bank if you deposit the amount of money in it, T is the maturity of the futures contract in number of years.

I.3.3.  Option Pricing 
The valuation or pricing of options is a careful balance of different market factors. However, the basic principle lies in that, the present value of a option is the expected value of the payoff, i.e the value, of the option at the expiration date at the risk-free  interest rate. For an European call option, the payoff of the option is the difference between the underlying asset price at maturity and strike price of the underlying asset. Then the pricing model for European call option is 

                                                                        C=(e^(-r(T - t))) E [max(S - K,  0)] 
where S is the spot price of the underlying stock at expiration, K the strike price, T the expiration time, t the present time, r the risk-free  interest rate and C, the present price of the option. 
The payoff (or value) of the option at expiration, max (S - K, 0), can be understood in this way: if the stock price at expiration is at or below the strike price, then the payoff of the option is zero, i.e the call option will expire worthless, because nobody wants to buy a stock at a price higher than market price; if it is greater than the strike price, then the payoff is simply the difference between the spot price and the strike price. The difference between the underlying asset price at maturity and strike price is called the intrinsic value of the call option. 
There are also other types of options, e.g Asian option, American option, lookback option etc. They are distinctive in different aspects: how to calculate payoff, whether an option can only be exercised on the expiration data, etc.
The term (e^(-r(T - t)))is the result of continuous compounding. To explain this concept, consider an amount A invested for n years at an interest rate of R per annum. If the rate is compounded once per annum, the terminal value of the investments is 

                                                                                           ((A(1 + R))^n)
 If it is compounded m times per annum, the terminal value of the investment is 
 
                                                                                         ((A(1 + (R/m)))^mn)   
 The limit as m tends to infinity is known as continuous compounding and it can be shown that
 
                                                                             (lim_(m -> ∞))((A(1+(R/m)))^mn)= (Ae^Rn) 
 So, compounding a sum of money at a continuously compounded rate R for n years involves multiplying it by  (e^Rn). Discounting it involves multiplying by (e^(-Rn)).                                                                                                                                                                                                                                                                                 
Here we present the celebrated Black-Scholes formula for calculation of option price. The derivation process of it is shown in Appendix. 

◼ Black-Scholes Option Pricing Formula
The most popular model in options pricing is the Black-Scholes model in which the underlying asset price is assumed to be lognormally distributed. As in most other theoretical models, Black and Scholes made many assumptions. We list a few important ones here:
(i).   The underlying asset price is lognormally distributed;
(ii).  The underlying asset pays no dividend;
(iii). There are no transaction costs in buying or selling the underlying asset or option;
(iv). The short-term interest rate is known and is constant through time.
With these assumptions, Black and Scholes obtained the following formula for the price of a European call option:

                                                                            C = SN ((Subscript[d, 1])) - K(e^(-rT)) N( d )                                                 

where                                                              d = ((ln( S/K ) + (  r -  (σ^2)/2  )T)/(σ(Sqrt[T])))                                                                 

                                                                        (Subscript[d, 1])=  ((ln( S/K ) + (  r + (σ^2)/2  )T)/(σ(Sqrt[T])))= d + σ(Sqrt[T])
C is the price of a call option, K is the strike price of the underlying asset, r is the annual interest rate, σ is the volatility of the annual return of the underlying asset, T is the time-to-maturity in number or fraction of year(s), N(x) is the value of the cumulative function of the standard normal distribution at  x. 
There is a important relationship between a call and its corresponding put option prices with the same strike price and time-to-maturity, which can be used to calculate the put option price:

                                                                                    P = C - S + K(e^(-rT)).
The Black-Scholes formula is clearly a function of five factors: S, K, T, r and σ.  S and r can be observed from the market; K and T are specified in the option contract.  σ, however, is neither specified in the option contract nor directly observable from the market. We have to estimate this volatility value using historical data of the underlying asset in order to use the Black -Scholes formula.
There are a few popular terms characterizing the sensitivity of options prices to the changes of these factors. These sensitivities are often named by Greek letters. They play an important role in both trading activities and risk management in financial institutions. 
Delta (δ = ∂C/∂S) measures how fast its price changes with the price of its underlying asset. Vega (ν =  ∂C/∂σ) measures how fast the option's price changes with the volatility of its underlying asset. Theta (θ = ∂C/∂T)) measures the sensitivity of its price with respect to the time to maturity. Rho (ρ = ∂C/∂r) measures the sensitivity of the option's value with respect to the fluctuation of the interest rate. Gamma (γ = ∂δ/∂S) measures how fast the option's delta changes with the price of its underlying asset. 
                                                                                                                   
I.3.4  Risk Management     
Risk management deals with risk reduction, basing on the principle of benefit-cost tradeoff and information available. There are four basic techniques available for reducing risk:
     ▪ Risk avoidance:  A consciousness not to be exposed to a particular risk.
     ▪ Loss prevention and control:  Actions taken to reduce the likelihood or the severity of  losses.
     ▪ Risk retention:  Absorbing the risk and covering losses out of one's own resources.
     ▪ Risk transfer: Transferring the risk to others who are willing to accept it in order to earn possible profit.
One of the greatest roles of the financial system is transferring risk. Three most commonly used methods for transferring risk are hedging, insuring, and diversifying.  
One is said to hedge a risk when the action taken to reduce one's exposure to a loss also causes one to give up of the possibility of a gain. For example, farmers who sell their future crops before the harvest at a fixed price to eliminate the risk of a low price at harvest time, also give up the possibility of profiting from high prices at harvest time.
Insuring means paying a premium to avoid losses. By buying insurance, you substitute a sure loss for the possibility of a larger loss if you do not insure.
Diversification: diversifying means holding many risky assets instead of concentrating all of your investment in only one.  Its meaning is captured by the familiar saying: "Don't put all your eggs in one basket." The diversification principle is that by diversifying across risky assets, people can sometimes achieve a reduction in their overall risk exposure with no reduction in their expected return.   

◼ Value at Risk : A Technique for Risk Measurement
Value-at-Risk  (VaR) measures the worst expected loss under normal market conditions over a specific period, with a specified probability. For example, suppose that a portfolio manager has a one-day VaR equal to $1 million at 1%. This means that, under normal market conditions, there is only 1 chance in 100 that a daily loss is bigger than $1 million occurs.
In practice, based on historic observations, it is often assumed that, after a certain period of time, the probability density function of the portfolio value (the portfolio profit also) represents a normal distribution. We know that the probability of the portfolio's value is less than  (Subscript[V, a])is given by the area, say A%, of the tail to the left of  (Subscript[V, a])in the probability density profile. Then we can calculate the correspondent maximal loss with this probability, i.e A%VaR: 

                                                                                   A% VaR = (Subscript[V, 0]) - (Subscript[V, a])              
where (Subscript[V, 0])is the value of the portfolio at the beginning. The graph of value probability distribution below illustrates the process of VaR calculation, in which (Subscript[V, 0])= 100, (Subscript[V, a])= 60.

The graph of profit probability distribution below can give a clearer illustration

VaR uses a single number to aggregates all of the risks in portfolio. It can be a tool for management used in various ways: to set their overall risk target, to determine internal capital allocation decision, to assess the risks of investment opportunities before decisions are made, as well as to evaluate the performance on them after the event, etc.

Chapter II  Computational Finance in General

II.1  Computational Finance

Computational finance refers generally to the application of computational techniques to finance. It is a rather broad field, including many diverse areas of applied mathematics, computer science and economics. Nowadays, computational finance has become an integral part of modeling, analysis, and decision-making in financial industry
Many models used in finance end up in formulation of highly mathematical problems. Solving these equations exactly in closed form is impossible as the experience in other fields suggests. Therefore, we have to look for efficient numerical algorithms in solving complex problems such as option pricing, risk analysis, portfolio management, etc.
Especially, in the finance market, financial models used in online information processing are generally large and dynamic, normally ending up in large number of equations, say, 1000 to 100,000 equations. Solving these models is, due to their size, computationally intensive. For this type of problems, high performance computing is needed to generate solutions quickly in order to respond adequately on rapid changes in the financial market.
Recently, enabled by powerful computational tools, computational finance is able to proceed in novel directions:  new stochastic methods, neural networks, chaos theory, genetic algorithms, artificial life, simulated annealing and control of dynamic systems etc. These new computational techniques have greatly enhanced our understanding of complex economic and financial behaviors.

II.2  Some Active Fields

II.2.1  Stochastic Simulation
The financial market is random by nature, e.g the stock prices, interest rates of bonds, foreign exchange rates, etc present typical stochastic behaviors. Understanding this financial probability process can help us to develop correct valuation models for estimating expected returns and volatilities and their effects on asset and derivative prices, which are essential in financial decision making.  The financial stochastic dynamics is mathematically modeled with stochastic calculus and other stochastic methods. 
Many complex financial problems exist for which analytical formulae are not possible. Stochastic simulation (Monte Carlo simulation) provides flexible methods for solving these types of problem. Monte Carlo simulation is advantageous at dealing easily with multiple random factors, implementing some more realistic asset pricing processes, such as that with jumps in asset prices, and that for exotic path-dependent options. The main drawback of Monte Carlo method is its computational inefficiency. However, new research and recent innovations in both technologic and algorithmic aspects have dramatically reduced computational time of Monte Carlo simulation by increasing speed and efficiency, and have been enhancing its attractiveness for modern financial computation.

II.2.2   Complexity Theory
The most important characteristics of chaos theory are clearly contradictory to the fundamental notions of the Newtonian world view of science. For instance, it demonstrates that many types of phenomena (fractal phenomena) are not susceptible to definitive measurement because they lack a characteristic scale, and is hence contradictory to the Newtonian world view which portrays the universe as a clockwork mechanism susceptible to precise measurement, prediction, and control.
The new vision of chaos theory or complexity theory is undermining the methodological perspective advocated by capital markets researchers most notably with respect to the assumptions of linearity and predictability. It is also challenging the validity of the most fundamental or traditional theories and models: EMH (efficient market hypothesis), MPT (modern portfolio theory), the CAPM (the capital asset pricing model), which underlie most of the research about the relationship between market prices and accounting information. The new vision is also breeding new theories of stock price behavior that are quite inconsistent with the traditional capital markets models and it has led to the emergence of a fractal market hypothesis.

II.2.3.  Agent-Based Simulation
Agent-based computational finance models economic markets with large numbers of interacting agents, relying heavily on computational tools to push beyond the restrictions of analytic methods. This new research methodology stresses interactions and learning dynamics in groups of traders who learn about the relations between prices and market information. 
In this framework, traders are made up from a very diverse set of types and behaviors. To make the situation more complex, the population of agent types, or the individual behaviors themselves, are allowed to change over time in response to past performance. The finance market is thought of as an adaptive non-linear network whose primary building blocks are adaptive agents. Also, the research achievements on increasing return and path dependency contribute to this evolutionary perspective of finance and economy.

II.2.4.  Neural Networks
Neural networks are computing models often used for pattern classification and pattern recognition problems. They can learn from examples or experiences and particularly noted for their flexible function mapping ability, and achieves a high degree of prediction accuracy. Therefore, financial application areas that require pattern matching, classification, and prediction, such as bankruptcy prediction, loan evaluation, credit scoring, and bond rating, are fruitful candidate areas for neural network technology.
Especially, financial forecasting is always and will remain difficult because such data are greatly influenced by economical, political, international and even natural shocks.  Neural networks are data-driven self-adaptive methods in that there are few a priori assumptions about the model form for a problem under study. Unlike linear regression analysis, which is limited to the linear function mappings, neural networks are able to discover complex nonlinear relationships in the data. These unique features make them valuable for solving many practical problems such as option price, stocks price, foreign exchange rate forecasting, etc in terms of accuracy, adaptability, robustness, effectiveness, and efficiency.

II.3  Mathematica in Finance

II.3.1  Symbolic Computation Systems in Finance
Financial problems normally turn out to be highly complex and dynamic, and the solutions of them need powerful computational tools. In the last decade or so, powerful software programs, generally called symbolic processors or computer algebra systems, have become readily available for assistance in solving problems mathematically. More advanced symbolic processing programs combine numeric, symbolic, and graphic computation in a single, unified computing environment.
Numerous existed environments will be of interest to financial problem solvers.  These include such packages as GAUSS, MATLAB, GAMS, Mathematica, Maple etc. While each of these is potentially useful, they are not all the same type of environment. Some of them are quite specially designed programming environments for doing matrix-type calculations easily and effectively; some else of them are basically statistical packages, etc. Among them, (Mathematica^®) is one of the most popular and widely used product, which provides a coherent environment that integrates specific functions such as numeric calculations, symbolic calculations, graphics, statistics, a programming language, and document preparation. 
The most common applications of Mathematica in finance are categorized as follows
     ▪  Modelling, programming, and visualization of financial problem
     ▪  Analytical valuation of financial assets
     ▪  Financial derivatives pricing
     ▪  Measurement of financial risks

II.3.2.  Examples of Mathematica Implementation

II.3.2.1 Black-Scholes Model
The Black-Scholes model provides a direct way of valuing a standard European call option for common stock. To implement it in Mathematica, we at first define the auxiliary functions d, d1 for calculating the parameters d and (Subscript[d, 1])of the Black-Scholes model:

Clear[S, K, σ, r, t];
d[S_, K_, σ_, r_, 
        t_] = (Log[S/K] + 
              r t)/(σ Sqrt[t]) -  .5 σ Sqrt[
            t]

\(\(\(d1[S_, K_, σ_, r_, t_] = 
      d[S, K, σ, r, t] + σ\ Sqrt[t]\)\(
\)
    \)\)

BlackScholes[S_, K_, σ_, r_, t_] = 
      S Norm[d1[S, K, σ, r, t]] - 
        K Exp[-r t] (Norm[
              d[S, K, σ, r, t]])
Norm[z_?NumberQ] := N[0.5 + 0.5 Erf[z/Sqrt[2]]]

We are now ready to compute the dollar value for stock options by calling the function BlackScholes with numerical arguments. For example, we might wish to find the value of a call option on a stock with an exercise price of 60 assuming that the current price of it is 58.5, the time until expiration is 0.3 years, the volatility of the stock is 29%, and the continuously compounded risk-free rate of return is 4% as follows:

BlackScholes[58.5, 60. , 0.29, 0.04, 0.3]

Using the graphic capabilities of Mathematica one can easily explore the various qualitative properties of the Black-Scholes formula. For example, We can plot the dependence of the option price on the stock price for the option, and that on the time to maturity:

Plot[BlackScholes[S, 60. , 0.29, 0.04, 0.3], {S, 50, 70}, 
      AxesLabel -> {"S",  "option_price"}]

\(\(\(Plot[BlackScholes[58.5, 60. , 0.29, 0.04, t], {t, 0.01, 0.5}, 
      PlotRange -> \ Automatic, 
      AxesLabel -> {"t", \ "option_price"}]\)\(
\)
    \)\)

REQUIRED
II.3.a Give a financial interpretation of this figure. It is helpful to run the code again by setting a short plotting range, i.e, { 0 , 0.5 }.

We can make a 3D plot of option value as a function of both stock price and time to expiration.

Plot3D[
      BlackScholes[S, 60. , 0.29, 0.04, t], {S, 50. , 70. }, {t, 0.01, 0.5}, 
      ViewPoint -> {20.0, 30.600, 6.0}]

As indicated above, risk can be assessed by using sensitivity analysis of the Greeks.  The most important parameter that affects the value of an option is the price of the underlying stock. The Greek δ  is the partial derivative of option value with respect to stock price and is a useful measurement of risk for an option because it indicates how much the price of the option will respond to a $1 change in the price of the stock. 
To find Delta, we at first calculate the derivative of the Norm function:

Norm'[z_] = N[(1/Sqrt[2 Pi])] Exp[-z^2/2]

Then the function that computes Delta is

Delta[S_, K_, sd_, r_, t_] = 
        D[BlackScholes[S, K, sd, r, t], S];

When Delta is applied to the situation given above, we have:

Delta[58.5, 60. , 0.29, 0.04, 0.3]

It shows that for a $1 increase in the stock, the price of this call option will increase by about 50 cents. A plot of Delta against stock price provides a fundamental insight into option valuation as follows:

Plot[Delta[x, 60. , 0.29, 0.04, 0.3], {x, 20. , 100. }, 
      AxesLabel -> {"S",  "Delta"}]

REQUIRED
II.3.b  Explain this figure upon the view of sensitivity analysis. Another Greek can facilitate you for this explanation. Which Greek is it? Why? Plot it against stock price.

The Black-Scholes formula provides a way to infer the volatility of a stock's price from the observed price of an option on that stock. Implied volatility is defined as the value of σ that makes the observed market price of the option equal to its Black-Scholes formula value. The function ImpliedVolatility to solve numerically for the volatility of an option given its price as follows:

ImpliedVolatility[S_, K_, r_, t_, optionprice_] := 
      sd /. FindRoot[
          BlackScholes[S, K, sd, r, t] == optionprice, {sd, 
            0.2}]

Hence, if we knew the price of the option given above as 3.34886, we could verify that the volatility is 0.29 as follows:

ImpliedVolatility[58.5, 60. , 0.04, 0.3, 3.34886]

Implied volatility is the collective wisdom of the market. It is also an extremely useful way of looking at options: indeed, some options on foreign currencies and other financial instruments are frequently quoted in terms of their implied volatility rather than by price. Many trading strategies are designed in the light of the value of implied volatility.

REQUIRED
II.3.2.2  Value at Risk

Suppose a portfolio manager manages a portfolio that consists of a single asset. The return of the asset is normally distributed with annual mean return 10% and annual standard deviation 30%. The value of the portfolio today is $100 million. We want to answer various simple questions about the end-of-year distribution of portfolio value:

1. What is the distribution of the end-of-year portfolio value?
2. What is the probability of a loss of more than 20 million dollars by year end (i.e., which is the probability that the end-of-year value is less than $80 million)?
3. With 1% probability what is the maximum loss at the end of the year? This is the VaR at 1%.

We start by loading Mathematica's statistical package:

Needs["Statistics`Master`"]

Needs["Statistics`MultiDescriptiveStatistics`"]

We first want to know the distribution of the end-of-year portfolio value:

Plot[PDF[NormalDistribution[110. , 30], x], {x, 0, 200}, 
      AxesLabel -> {"value",  "probability"}]

Then we can calculate the probability that the end-of-year portfolio value is less than $80:

CDF[NormalDistribution[110, 30], 80] // N

The answer is about 15.9%.

To calculate the maximum loss at 1% at the end of the year, we can at first calculate the end-of-year value at 1%:

Quantile[NormalDistribution[110. , 30], 0.01]

So the answer is (100-40.2096)  =  59.7904. i.e the VaR at 1% is about $60 million.

We can formalize this by defining a VaR function, which takes as its parameters the mean mu and standard deviation sigma of the distribution as well as the VaR level x.

ClearAll[VaR]

VaR[mu_, sigma_, x_] := 
      100 - Quantile[NormalDistribution[mu, sigma], x]

VaR[110, 30, 0.01]

REQUIRED
II.3.c  Using the parametric values in this example, calculate the 10%VAR. Plot two figures similar to the ones showed in section I.3.4.

Chapter III  Stochastic Modeling and Simulation in Finance

III.1  Stochastic Modeling

III.1.1 The Random Nature of the Financial Market
The values of the major indices and the graphs of them are quoted frequently on newspapers, television news bulletins. To many people these 'mountain ranges' showing the variation of the value of an asset or index with time is an excellent example of the 'random walk'. 
We cannot predict tomorrow's values of asset prices. The past history of the asset value is there as a financial time series for us to examine as much as we want: but we cannot use it to forecast the next move that the asset will make. This does not mean that it tells us nothing. We know from a statistical analysis of it what are the likely jumps in asset price, what are their mean and variance and, generally, what is the likely distribution of future asset prices. 
According to the efficient market hypothesis, which states that market prices reflect the knowledge and expectations of all investors, asset prices must move randomly. This basically tells two things: 
     ▪ The past history is fully reflected in the present price, which does not hold any further information;
     ▪ Makets respond immediately to any new information about an asset price.
Thus the modeling of asset prices is really about modeling the arrival of new information which affects the price. With the two assumptions above, changes in the asset price are a Markov process.
Now suppose that at time t the asset price is S. Let us consider a small subsequent time interval dt, during which S changes to S + dS.  We can model the corresponding return on the asset, dS / S , into two parts. One is a predictable, deterministic return akin to the return on money invested in a risk-free bank. It gives a contribution

                                                                            μdt
                                                                                                                                       
to the return dS / S, where μ is a measure of the average rate of growth of the asset price, also known as the drift. Normally, μ is taken to be a constant.
The second contribution to dS / S models the random change in the asset price in response to external effects, such as unexpected news. It is represented by a random sample drawn from a normal distribution with mean zero and adds a term 

                                                                                                                             
                                                                           σdz
                                                                                                                     
to dS / S . Here σ is a number called the volatility, which measures the standard deviation of the returns. The quantity dz is the sample from a normal distribution, which is discussed further below. 
Putting these contributions together, we obtain the stochastic differential equation
  
                                                                            (dS/S)= σdz + μdt          (III.1)                                                                                                                                                                    
which is the mathematical representation of our simple recipe for generating asset prices.
The only symbol in the above equation whose role is not yet entirely clear is dz. If we were to cross out the term involving dz, by taking σ = 0, we would be left with the ordinary differential equation

                                                                                (dS/S)=  μdt          (III.2)
                                                               
          or                                                                  (dS/( dt))=  μS          (III.3)                                                                  
When μ is constant this can be solved exactly to give exponential growth in the value of the asset, i.e.

                                                                             S = S\(\_0\)((e )^(μ( t  -  (Subscript[t, 0]))))          (III.4)                                                           
where S\(TraditionalForm\`\_0\)is the value of the asset at t = t\(\_0\).Thus if σ = 0 the asset price is totally deterministic and we can predict the future price of the asset with certainty.
The term dz, which contains the randomness that is certainly a feature of asset prices, is known as a Wiener process. It has the following properties:
     ▪ dz is a random variable, drawn from a normal distribution;
     ▪ the mean of dz is zero;  
     ▪ the variance of dz is dt. 
One way of writing this is 

                                                                              dz = ϕ (Sqrt[dt])          (III.5)                                                            
where ϕ is a random variable drawn from a standardized normal distribution. The standardized distribution has zero mean, unit variance and a probability density function given by

                                                                                (1/((Sqrt[2  π])))(e^(-(1/2)(ϕ^2)))                                                                
for -∞ < ϕ < ∞. If we define the expectation operator ξ by

                                                ξ [F(.)] = (1/((Sqrt[2  π])))(∫_(-∞)^∞)F(ϕ)(e^(-(1/2)(ϕ^2)))dϕ          (III.6)                                        
for any function F, then 
                                                                                   ξ [ϕ] = 0           (III.7)                                                               

          and                                                                  ξ [(ϕ^2)] = 1          (III.8)
                                                                
Equation (III.1) is a particular example of a random walk. It does not refer to the past history of the asset price; the next asset price ( S + dS ) depends solely on today's price and hence it is a Markov process.

III.1.2  Modeling with Stochastic Calculus 
In modeling, analyzing and predicting activities in finance, greater and greater emphasis has been placed upon stochastic methods: Ito's lemma, stochastic differential equations, stochastic stability and stochastic control. Such methods are expected to capture the various complexities, measurement errors and uncertainties that are associated with financial reality. Among them, Ito's lemma is the basic stochastic calculus rule for computing stochastic differentials of composite random functions.

◼ Ito's Lemma
Let u(X,t) be a continuous, non-random function with continuous partial derivatives and X(t) a stochastic process defined by

                                                 dX (t) = a ( X, t )dt+b ( X, t )dz(t)          (III.9)                                             
where dz(t) is the standard Wiener process. Then the stochastic process Y(t) = u (X (t),t) has the following form of stochastic differential

                 dY(t) = (((∂u)/(∂t))+a(X, t)((∂u)/(∂X))+(1/2)((b(X, t))^2)(((∂^2) u)/(∂(X^2))))dt + b(X,t)((∂u)/(∂X))dz(t)        (III.10)              
The derivation of Ito's Lemma is given in Appendix. Here we simply use it to model stochastic processes. In the following we show two examples of stochastic modeling: 

(1). Geometric Brownian Motion model for asset price dynamics
The asset model we discussed above is 

                                                                  (dS/S)=σdz + μdt          (III.11)                                                     
With the help of the correspondent expression of Ito's lemma                                                     
                                                                                                       
                                                                               df=((∂f)/(∂S))dz+(μS((∂f)/(∂S))+(1/2)(σ^2)(S^2)(((∂^2) f)/(∂(S^2)))+((∂f)/(∂t)))dt          (III.12)                            
we can quickly derive a probability density function for the asset price, S(t). Setting                            
                                
                                                                       f = lnS          (III.13)                                                              
 we have                                                                  
                                                              
                                               ((∂f)/(∂S))=(1/S)       (((∂^2) f)/(∂(S^2)))=-(1/((S^2)))      ((∂f)/(∂t))=0                             
Substituting them into the expression of Ito's Lemma III.12 results in                                    
                                    
                                                           d ln(S) = σ dz + (μ-(1/2)(σ^2))dt          (III.14)                                                                                               

i.e                                                      ln((Subscript[S, t]))- ln((Subscript[S, 0]))=  σ dz + (μ-(1/2)(σ^2))dt          (III.15)                                    
Finally we get                                          
                                   
  \(TraditionalForm\`\(\(\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \)\(S\_t\)\(\ \)\)\)= (Subscript[S, 0])Exp( σ dz + (μ-(1/2)(σ^2)) dt )          (III.16)                                       
 It shows that the asset price follows a lognormal distribution.                                                       

(2). Derivative securities pricing model 
Again we start at the asset model 

                                                                       (dS/S)=σdz + μdt          (III.17)                                                         
Suppose that f is the price of a derivative contingent on S, which must be a function of S and t. Ito's lemma says 

                                                                               df=((∂f)/(∂S))dz+(μS((∂f)/(∂S))+(1/2)(σ^2)(S^2)(((∂^2) f)/(∂(S^2)))+((∂f)/(∂t)))dt          (III.18)                               

An important step in derivatives valuation is the elimination of randomness: the two random walks in S (equation III.17) and f (equation III.18) are both driven by the single random variable dz. We can exploit this fact to construct a third variable Π whose variation dΠ is wholly deterministic during the small time period dt.
Let Δ be a constant number during the timestep dt and let
 
                                                                        Π = -f  + ΔS          (III.19)
We can write  

                                                                  dΠ= -df  + ΔdS 
                                  
                                                                             = -σS((∂f)/(∂S))dz (μS((∂f)/(∂S))+(1/2)(σ^2)(S^2)(((∂^2) f)/(∂(S^2)))+((∂f)/(∂t)))dt 
                                                                                  +Δ( σSdz + μSdt )
                                            
                                                                            = - σS ( ((∂f)/(∂S))-Δ)dz 
                                                                                   -( μS(((∂f)/(∂S))-Δ)+(1/2)(σ^2)(S^2)(((∂^2) f)/(∂(S^2)))+((∂f)/(∂t)) )dt          (III.20)                                                 
Now, by choosing Δ = ∂ f/∂ S, we can make the coefficient of dX vanish. So, It follows that by choosing a portfolio of the stock and the derivative, the Wiener process can be eliminated                              
The appropriate portfolio is                                                                                                                                     

                                                                                       - 1: derivative

                                                                                    +((∂f)/(∂S)): shares of stock                                                 
The holder of this portfolio is short (agreeing to sell in the future) one derivative and long (agreeing to buy in the future) an amount ∂ f/∂ S of shares. Defining Π as the value of the portfolio, we have                                                 

                                                                                Π = -f  +((∂f)/(∂S))S          (III.21)                                                                                                                             

          and                                                          dΠ = - df  +((∂f)/(∂S))dS          (III.22)                                                            
 Substituting equations (III.17) and (III.18) into equation (III.22) yields
 
                                                                            dΠ =  (-((∂f)/(∂t))- (((σ^2))/2)(S^2)(((∂^2) f)/(∂(S^2)))) dt          (III.23)
Because this equation does not involve dz, the portfolio must be riskless during time Δt. The assumptions listed in the preceding section imply that the portfolio must instantaneously earn the same rate of return as other short-term  risk-free securities. If it earned more than this return, arbitrageurs could make a riskless profit by shorting the risk-free  securities and using the proceeds to buy the portfolio; if it earned less, they could make a riskless profit by shorting the portfolio and buying risk-free  securities. It follows that 
 
                                                                                              dΠ =  rΠdt          (III.24)                                                        
where r is the risk-free  interest rate. Substituting from equation (III.21) and (III.23), this becomes                                                        
 
                                                          (-((∂f)/(∂t))- (((σ^2))/2)(S^2)(((∂^2) f)/(∂(S^2))))dt = r (-f + S ((∂f)/(∂S)))dt          (III.25) 

          So that                                                       ((∂f)/(∂t))+ (((σ^2))/2)(S^2)(((∂^2) f)/(∂(S^2)))+ r S ((∂f)/(∂S))- rf = 0          (III.26)                                                                                                                                                                               
This parabolic partial differential equation is called the Black-Scholes-Merton   differential equation. Combining it with particular boundary conditions of European call, we can derive Black-Scholes formula as shown in Chapter I. The complete derivation is in Appendix.

III.2  Stochastic Simulation

III.2.1  The Principle of Monte Carlo Simulation for Finance
The Monte Carlo method simulates the random movement of the asset prices and provides a probabilistic solution to the option pricing problems. Since most derivative pricing problems can be formulated as the valuation of the discounted expectation of the terminal payoff function, the Monte Carlo simulation becomes naturally an effective numerical tool for pricing derivative securities whose analytic closed form solutions do not exist, e.g. Asian option pricing. 
Consider a derivative dependent on a single underlying asset S that provides a payoff at time T. Assuming that interest rates are constant, we can value the derivative by following the steps below:
1. Sample a random path for S in a risk-neutral  world ( the risk preferences of the investors do not affect the price): (Subscript[S, t]) = (Subscript[S, 0])Exp( σdz  + (μ - 1/2(σ^2)) dt ).
2. Calculate the payoff, for an European call option, it is max((Subscript[S, T]) - X, 0).
3. Discount the expected payoff at the risk-free rate to get an estimate of the value of the derivative c = (e^(-r(T - t))) max((Subscript[S, T]) - X, 0). 
4. Repeat steps 1 and 2 to get many sample values of the payoff.
5. Calculate the mean of the values to get the price of the derivative: \(TraditionalForm\`c\&^\) = 1/M (∑_(i = 1)^M) (Subscript[c, i]). 
The major advantage  of the Monte Carlo approach is its ease to accommodate complicated terminal payoff function in a derivative pricing model. For example, the terminal payoff may depend on the average of the asset price over certain time interval (Asian options) or the extremum value of the asset price over some period of time (Lookback options). It is quite straightforward to obtain the average or extremum value in the simulated price path in individual simulation runs, and this represents a instinctive advantage. The main drawback of the Monte Carlo simulation is the demand for a large number of simulation trials in order to achieve a high level of accuracy. However, viewing from another perspective, practitioners dealing with a newly invented option may obtain an estimate of its price using the Monte Carlo approach through brute force simulation, rather than risking themselves in the construction of an analytic pricing model for the new option.
For the same reasons, Monte Carlo is also widely used in calculation of VaR (value at risk). Under Monte Carlo method, possible futures of assets values are constructed and the value change of the portfolio under those asset value changes are remembered. The resulting distribution of portfolio value changes can then be statistically analyzed. To calculate, say 5% VaR, it is only necessary to sort the value changes in ascending order and select the change that is 5% of the way through the list.
The main steps in a basic Monte Carlo approach to estimating VaR are as follows: 
1. Value the portfolio using the current values of assets.
2. Sample every asset once to obtain its change in value at the end of horizon Δt. 
3. Calculate the value change of the portfolio ΔP, at the end of the horizon using the result of step2.
4. Repeat step 2 and 3 many times to build up a probability distribution for ΔP.
5. Fix the required VaR from the distribution.
Here we give a example to explain this process. Consider a portfolio with initial value $100. We run Monte Carlo simulation following the above steps for 100 times and obtain a series of value change of the portfolio (see the table below). This series is then ranked best-case-to-worst    and the number corresponding to the chosen level of confidence is picked from the series. In the case, for the 97.5% confidence level one merely averages outcomes number 97 and 98 to come up with the VaR: -$3.30.

({{Path,         Value, \(\(\ \ \ \ \ \ \ \)\(Value_change\)\),         Rank No.}, {100,         99.00, \(\(\ \ \ \ \ \)\(-1.00\)\),     75}, {  99,         99.50, \(\(\ \ \ \ \ \)\(-0.50\)\),      58}, {  98,       101.75, \(\(\ \ \ \ \ \)\(+1.75\)\),      21}, { ·, \(\(\ \ \ \ \ \ \ \)\(·\)\),    ·,    ·}, { ·, \(\(\ \ \ \ \ \ \ \)\(·\)\),    ·,    ·}, { ·, \(\(\ \ \ \ \ \ \ \)\(·\)\),    ·,    ·}, {   2,          97.75, \(\(\ \ \ \ \ \)\(-2.25\)\),      91}, {   1,          98.25, \(\(\ \ \ \ \ \)\(-1.75\)\),      86}})

The Monte Carlo prices for two assets are generated according to the formulae

                                                           (Subscript[S, 1])(t)/(Subscript[S, 1])(0)= Exp[(r-((Subscript[σ, 1])^2)/2) t + (Subscript[ϵ, 1]) (Subscript[σ, 1])(Sqrt[t])]  
                                                                                                                                                
                                                           (Subscript[S, 2])(t)/(Subscript[S, 2])(0)= Exp[(r-((Subscript[σ, 2])^2)/2) t + (Subscript[ϵ, 2]) (Subscript[σ, 2]) (Sqrt[t])]           (III.27)
The correlation of the assets is imposed by requiring that the random numbers \(TraditionalForm\`ϵ\&_\) be correlated. Specifically, a vector of two uncorrelated random number, \(TraditionalForm\`η\&_\) is constructed, and the correlation is effected by transformation

                                                                                          \(TraditionalForm\`ϵ\&_\) = A.\(TraditionalForm\`η\&_\)  
                                                                                                                                                    
                                                                                A=(({{1, 0}, {ρ, (Sqrt[1  -  (ρ^2)])}}))          (III.28)
where ρ is the correlation of the two assets. So we can have
      
                                                                              (Subscript[ϵ, 1])= (Subscript[η, 1])
  
                                                                              (Subscript[ϵ, 2])= \(\(η\_1\) ρ + \ \(η\_2\) \@\(1\  - \ ρ\^2\)\)          (III.29)                                                      
The derivation of A refers to [7].  The A matrix for portfolio with n assets can also be derived.

III.2.2  Application Examples Implemented in Mathematica                    

III.2.2.1  Simulation of Stock Price Behavior 
Here we simulate stock price behavior formulated by (Refer to III.1.1)

                                                                               (dS/S)= σ dz + μ dt                                                   

          or                                                  (Subscript[S, t+1])=(Subscript[S, t])+ σSdz + μSdt,   t = 0, 1, . . . n

Needs["Statistics`NormalDistribution`"]

t = 250; S = 49; r = 0.1; 
    dt = 0.01; σ = 0.2;
DATA = 
        Table[S = 
            S + S*(r*dt + 
                    Random[NormalDistribution[]]*σ*
                      Sqrt[dt]), {t}];

Take[DATA, 100];

ListPlot[DATA, PlotJoined -> True, PlotRange -> {40, 70}, 
      AxesLabel -> {"t(time)",  "S(stock price)"}]

The above code is for only one path of the random stock movement. Repeating the procedure for many times and putting the results together we get the following multiple-path  graph. The principle behind this is important for Monte Carlo simulation for finance. As that we stated in III.2.1 and that we will see late, Monte Carlo simulation needs a number of times of random procedure followed by somehow diverse results, of which the mean is what we seek after.

III.2.2.2  Monte Carlo European Option Pricing

In the method of Monte Carlo simulation for pricing plain vanilla (or standard) European option, instead of adopting a closed form equation, like Black-Scholes formula, we simply take use of the fundamental equation for stock price (III.16). With the stock price at expiry date, we can calculate the payoff max( (Subscript[S, T]) - X, 0). Then, by discounting the payoff to the beginning date we can get the price of the option. Repeating many times we can obtain the approximated option price by averaging the results of the sample values.
At first, we define the simulation procedure:

Needs["Statistics`NormalDistribution`"]

nor[mu_, sig_] := Random[NormalDistribution[mu, sig]];

MCEuropean[s_, n_, σ_, τ_, r_, exercise_Function] := 
      Module[{m = N[Log[s] + (r - 1/2 σ^2) τ], 
          sg = N[σ Sqrt[τ]], tb1}, 
        tb1 = Table[nor[m, sg], {i, n}]; 
        Exp[-r τ] Map[exercise, Exp[Join[tb1, 2  m - tb1]]] // {n, 
              Mean[#], StandardErrorOfSampleMean[#]} &]

MCEuropeanCall[k_, s_, n_, σ_, τ_, r_] := 
      MCEuropean[s, n, σ, τ, r, Max[# - k, 0] &]

Notice that to improve the accuracy of the result, a method called the antithetic variable technique is used in this code, i.e using one set of random number to generate two sample sets: tb1 and 2m-tb1 .  Now let's run, for example, 1000 samples:

MCEuropeanCall[50, 50, 1000,  .4, 5/12,  .1]

The simulation result is: the mean of option price is around 6.1; the deviation of the samples is around 0.2.  By the principle of Monte Carlo simulation, we expect that the more times we sample, the more accurately the final result converges to the analytic result. For comparison, here we calculate the option price using the code for Black-Scholes formula in II.3.2.1. The result is assigned to BStheory.

BStheory  = %[[2]]

In the following graph, we put together all the results of Monte Carlo simulation with different sample numbers:

\(\(results[EuropeanCall]\  = \ 
        Table[MCEuropeanCall[50, 50, 1000\ 2^n,  .4, 5/12,  .1], 
		{n, \ 
            0, \ 4}];\)\)
temp  =  results[EuropeanCall];
PrependTo[
        temp,   {"n",   "mean",   "stderrr"}];
TableForm[temp]

A plotting function ShowPrice is defined below to illustrate these results comparing with the theoretic solution.

Clear[Bar, ShowIt];
\(\(\(Bar[{x_, \ y_, \ dy_}]\  := \ 

        Line[{{x, \ y\  - \ 2\ dy}, \ {x, \ y\  + \ 2\ dy}}];\)\(
\)
    \)\)
\(\(ShowPrice[nlist_, \ tdata_]\  := 
	
        Module[{nbars, \ xmax, \ tline}, 
		nbars\  := \ 
            Bar\  /@ \ nlist; 
		xmax\  = \ 
            Max[First\  /@ \ nlist]; 
		tline\  = \ 
            Line[{{0, \ tdata}, \ {xmax, \ tdata}}]; 
		Show[
            Graphics[{tline, \ RGBColor[1, 0, 0], \ 
                nbars}, 
				\ Axes\  -> \ Automatic]]];\)\)

ShowPrice[results[EuropeanCall],  BStheory];

The red vertical bars represent the results of Monte Carlo simulation with different sample numbers, the black horizontal line is the theoretical result. Notice that the height of a red  bar represents the standard deviation of a simulation result, and the central point of it represents the mean.  From the graph, we see that when the sampling number becomes large enough, e.g, 16000 times here, the simulation result is very closed to the analytic one, and the correspondent stand deviation becomes much smaller.

III.2.2.3  Monte Carlo Asian Option Pricing

An Asian option is an option of which the payoff is calculated by using the average price of the underlying asset during at least some part of the life of the option. For a call option, the payoff is max((Subscript[S, ave])-K, 0); for a put, it is max (K-(Subscript[S, ave]), 0).
Asian options are considered to be without analytic closed form solutions. To price Asian options, people resort to Monte Carlo methods. The basic procedure of Monte Carlo Asian call option pricing is the same as that of standard European call option. The main difference lies in the calculation of payoff. In the following code, we calculate the price of Asian option whose average prices of the underlying asset  (Subscript[S, ave])are taken along the horizon between certain time T1 and the expiration.

paths[s_, σ_, T1_, τ_, r_, n_, navg_] := 
        Module[{mt1 = Log[s] + (r - σ^2/2) T1, 
            st1 = σ Sqrt[T1], 
            mpath = 1 + r (τ - T1)/(navg - 1), 
            spath = σ Sqrt[(τ - T1)/(navg - 1)]}, 
          Table[NestList[# nor[mpath, spath] &, Exp[nor[mt1, st1]], 
              navg - 1], {i, n}]];

MCAsianCall[s_, k_, σ_, T1_, τ_, r_, n_, 
        navg_] := (Exp[-τ r]*
            Map[Max[0, Mean[#] - k] &, 
              paths[s, σ, T1, τ, r, n, navg]]) // {n, Mean[#], 
            StandardErrorOfSampleMean[#]} &

Notice that the price of the underlying asset at T1 corresponds to the formula (Subscript[S, t])=(Subscript[S, 0])Exp[μ-(1/2)(σ^2)]dt+σdz; the prices in the path between T1 and T use dΔS/(Subscript[S, 0])=μdt + σdz. 
Because we lack an analytic solution for Asian options, simply for the comparison of the results with different sample numbers, one of the running results which is with 100000 samples is given here. It is time consuming and you don't have to run it yourself.

AsianCall100000 = 5.59597

Now we can run this Monte Carlo program with some reasonable sample numbers and show the results in a same graph.

\(\(results[AsianCall]\  = \ 
        Table[MCAsianCall[50, 50,  .4, 4/12, 5/12,  .1, 1000\ n, 
            30], 
		{n, \ 1, \ 4}];\)\)
temp  =  results[AsianCall];
PrependTo[
        temp,   {"n",   "mean",   "stderrr"}];
TableForm[temp]

ShowPrice[results[AsianCall], AsianCall100000];

REQUIRED
III.2.a Define a function MCLookbackCall[s_, σ_, τ_, r_, n_, navg_] for a lookback call option. The payoff from a lookback call is the amount that the final stock price exceeds the minimum stock price achieved during the life of the option. The above code for Asian option pricing can be used here after some modification. Notice that here path is the whole range of the option's life and strike price is not used. Calculate the option price MCLookbackCall[50, 0.4, 5/12, 0.1, 1000, 30].
Hint: use the Mathematica functions Last[] and Min[].

III.2.2.4  Monte Carlo Value at Risk

Monte Carlo simulation provides a brute force method of calculating VaR for portfolio with nonlinearity of instruments and can handle virtually any type of portfolio, however complex or exotic. Like the above cases of the option pricing simulation, the fundamental factor of Monte Carlo simulation of VaR is the stochastic process of asset prices, which is presented here by a function GeoBrownianMotion.

\(\(GeoBrownianMotion[r_, σ_, τ_, \ ϵ_] := 
	
        Exp[\((r - 
                  0.5\ σ\ σ)\)\ τ - ϵ\ σ\ \@τ];\)\)

Here we deal with a portfolio contain two assets. The function MonteCarloVAR is constructed below to project the prices of two random assets undergoing stochastic motion:

Needs["Statistics`DataManipulation`"]

RandNormal[] := 
        1.41421 (Sqrt[-Log[Random[]]]) Cos[6.28319 Random[]];

Clear[MonteCarloVAR];
\(\(MonteCarloVAR[n_, Port_, \ S01_, \ S02_, \ 
          r_, σ1_, \ σ2_, \ ρ_, \ τ_] := 
	
        Module[{sum = 0, sum2 = 0, ST1, \ ST2, \ term, MCestimate, 
            variance, \ η1, \ η2, \ ϵ1, \ ϵ2, \ 
            fac, \ oldPrices, \ newPrices, \ delPrices, \ 
            delList\  = \ {}}, 
		fac\  = \ \@\(1\  - \ ρ\^2\); \ 
		oldPrices\  = \ Apply[Port, \ {S01, \ S02}]; 
		For[i = 1, 
            i ≤ 
              n, \(i++\), 			
		\ \ \ \ \ \ \ \ \ η1\  = \ 
              RandNormal[]; 
		\ \ \ \ \ \ \ \ \ η2\  = \ 
              RandNormal[]; 			
			ϵ1\  = \ η1\ ; 
			ϵ2\  = \ \ η1\ ρ\  + \ η2\ fac; 
			ST1 = 
              S01\ \ GeoBrownianMotion[
                  r, σ1, τ, ϵ1]; 
			ST2 = 
              S02\ \ GeoBrownianMotion[
                  r, σ2, τ, ϵ2]; 
			newPrices\  = \ \ Apply[Port, \ {ST1, \ ST2}]; 
			delPrices\  = \ 
              newPrices\  - \ oldPrices; 
			AppendTo[delList, \ 
              delPrices]]; \ 
	
	delList];\)\)

As a first example, we consider a portfolio of two stocks, S1and S2. These equities have identical volatilities but initial values (or prices, if the volume of the assets are fixed) are S1=100 and S2=50.

Clear[Portfolio1];
Portfolio1[S1_,  S2_]  :=  {S1,  S2}

In the following calculation, the function MonteCarloVAR returns a list of the price changes for the two instruments of a time horizon of one day.

MonteCarloVAR[5,  Portfolio1,  100,  50,  0.05,  0.2,  0.2,  
      0,   1.0/365.0]

Below we define a second function ShowVaR that takes lists of pairs and constructs distribution functions and VaRs of each of the two instruments, as well as the sum of them -  the value change of the overall portfolio (Refer to III.2.1).

\(\(\(\(BLACK\  = \ RGBColor[0, 0, 0];\)

    \(RED\  = \ RGBColor[1, 0, 0];\)

    \(BLUE\  = \ RGBColor[0, 0, 1];\)

    \(\(GREEN\  = \ RGBColor[0, 1, 0];\)\(
\)
    \)

    \(Clear[ShowDist];\)

    ShowVaR[rawdata_, \ n_, \ varlevel_]\  := 
	
      Module[{xmin, \ xmax, \ xmin1, \ xmax1, \ xmin2, \ xmax2, xmin3, \ 
          xmax3, \ dx, \ bins1, \ bins2, \ bins3, \ xvals, \ lines1, \ 
          lines2, lines3, \ x1, \ y1, \ vline1, 
			x2, \ y2, \ vline2, 
          x3, \ y3, \ vline3, var, \ label, 
			data1, \ data2, \ 
          data3}, 
		data1\  = \ \((\(\((#[\([1]\)])\) &\)\ \  /@ \ 
                rawdata)\)\  // \ 
            Sort; 
		data2\  = \ \((\(\((#[\([2]\)])\) &\)\  /@ \ 
                rawdata)\)\  // \ Sort; 
		data3\  = \ 
          Table[rawdata[\([i, 1]\)]\  + rawdata[\([i, 2]\)], 
				{i, \ 
                1, \ Length[rawdata]}]\  // \ Sort; 
		xmin1\  = \ 
          data1[\([1]\)]; 	
        xmax1\  = \ data1[\([\(-1\)]\)]; 
		xmin2\  = \ data2[\([1]\)]; 	
        xmax2\  = \ data2[\([\(-1\)]\)]; 
		xmin3\  = \ data3[\([1]\)]; 	
        xmax3\  = \ data3[\([\(-1\)]\)]; 
		xmin\  = \ 
          Min[xmin1, \ xmin2, \ xmin3]; 
		xmax\  = \ 
          Max[xmax1, \ xmax2, \ xmax3]\ ; 
		xmax\  = \ 
          Max[xmax, \ Abs[xmin]]; 
		dx\  = \ 2\ xmax/n; 
		bins1\  = \ 
          BinCounts[data1, \ {\(-xmax\), \ xmax, \ dx}]; 
		bins2\  = \ 
          BinCounts[data2, \ {\(-xmax\), \ xmax, \ dx}]; 
		bins3\  = \ 
          BinCounts[data3, \ {\(-xmax\), \ xmax, \ dx}]; 
		x1\  = \ 
          data1[\([varlevel\ Length[
                  data1]]\)]; 		\ \ \ \ \ \ \ \ \ 
\ \ \ \ \ \ \ \ \ \ \ \ \ \ vline1\  = \ 
          Line[{{x1, \ \(-30\)}, \ {x1, \ 50}}]; 
		x2\  = \ 
          data2[\([varlevel\ Length[data2]]\)]; 
		vline2\  = \ 
          Line[{{x2, \ \(-30\)}, \ {x2, \ 50}}]; 
		x3\  = \ 
          data3[\([varlevel\ Length[data3]]\)]; 
		var\  = \ 
          x3; 		\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
	\ \ \ \ \ label = 
          ToString[
            StringForm["VAR = ``", 
              Abs[
                var]]]; 
\ \ \ \ \ \ \ \ \ \ \ \ \ \ vline3\  = \ Line[{{x3, \ \(-30\)}, \ {x3, \ 50}}]; 
		lines1\  = \ 
          Table[{xmin\  + \ dx/2. \  + \ dx\ \((i - 1)\), \ 
                bins1[\([i]\)]}, 
				{i, \ 1, \ n}]\  // \ 
            Line; 
		lines2\  = \ 
          Table[{xmin\  + \ dx/2. \  + \ dx\ \((i - 1)\), \ 
                bins2[\([i]\)]}, 
				{i, \ 1, \ n}]\  // \ 
            Line; 
		lines3\  = \ 
          Table[{xmin\  + \ dx/2. \  + \ dx\ \((i - 1)\), \ 
                bins3[\([i]\)]}, 
				{i, \ 1, \ n}]\  // \ 
            Line; 
		Show[
          Graphics[{RED, vline1, \ lines1, \ BLUE, \ vline2, \ 
              lines2, 
					\ BLACK, \ vline3, \ 
              lines3}, 
				\ Axes\  -> \ Automatic, \ 
            PlotLabel -> label]];]\)\(	\)\)\)

Now, We carry out a simulation of 2000 iterations.

vres  =  
        MonteCarloVAR[2000,  Portfolio1,  100,  50,  0.05,  0.2,  
          0.2,  0,   1.0/365.0];

Then we can take 20 pairs of data to construct the distribution of VARs of the two assets and the portfolio, and show the portfolio's 5%VAR.

ShowVaR[vres,  20,  0.05]

In this figure, the red curve is the distribution of price changes of the first instrument 1, the blue curve is for the instrument 2 and the black curve is for the portfolio. The vertical bars show the respective VaRs. The portfolio's VaR, S1 + S2, is printed in the graph.

REQUIRED
III.2.b  Change the value of the correlation of the two assets to ρ = -1  and 1,  respectively, and run the above simulation. How do you explain the results?

To illustrate the effect of nonlinear instruments, we consider, for the sake of simplicity, a portfolio of two instruments that depend only on the asset S1. We initially consider a simple portfolio consisting of two equal amount of (S1)/2.

Clear[Portfolio2];
Portfolio2[S1_,  S2_]  := {S1/2,  S1/2}

vres  =  
        MonteCarloVAR[2000,  Portfolio2,  100,  100,  0.05,  0.2,  
          0.2,  0,   1.0/365.0];
ShowVaR[vres,  20,  0.05]

Here, the blue curve exactly overlays the red curve. In the following example we give a comparatively more sophisticated nonlinear example.

As explained above, hedging is a widely used strategy for risk reduction. Here we give a simple example of hedging, in which the portfolio contains only two assets: a underlying asset, i.e a share of stock,  and a derivative asset, i.e a standard European call on the stock. When the delta is approximately 0.5, by writing (i.e selling) the call option at the price near the strike price, the holder of the portfolio can hedge half of the position in S1, but has to pay the price that there is no longer the possibility of substantial positive gains.

So, suppose the value of the stock is S1, the value of the call option can be expressed as "-EuroCall[S1, 100, 0.05, 0.0, 0.20,0.01]", where the function EuroCall is exactly the function Black-Scholes in II.3.2 and K = 100, σ = 0.2, r = 0.05, t = 0.0. Notice that he is the writer or seller, but not the buyer or holder of the call option, the same role as the car dealer above. Hence a " - ' is added in front of the function.

Clear[EuroCall]

d[S_, K_, σ_, r_, 
          t_] = (Log[S/K] + 
                r t)/(σ Sqrt[t]) -  .5 σ Sqrt[
              t];

    
d1[S_, K_, σ_, r_, t_] = 
        d[S, K, σ, r, t] + σ Sqrt[t];

    
Norm[z_?NumberQ] := 
        N[0.5 + 0.5 Erf[z/Sqrt[2]]];

    
EuroCall[S_, K_, σ_, r_, t_] = 
        S Norm[d1[S, K, σ, r, t]] - 
          K Exp[-r t] (Norm[
                d[S, K, σ, r, t]]);

The portfolio is constructed:

Clear[Portfolio3];
\(Portfolio3[S1_, \ 
        S2_]\  := 
	\ {S1, \ \(-EuroCall[\ S1, \ 100, \ 0.2, \ 0.05, \ 
            0.01]\)}\)

Now, We carry out a simulation of 2000 iterations.

vres  =  
        MonteCarloVAR[2000,  Portfolio3,  100,  100,  0.05,  0.2,  
          0.2,  0,   1.0/365.0];
ShowVaR[vres,  20,  0.05]

Here, the red curve is again the nearly normal distribution associated with the linear position in the underlying asset S1. The blue curve is the payoff distribution of the short position in the call option. The skewness of the distribution describes the highly nonlinear price change behavior of the call option near expiry. The black curve is the net position of the portfolio. In this case the VaR has been reduced, comparing with previous example. So writing the call as a hedge has indeed reduced the amount that can be lost under the same condition. 

This example illustrates an important point about the use of Monte Carlo simulation to estimate VaR. Although it is much more computation intensive than some other methods, we have  much more available information about the price behavior of the portfolio:  indeed, we have the distribution and sub-distributions of prices changes, and much more other information relevant to financial decision making.

REQUIRED
III.2.c  Now change the above portfolio to contain two assets: the same underlying asset and a put option on the asset. This time, however, the holder of the underlying asset buy the option. The pricing formula for a put option is presented in section I.3.3. Use the parametric values in the above hedging example to calculate the 5%VAR of the portfolio. What is your  comment on your result?

Appendix

A.1  The Derivation of Ito's Lemma

A completely rigorous derivation or proof of Ito's lemma is beyond the scope of this notebook. We now present a non-rigorous definition of Ito's lemma using the Taylor series formula. For a smooth function G(x, t), the normal Taylor series expansion goes as 

                                             ΔG = ((∂G)/(∂x))Δx +((∂G)/(∂t))Δt+ (1/2)(((∂^2) G)/(∂ (x^2)))Δ(x^2)+(((∂^2) G)/(∂ x ∂t))Δx Δt+(1/2)(((∂^2) G)/(∂ (t^2)))Δ(t^2)+···          (A.1)       
For a non-stochastic  process, when Δx → 0, Δt → 0, the above equation becomes

                                                                                dG =  ((∂G)/(∂x))dx+((∂G)/(∂t))dt          (A.2)                                                     
We now extend equation (A.2) to cover functions of variables following Ito processes. Suppose that a variable, x, follows the Ito process  

                                                                             dx=a(x, t)dt+b(x, t)dz          (A.3)                                                  
the discretised form of which is 

                                                                         Δx = a(x, 
              t) Δt + b(x, 
              t) ϵ (Sqrt[ Δ])t          (A.4)                                                                                                   
where ϵ is a standard normal variable. From this equation,

                                                     \(TraditionalForm\`Δx\^2 = \(\(a\^2\) Δt\^2 + 2  abϵΔt\^\(3\/2\) + \(b\^2\) \(ϵ\^2\) Δt = \(b\^2\) \(ϵ\^2\) Δt + 𝒪(Δt\^\(3\/2\))\)\)          (A.5)                             
This shows that the term involving Δ(x^2)in equation (A.1) has a component that is of order Δt and cannot be ignored.                                                          
The variance of a standardized normal distribution is 1. This means that 

                                                                                  E((ϵ^2)) - (([E(ϵ)])^2)= 1
Because E(ϵ) = 0, it follows that E ((ϵ^2)) = 1. The expected value of (ϵ^2)Δt is of order Δ(t^2)and that as a result of this, we can treat (ϵ^2) Δt as nonstochastic and equal to its expected value of Δt as Δt tends to zero. It follows from equation (A.5) that Δ(x^2)becomes nonstochastic and equals to (b^2) Δt as Δt  tends to zero. Taking limits as Δx and Δt tend to zero in equation (A.1), and using this last result, we obtain   

                                                                  dG =  ((∂G)/(∂x))dx+((∂G)/(∂t))dt+(1/2)(((∂^2) G)/(∂ (x^2)))(b^2)dt          (A.6)  
This is  Ito's lemma. Substituting for dx from equation (A.3), equation (A.6) becomes
 
                                                            dG =  (((∂G)/(∂x))a+((∂G)/(∂t))+(1/2)(((∂^2) G)/(∂ (x^2)))(b^2) )dt + ((∂G)/(∂x))bdz          (A.7)

A.2  The Derivation of Black-Scholes  Formula

There are several assumptions involved in the derivation of the Black-Scholes  formula:
(1) trading takes place continuously in time. (2) the riskless interest rate r is known and constant over time. (3) the asset pays no dividend. (4) there are no transaction costs in buying or selling the asset or the option, and no taxes. (5) the assets are perfectly divisible. (6) short selling (sale of a security not own by the seller) with full use of proceeds (funds given to a borrower after all costs and fees are deducted) is possible. (7) there are no riskless arbitrage (profiting from differences in price when the same asset is traded on two or more markets) opportunities.     
One common way of pricing a derivative is to form a self-financing,  replicating hedging strategy for it. Self-financing means that the portfolio produced by the strategy must not itself take up any money apart from a possible initial investment. As we will soon see, this initial investment will be the price of the security that the strategy is replicating. The term replicating means that the strategy must replicate the payoff of the security we are trying to price. Further, the portfolio produced by the strategy should always produce the same result regardless of price changes in the underlying security. In other words, the value of the portfolio generated by the strategy should be deterministic and cannot have a stochastic component (except for the stochastic components of the underlying securities of the derivative). This explains the term 'hedging' used for the strategy. 
The value of  a derivative is its expected future value discounted at the risk-free  interest rate. This is exactly the same result that we would obtain if we assumed that the world was risk-neutral.  In such a world, investors would require no compensation for risk. This means that the expected return on all securities would be the risk-free  interest rate. This is a very useful principle as it states that we can assume that the world is risk-neutral  when calculating option prices. The result would still be correct in the real world even if (as is most probably the case) it is not risk-neutral.
We derive the put-call  parity relation using this principle. To do so, use the fact that the sum of the payoff of a long call and a short put option with the same strike price and maturity (and, of course, on the same underlying securities) is given by S - K. Hence, the value of the call and put option is given by 

                                                 (e^(-r(T - t))) E[S  -  K ] = (e^(-r(T  -  t) ))(
          E[S]  -  K)  =  S  -  (Ke^(-r(T - t)))          (A.8)                         
the last equality coming from risk-neutral  valuation. This gives us 

                                                            C- P = S - K(e^(-r(T - t))) or C + K(e^(-r(T - t))) = P  +  S          (A.9)                              
We need one more piece of information before we can derive the Black-Scholes  formula. This is Ito's lemma: if a variable x follows a stochastic process of the form

                                                                              dx = a(x, t)dt + b(x, t)dz          (A.10)                                                                                          
then any smooth function G(x, t)  follows the process 

                                                           dG =  (((∂G)/(∂x))a+((∂G)/(∂t))+(1/2)(((∂^2) G)/(∂ (x^2)))(b^2))dt + ((∂G)/(∂x))bdz          (A.11)                                                                                                                                       
We are now in a position to present a derivation of the Black-Scholes  formula. Review the Black-Scholes equation derived in Chapter III:               
                                                                                                                                                                                                                                                                                                            
                                                                        ((∂f)/(∂t))+rS((∂f)/(∂S))+(((σ^2) (S^2))/2)(((∂^2) f)/(∂ (S^2)))=rf          (A.12)                                                
We have shown in Chapter III that if  (dS/S)=σdz + μdt, then    

                                            ln((Subscript[S, t]))- ln((Subscript[S, 0]))=  σdz + (μ-(1/2)(σ^2))dt          (A.13)                                         
i.e,  S follows a lognormal distribution:
                                                                      lnS∼N[ln (Subscript[S, 0])+(ϕ-(((σ^2))/2)) t, σ (Sqrt[ t])]          (A.14)
The principle of risk-neutral  valuation implies that the present value of the option is the expected final value E [max ( S-K,  0 )] of the option discounted at the risk-free  interest rate. So, we have                                                                                                                                                                                                  
                                                  c = (e^(-r(T - t))) E [max(S - K,  0)]  = 
            (e^(-r(T - t))) (∫_K^∞)(S - 
                      K) g(S) dS          (A.15)                          
where g(S), the probability density function  is given by (A.14) which can be explicitly written as                          
                               
                                                         g(S) = (1/(σS(Sqrt[2  πt])))exp(-(((ln((S/((Subscript[S, 0])))))-(r-(((σ^2))/2)) (t^2))/(2  (σ^2) t )))          (A.16)                            
where μ has been replaced by r in accordance with the principle of risk-neutral   valuation. We can easily verify that this solution satisfies the principle of risk-neutral valuation by evaluating  E (S) = (∫_K^∞)Sg(S)dS=(Subscript[S, 0]) (e^rt). 
The value of the integral (A.15) can be found with a bit of algebraic manipulation and the Black-Scholes  formula for standard European call option is                                      

                                                                       c = SN(((Subscript[d, 1])) - K(e^(-r(T - t))) N((Subscript[d, 2]))          (A.17)
                                                                                                           
          where             (Subscript[d, 1])=((ln((S/K))+(r+(((σ^2))/2))(T- t))/(σ(Sqrt[T - t]))),    (Subscript[d, 2])=((ln((S/K))+(r-(((σ^2))/2))(T- t))/(σ(Sqrt[T - t])))=(Subscript[d, 1]) - σ (Sqrt[ T - t])                                                                                                                                                                                                                            
and N(x) is the cumulative standard normal distribution.

Reference

[1] Zvi Bodie, Robert C. Merton, Finance, Prentice Hall, 1997.
[2] John C. Hull, Options, Futures, & Other Derivatives, Prentice-Hall, 1999.
[3] Reuters, An Introduction to Derivatives, John Wiley & Sons Pte Ltd, 1998. 
[4] Y. K. Kwok, Mathematical Models of Financial Derivatives, Springer, 1998.
[5] Paul Wilmott, Jeff Dewynne, Sam Howison, Option Pricing, Oxford Financial Press, 1996.
[6] Martin Baxter, Andrew Rennie, Financial Calculus, An Introduction to Derivative Pricing, The Press Syndicate of the University of Cambridge, 1997.
[7] Kevin Dowd, Beyond Value at Risk, John Wile & Sons Ltd, 1998.
[8] Peter G. Zhang, Barings Bankruptcy and Financial Derivatives, World Scientific, 1995.
[9] Thomas Mikosch, Elementary Stochastic Calculus, with Financial in View, World Scientific, 1998.
[10] Albert N. Shiryaev, Essentials of Stochastic Finance, Facts, Models, Theory, World Scientific, 1999.
[11] A.G. Malliaris, W.A.Brock, Stochastic Methods in Economics and Finance, North-Holland Publishing company, 1982.
[12] Hal R. Varian, Computational Economics and Finance, Springer, 1996.
[13] Hal R. Varian, Economic and Financial Modeling with Mathematica, 1993.
[14] William Shaw, Modeling Financial Derivatives with Mathematica, Cambridge University Press, 1998.
[15] John Downes, Jordan Elliot Goodman, Dictionary of Finance and Investment Terms, Barron's, 1998.
[16] Tom Gladd, A "Hand on" Introduction to Financial Monte Carlo Simulation, Internet, 2000.
[17] Rongwen Wu, Options Pricing via Monte Carlo Simulation, Internet, 2000.
[18] Simon Benninga, Zvi Wiener, Value-At-Risk,   Mathematica in Education and Research, Vol.7,  No.4 1998. 
[19] Hans-Peter Deutche, Computational Methods in the Pricing and Risk Management of Modern Financial Derivatives, Computer Physics Communications 121-122 (1999).
[20] Mrakani Srikant, Option Pricing with Stochastic Volatility , Internet, 2000.
[21] Blake LeBaron, Agent Based Computational Finance: Suggested Reading and Early Research, Journal of Economic Dynamics & Control, 24(2000) 679-702.
[22] Jingtao Yao, Yili Li, Chew Lim Tan, Option Price Forecasting Using Neural Networks, Omega 28 (2000) 455-466.