You are on page 1of 7

Derivative Financial Asset Pricing

Programming Design Final Project

Jhong-Yi, Huangand Huo, Wu


June 22, 2017

In the final project, our team wants to solve the simple finance engineering problem which often appears in the problem
set of investment course or introduction to finance engineering. However, not processing the computation by hand, we
want to design a simple program to help us to get the answer quickly. And hopefully, we can enhance our practical ability
to deal with the pricing of financial assets through this experience of programming design.

1 Physical Environment
Consider an economy that extends for three dates (t = 0, 1, 2) with 4 states of nature (1 , 2 , 3 , 4 ) and two long-lived
assets. The common information structure for investors is as follows. At t = 0, investors know that the true state is an
element of = {1 , 2 , 3 , 4 }. At t = 1, investors know whether the true state is an element of E = {1 , 2 } or an
element of E c = {3 , 4 }. At t = 2, investors know exactly which among 1 , 2 , 3 , 4 is the true state. The prices of
the two traded long-lived assets at each time-event node on the event tree correspond into the above information structure
are summarized in the following figure. For convenience, we denote these two assets as asset 1 and asset 2.
In this economy, the prices of two assets are determined by the Walarsian market, which satisfies the optimal decision
for all investors in the market and market-clearing conditions for all time and all states. Thus, we can take the prices of
two assets as exogenous variables. In addition, markets are dynamically complete1 and open at each time-event nodes, so
any other asset in the market can be priced by no-arbitrage principal.

(0, )

(1, E) (1, E c )

(2, 1 ) (2, 2 ) (2, 3 ) (2, 4 )

2 Problem Setting and Requirement


For simplicity, we assume that the two long-lived assets only generate cash flows at date 2 (e.g. Stocks only pay dividends
at t = 2.) and then the payoff of every assets at t = 2 can be seen as a vector in R4 , which depends on the state. Given
the following information structure of price of the two assets, we want to ask that if we introduce another derivative
financial asset into the market, what is the no-arbitrage price of it? And moreover, if the real price is deviated from our
calculation, what is our optimal strategy to get profit by trading this asset? The above two questions must be solved in our
programming algorithm.

fourth grade, Department of Economics, student ID: b02302133


fourth grade, Department of Economics, student ID:B02303041
1 In financial economics literature, we say the market is complete under the condition of uncertainty, which means that there exist sufficient trading

assets in the market so that every investor or consumer can realize his consumption plan for all time-event nodes at date 0. Here, we suppose the market
is dynamically complete, which means even though consumers cannot realize his consumption plan at date 0, he still can get his want by trading assets
at every time-event node. For simplicity, there must be consistency between the nature of state at every node and the number of assets having linearly
independent payoff vectors

1
In this project, we are going to design a program which can use the given information of elementary assets to solve
the price of derivative financial assets2 for all time-event nodes. The main assets are as follows:
Arrow-Debreu securities3 for the state belongs to = {1 , 2 , 3 , 4 } and zero coupon bond
European option including call option and put option set on the one unit of the specific elementary asset.
Forward contract and future contract set on the one unit of the specific elementary asset.
And if the real price of any asset is deviated from no-arbitrage price, we should find out the trading strategy for
arbitrage, which can be denoted as S = {s1 , s2 , sa }, where si is the holding strategy for asset i for all time-event nodes.

3 Finance Theory Basis


In order to explain our program designing, we need to propose a brief introduction to some core idea in asset pricing. It
might be helpful for those unfamiliar with financial theory. For simplicity, the number of state we consider here is just
two period; however, the number of state larger than two can be analyzed through the same concept as follows.
We first introduce the idea of binomial tree. Imagine there is an investor at t = 0) who wants to buy some stocks
of a certain company, but he does not know whether the company will pay dividends or not in the future at t = 1 (more
precisely, how much money will this company make in the future). In the binomial tree setting, we can simplify his
concern into only two possible states, where there is probability P (P is exogenous) that the company pays dividend 10
dollars (without loss of generality), and probability 1-P that the company pays no dividend. After the dividend payment,
the stock might be sold for 10 dollars in either states.
(These assumption might seem unrealistic, but again they are without generality.)
The following graphic shows how a binomial tree may look like4 :

(P) state 1 payoff = 10 + 10 = 20

investor, t = 0

(1-P) state 2 payoff = 0 + 10 = 10

Now the investor may want to know how much he should pay for the stock. Suppose now there are two other kinds of
asset with prices and possible payments as follows:

asset 1 asset 2
price state 1 state 2 price state 1 state 2
4.5 5 5 2 5 0

The investor may find out that if he buys 2 units of asset 1, and 2 units of asset 2, he will get exactly the same payoff
as the stock, denoted as the payoff vector (20, 10). Intuition tells us that the stock should worth 2 4.5 + 2 2 = 13
dollars. This is the No-Arbitrage Principle: assets with the same payoff vector should have the same price. If not, then
one can arbitrage: profiting from buying the cheap and selling the expensive.
Suppose now, a new asset with payoff vector (94, 87) needs pricing. One may find it difficult to replicate it with asset 1
and 2 (its undoubtedly possible, but complicated). Introducing the idea of Arrow-Debreu security helps a lot. Consider
the following two bundle of assets:
asset A : buy 0.2 units of asset 1, and sell 0.2 units of asset 2
asset B : buy 0.2 units of asset 2
Clearly, their payoff vectors are (0,1) and (1,0) respectively, and their prices (again using the no-arbitrage method) are 0.5
and 0.4 dollars. Asset A and B are now called the Arrow-Debreu securities - assets that pay 1 dollar in one state and 0 in
other states. With its help, the strange (94,87) asset can be easily priced: 87 * 0.5 + 94 * 0.4 =81.1. Actually, every asset
can be priced with the help of A-D securities.
Is pricing always so straightforward like this? Suppose now asset 1 does not exist. Then, the (0,1) A-D security may
never be replicated, and we call this scenario market incomplete - A-D security does not exist for each state. Facing
market incompleteness, no-arbitrage principle may not be applied, and the whole financial market lose efficiency.
Now we introduce an asset called zero-coupon bond - If we combined the two A-D securities together, we get an
asset paying (1,1), with price 0.9. Buying such an asset is just like saving 0.9 dollars now in the bank and getting 1 dollar
2 Formore information about derivative financial assets, please refer the following link: Chyi-Mei Chen, Investment Lecture 5, 8-12
3 Animaginary asset which only pays one unit of cash flow for some state and zero for the others at t = 2.
4 Most financial assets can be portrayed in binomial trees. For example, you dont know whether a bond will pay or not; you dont price will rise or

fall when you buy oil futures; you dont know whether you will be hit by a car when you buy insurance

2
back in the future. From this point of view, 1 / 0.9 is the risk-free rate or simply the interest rate, often denoted as
1 + rf . ( As it is commonly known, risk-free rate are often used as the time discount rate.)
The final assertion is that, though we construct the no-arbitrage pricing method from comparing asset 1 and 2 with
other assets, all of the above arguments, in fact, can be summarized as ( more precisely, stem from ) the Martingale Pricing
Theorem - every assets price is its own discounted expected payoff, and the expectation is taken using the martingale
probability. Examples may help us understand this idea better, and we first apply the assertion discounted expected
payoff to asset 1 and 2 as follows:

p 5 + (1 p) 5
4.5 =
1 + rf
p 5 + (1 p) 0
2=
1 + rf
Here, 1 + rf represent discounted, and its clear that were taking expectation of payoff, using some sort of proba-
bility p. Simple calculation gives us 1 + rf = 10 4
9 , and p = 9 . Then, applying this method to the stock, we get:

4 5
9 20 + 9 10
price of stock = 10 = 13,
9
exactly what we get by non-arbitrage method. There should be no surprise whatsoever, as these two concept implies each
other. (The most interesting part is that, this martingale probability p simply has nothing to do with the real world
probability P)
So far, what is needed to understand our algorithm is roughly provided. Next, let us explain the requirement of input
and output, and then come back to our three-period model.

4 Asset Pricing
1. Input
In order to construct derivative assets, we need to input the price of our two elementary assets for all state and all
time first, which can be shown as the following:
Please enter elementary asset 1:
1.75
1.1 2.2
1 1.48 3.3 1.1
Please enter elementary asset 2:
1
1.1 1.1
1.32 1.32 1.1 1.1

From first line to third line, the price of asset 1 would be shown as the non-negative float number.And from fourth
line to sixth line, the price of asset 2 would be shown as the non-negative float number, too.
Now, we need to decide what derivative assets we want to introduce. For example, if we want to know no-arbitrage
price for the zero-coupon bond, we should input character B into the command. The corresponding code to
derivative assets are as follows:

If the first character is A, it means that we want to compute the Arrow-Debreu security. And then we should
input an integer, which stands for the state we want to consider.
If the first character is B, it means that we want to compute the zero-coupon bond.
If the first character is C, it means that we want to compute the European call option. And then we should
input an integer, which stands for the elementary asset, and a float number, which stands for the exercise price.
If the first character is P, it means that we want to compute the European put option. And then we should
input an integer, which stands for the elementary asset, and a float number, which stands for the exercise price.
If the first character is G, it means that we want to compute the forward contract. And then we should input
an integer, which stands for the elementary asset.
If the first character is H, it means that we want to compute the future contract. And then we should input a
integer, which stands for the elementary asset.
2. Output
Hence, according to the above input, we need to show the price of specific derivative asset for all states and all time.
For example, if the input is:

3
B

then the output should be:


0.8712
0.8333 1
1 1 1 1

if the input is :
A
state : 4

then the output should be:


0.3409
0 0.5
0 0 0 1

where we print out the price of assets as the form of input.


3. Sample
Given the two elementary assets:
Please enter elementary asset 1:
1.75
1.1 2.2
1 1.48 3.3 1.1
Please enter elementary asset 2:
1
1.1 1.1
1.32 1.32 1.1 1.1

The output is:


E n t e r t h e i n f o r m a t i o n o f d e r i v a t i v e a s s e t or o t h e r s :
A
state : 1
0.0631
0.2777 0
1 0 0 0

B
0.8712
0.8333 1
1 1 1 1

C
o p t i o n s e t on : 2
exercise price : 1.1
0.0416
0.1833 0
0.22 0.22 0 0

P
o p t i o n s e t on : 2
e x e r c i s e price : 1.32
0.15
0 0.22
0 0 0.22 0.22

G
f o r w a r d c o n t r a c t s e t on : 1
2.0087
1.3200 2.2

H
f u t u r e c o n t r a c t s e t on : 1
1.98
1.3200 2.2

4
5 Trading Strategy
Now, given the two elementary assets, we know the no-arbitrage price for any derivative asset. However, if the real price
of the asset in the market at date 0 is deviated from our computation, there exists arbitrage space for trading the derivative
asset by replicating its payoff from the two elementary assets. Hence, we want to use the program to help us find out the
optimal trading strategy. Our goals are as follows:
Determine the replicating strategy for the two elementary assets for all time-event nodes.
Compute the arbitrage profit for selling or buying one unit of the given derivative asset and exercising the replicating
strategy.

1. Input
In order to make arbitrage profit, we need to input the real price of any derivative asset at date 0, which can be
shown as the following:
T A
state : 4
r e a l price : 0.5

The first charactor T means that we want to find out the optimal trading strategy for the required asset. From the
second charactor to the last two number are the same as our setting in the section Asset Pricing. The final number
means that we know the real price of the Arrow-Debreu security for state (2, 4 ) is 0.5 and we want to find the
replicating strategy for given elementary assets and get the arbitrage profit.
2. Output
Hence, according to the above requirements, we need to show the arbitrage profit and replicating strategy for time
node (0, ), (1, E) and (1, E c ). For example, if the input is :
T A
state : 4
r e a l price : 0.5

then the output should be:


Trading Strategy :
( 0 . 4 5 4 5 , 0.4545)
( 0 , 0 ) ( 0.4545 , 1 . 3 6 3 6 )
p r o f i t : 4.6590

From the first line to the second line, there are three parentheses, which correspond to time node (0, ), (1, E) and
(1, E c ) separately. In addition, the first number in the parenthesis stands for the unit of holding the asset 1, and the
second element in the parenthesis stands for the unit of holding the asset 25 . Finally, we need to output the arbitrage
profit in the last line6 .
3. Sample
Given the two elementary assets:
Please enter elementary asset 1:
1.75
1.1 2.2
1 1.48 3.3 1.1
Please enter elementary asset 2:
1
1.1 1.1
1.32 1.32 1.1 1.1

The output is:


T A
state : 1
r e a l price : 0.8
Trading Strategy :
( 0.2525 , 0 . 5 0 5 0 )
( 2.0833 , 2 . 3 3 5 8 ) ( 0 , 0)
p r o f i t : 0.7368
5 The number can be negative, which means we borrow others asset and sell it.
6 Inour framework of this economy, we can enhance or decrease our holding of this asset and exercise the replicating strategy to get infinite arbitrage
profit even though it cant be happened in the real world. For simplicity, we only consider the trading of one unit of derivative asset, and thus, the profit
is limited.

5
T B
real price : 1
Trading Strategy :
(0.1515 , 0.6060)
(0 , 0.7575) (0 , 0.9090)
p r o f i t : 0.1287

T C
o p t i o n s e t on : 2
exercise price : 1.1
r e a l price : 0.1
Trading Strategy :
( 0.1666 , 0 . 3 3 3 3 )
(0 , 0.1666) (0 , 0)
p r o f i t : 0.0583

T P
o p t i o n s e t on : 2
e x e r c i s e price : 1.32
r e a l price : 0.2
Trading Strategy :
( 0 . 2 , 0.2)
(0 , 0) (0 , 0 . 2 )
p r o f i t : 0.05

6 Programming Design
By the martingale pricing theorem mentioned above, two assets are needed to be basis for calculating martingale proba-
bilities and risk-free rates. The main function of class, variables and functions are explained as the following:
Class ElementaryAsset and DerivativeAsset : It is constructed to record all the informations about assets. This
class contains a dynamic array that records the price of this asset at each time-event nodes.
Variable double** martingaleProb and double** freeInterest : We calculate the martingale probabilities and
risk-free rates for all state and all time, and record them into a dynomic array.
Variable double** strategy : It is the holding of elementary assets 1 and 2 at each time node in order to replicate
the same payoff as the target asset.

Function solveMartingaleAndInterest : It is closed-form solutions of the martingale probabilities and risk-free


rates, which can then be easily obtained and recorded in the corresponding array.
Function solveReplicatingStrategy : It is closed-form solutions of the replicating strategy for the holding of ele-
mentary assets 1 and 2.

In our program, upon constructing a specific derivative asset, its payoff at t = 2 is immediately recorded in its price
structure. The constructor then computes time 1 and time 0 prices according to given martingale probabilities and risk-free
rates.
Another feature of our program is that we designed an algorithm to figure out arbitrage opportunity, and the trading
strategy to profit from it. The process of such algorithm is as follows: given an existing asset (called target asset) and
other information (eg. call option of elementary asset 1, with exercise price X and time 0 price Y), our program calls the
function solveReplicatingStrategy.
In the very beginning of our program, we input prices of two assets (record them in temporary dynamic arrays), and
declare them to be two ElementaryAsset. (The input of its constructor is dynamic array). All the arrays (risk-free rates,
martingale probilities, strategy) we use to restore information are then declared and initialized. The final step before
pricing is the computation of martingale probabilities and risk-free rates, which are done in functions described above.
A finite loop that involves input of order is then called into action. For pricing orders, a corresponding DerivativeAsset
is declared, and its price structure is printed out. For arbitraging order, otherwise, the target asset is corresponding
DerivativeAsset is declared and strategy is computed accordingly. Target asset is price structure, replicating strategy and
arbitrage profit are then printed out orderly.

6
7 Work Assignment and Reflection
Jhong-Yi, Huang Programming design and paper report
In the final project, I learn a lot from designing a project plan and realizing it with the group member. Since I am
sepecialized at Economics at NTU, I havent tried to make advantage of program to help me to solve problems. Especially
for this project, I combine with my knowledge from Investment and financial economics to model the price of financial
assets, which I never think I can complete before this course.
Huo, Wu Problem setting, algorithm design and presentation Frankly speaking, our program isnt complicated
whatsoever, but it does involves every aspect of this semesters curriculum. It is also a precious opportunity for me to
integrate economic studying - on which ive spent four years - with programming - something I had just started this
semester. Programming might not, though, be my future career, and I did not get hundred percent grasp of this course,
it is from this experience that I learned how helpful programming can be for both mass problem solving in my work and
trifles in my everyday life.

References
[1] Chyi-Mei Chen, Investment Lecture 5

[2] Hung-Jen Wang, Financial Economics Lecture Note

You might also like