# [Review Notes] Introduction to Financial Computing

Basic Financial Arithmetic
Simple and Compound Interest
Simple Interest :

TotalProceed=Principal×(1+interestrate?daysyear)
Compound Interest :

TotalProceed=Principal×(1+interestrate?daysyear)N
Interest Rate:

The period for which the investment/loan will lastThe absolute period to which the quoted interest rate applies The frequency with which interest is paid
Nominal and Effective Rates

1+effectrate=(1+nominalraten)n

-

effectiverate=(1+nominalraten)n?1

-

nominalrate=[(1+effectrate)1n?1]×n

Daily Compounding
-

Dailyequivalent=[(1+effectrate)1365?1]×365

Continuous Compounding
-

1+effectiverate=limx→∞(1+rcn)n=erc

?
Continuously compounded rate :

r=ln(1+i)

?
Nominal rate for a year :

i=er?1

Time Value of Money
ItemsShort-Term InvestmentLong-Term Investment
Future Value

FV=PV×(1+i×daysyear)

FV=PV×(1+i×daysyear)N

Present Value

PV=FV1+i×daysyear

PV=FV(1+i×daysyear)N

yield

yield=(FVPV?1)×yeardays

yield=(FVPV)1N?1

effective yield

effectiveyield=(1+yield×daysyear)yeardays?1

effectiveyield=(FVPV)365days?1

for simple invest :

yield=i

for compound invest :

yield=i×daysyear

-

PV=FV×DiscoutFactor

SimpleCompoundContinuous Compounding

FV=PV×(1+i×daysyear)

FV=PV×(1+i×daysyear)N

FV=PV×(ei×daysyear)

DF=11+i×daysyear

DF=(11+i×daysyear)N

DF=e?i×daysyear

- IRR

?
Internal Rate of Return
IRR : The one single interest rate used when discounting a series of future value to achieve a given net present value.
Example:
?????

Basic Financial Modeling

Money Market
TerminologyExplanation
EurodollerU.S. dollar-denominated deposits at banks outside of the U.S.
CouponInterest rate stated on an instrument when it is issued
Discount InstrumentAn instrument which does not carry a coupon is a “discount” instrument. Discount equals the difference between the price paid for a security and security’s par value.
Bearer / registeredA “bearer” security is one where the issuer pays the principal (and coupon if there is one) to whoever is holding the security at maturity.
Fixed Income SecurityMoney market instrument whose future cash flows have been contractually defined and can be determined in advance.
Yield to MaturityYTM is the rate of return that you would achieve on a fixed income security, if you bought it at a given price and held it to maturity
LIBOR, HIBORInterbank offered rate ? interest rate at which one bank offers money to another bank.
EurodepositRound-the-clock business spanning Singapore and Hong Kong, Bahrain, Frankfurt, Paris, London and New York

Eurodeposit

LIBOR
The rate dealers charge for lending money (they offer funds) LIBID
The rate dealers pay for taking a deposit (they bid for funds)In London, quote (offered rate ? bid rate), Other places, quote (bid rate ? offered rate)Rule: pay the higher rate for a loan, receive the lower for a deposit

DAY/YEAR Conventions

Interestpaid=interestratequoted×daysinperioddaysinyear
Most money markets use ACT/360
Interest rate on 360-day basis = Interest rate on 360-day basis

×360365
Exceptions using ACT/365:
Interest rate on 365-day basis = Interest rate on 365-day basis

×365360

International and domestic:
Sterling, Hong Kong dollar, Singapore dollar, Malaysian ringgit, Taiwan dollar, Thai baht, South African rand.Domestic (but not international):
Japanese yen, Canadian dollar, Australian dollar, New Zealand dollar
Money Market Instruments

InstrumentTermInterestQuotationCurrencySettlementRegistrationnegotiableIssuers
Time deposit / loan1 day to several years, but usually less than 1 yearusually all paid on maturityas an interest rateany domestic or international currencygenerally same day for domestic, 2 working days for internationalnono
Certificate of deposit (CD)generally up to one yearusually pay a couponas a yieldany domestic or international currencygenerally same day for domestic, 2 working days for internationalusually in bearer formyesBank
Treasury Bill (T-bill)generally 13, 26 or 52 weeksmostly non-coupon bearing, issued at a discountUS and UK a “discount rate” basis; most places on a true yield basisusually the currency of the countrybearer securityyesGovernment
Commercial Paper (CP)for US, from 1 to 270 days; usually very short-term for ECP, from 2 to 365 days; usually 30 to 180 daysnon-interest bearing; issued at a discountfor US, on a “discount rate” basis for ECP, as a yieldfor US, domestic US dollar;for ECP, any Eurocurrency but largely US dollarfor US, same day;for ECP, 2 working daysin bearer formyesCorporation
Bill of exchange / Banker’s acceptanceFrom 1 week to 1 year but usually < 6 monthsnon-interest bearing; issued at a discountfor US and UK, quoted on a “discount rate” basis elsewhere on a yield basismostly domesticavailable for discount immediately on being drawnnoneyes
Repurchase agreement (repo)usually for very short-termdifference between purchase and repurchase pricesas a yieldany currencyGenerally cash against delivery of the securityn/anoGovernment / Bank

CD - Pricing

Price=presentvalue

maturityproceeds=facevalue×(1+couponrate×couponperiod(days)year

Price=facevalue×(1+couponrate×couponperiod(days)year)1+interestrate×dayspurchasetomaturityyear
CD - Return

yield=(FVPV?1)×yeardays

yield=(salepricepurchaseprice?1)×yeardaysheld

yield=((1+interestratepurchase×dayspurchasetomaturityyear)(1+interestratesale×dayssaletomaturityyear)?1)×yeardaysheld
Discount rate quote

Price=FaceValue×(1?DiscountRate×daystomaturityyear)

Price=FaceValue1+yield×daystomaturitysyear

yield=discountrate1?discoutrate×daystomaturityyear

discountrate=yield1+yield×daystomaturitysyear

Forward Rate Agreements (FRAs)
Forward-forward
A cash borrowing or deposit which starts on one forward date and ends on another forward.The term, amount and interest rate are all fixed in advance.

forward?forwardrate=[(1+iL×dLyear)(1+iS×dSyear)?1]×yeardL?dS

L and S stand for longer and shorter period respectively

Forward Rate Agreements
off-balance sheet instrumentfix a future interest rateon the agreed date (fixing date), receives or pays the difference between the reference rate and the FRA rate on the agreed notional principal amountPrincipal is not exchangedSettles at the beginning of the period

His flow will therefore be : - LIBOR

+ LIBOR

- FRA rate

?????

net cost : - FRA rate

Usually two days before the settlement date, the FRA rate is compared to the agreed reference rate (LIBOR).

Settlement Paid

settlementpaid=interestamountdiscountrate

- Period < 1year

- Period > 1year

FRAsettlement=Principal×(f?L)×d1year1+×d1year+(f?L)×d2year(1+×d1year)×(1+×d2year)

Constructing a strip

The interest rate for a longer period up to one year =

[(1+i×d1year)×(1+i×d2year)×(1+i×d3year)×...?1]×yeartotaldays

Futures Contract
Futures
A contract in which the commodity being bought or sold is considered as being delivered (may not physically occur) at some future dateExchange traded (vs OTC in “forward”)Contract standardized by exchangePricing depends on underlying commodity
Quotation

Futuresprice=100?(impliedforwardinterestrate×100)

Futures & FRAs are in opposite directions :

Dealing
Open outcry
designed to simulate the transparency of open outcry
Clearing

Following the confirmation of a transaction, the clearing house substitutes itself as a counterparty to each user and becomes

Margin Requirements
Initial Margin

Collateral for each deal transactedProtect clearing house for the short period until position can be revaluedVariation (Maintenance) Margin

Marking to marketPaid daily based on adverse price movements
????????
Profit and Loss

Profit/los s on long position in a 3-month contract :

Profit/loss=numberofcontract×contractamount×pricemovement100×14

Hedging FRA with Futures
Settlement for FRA = Profit or loss on sold futures Hedge required is the combination of the hedges for each leg

`e.g.,? Sell 3x6 FRA + Sell 6x9 FRA, hence hedged by? Sell 10 June futures + Sell 10 Sept futures`
Imperfect FRA Hedging with Futures

Future contracts are for standardized amountFutures P&L are based on 90-day period rather than 91 or 92 days as in FRAFRA settlements are discounted but futures settlements are not.Future price when the Sept contract is closed out in June may not exactly match the theoretical forward- forward rate at that timeSlight discrepancy in dates.

Open Interest : number of purchases of contract not yet been reversed or “close out”
Volume : total number of contracts traded during the day
3v8 FRA:

3v6+(3v9?3v6)×daysin3v8?daysin3v6daysin3v9?daysin3v6

5v10 FRA:

3v8+(6v11?3v8)×daysinfixing5v10?daysinfixing3v8daysinfixing6v11?daysinfixing3v8

Arbitrage

Any must win strategy?

Interest Rate Swaps (IRS)
Definitions
A swap is a derivative in which two counterparties agree to exchange one stream of cash flows against another stream.These streams are called the legs of the swap.An interest rate swap is a derivative in which one party exchanges a stream of interest payments for another party’s stream of cash flows.

Hedging with FRA

Hedging with IRS

Characteristics of IRS
Similar to FRA

No exchange of principalOnly interest flows are exchanged and nettedDifferent from FRA

Settlement amount paid at the end of relevant period

?Motivation: win-win

Type of Swap
Coupon Swap
Party A pay fixed interest rate and receive floating interest rate from party BBasis Swap
Floating vs floating but on different rate basis
e.g.,
Index Swap
The flow in one / other direction are based on index
e.g.,

Valuation of Swap

Long Swap = + Long a Fixed rate bond - Floating rate borrowingSwap Value = + PV of Fixed leg cashflow - PV of floating leg cashflowSwap = NPV of Fixed leg cashflowAt inception, NPV = 0

NPV=?P+∑ni=1CiDi+PDn

NPV=0

Dn=(1?r∑n?1i=1tiDi)1+rtn
;

r=1?Dn∑ni=1tiDi

where:

P = hypothetical principal notional

ti
= day count fraction of each interest payment period i

Ci
= cashflow at time period

i=P×r×ti

Di
= discount factor at time i

Dn
= discount factor at time n. (e.g., at maturity)

r = swap par rate (fixed leg)

Construction of Yield Curve
Definitions
The relationship of interest rate for different maturityMarket rate of interest for:

theoretical zero coupon instrumentmatures at any future dateDerived from

prices of real financial instrumenttrade in a liquid market
Type
Curve Shape

positivenegativeflatCurve Categories

Par Yied CurvesZero Coupon Yield CurveForward Rate Yield Curve
Example

forward rate =

(100D2100D1?1)×yearperiod=(D1D2?1)×yearperiod

Therefore,

D2=D11+forwardrate×periodyear

Base on that and construct further, and this formula use again & again to construct the yield curve.

Quick Recap
Over night

DON=11+RON(1365)

DTN=DON1+DTN(1365)

Money Market

D=11+r×t

r=[1D?1]×1t

e.g.,

DF3M=11+r3M×t3M

FRA

r=DS?DEDE×t

DE=DS1+rt

where,

DS
: Discount factor on forward start date

DE
: Discount factor on forward maturity date

t : period of FRA

r : FRA forward rate

SWAP Valuation

NPV=?P+∑ni=1CiDi+PDn

NPV=0

Dn=(1?r∑n?1i=1tiDi)1+rtn
;

r=1?Dn∑ni=1tiDi

(点与点之间可以通过一次函数求解)

Zero Coupon Rate

Dt=1(1+ZCt)days/year

ZCt=(1Dt)1days/year?1

Options
Options Basic

Options:
gives the buyer the right to buy or sell a specified quantity of an underlying asset at a specific price (premium) within a specified period of time.

Terminology

TerminologyExplanation
Strike price / Exercise pricePrice at which the option buyer has the right to buy or sell the underlying
ExpirationDate on which the holder / buyer of the option loses the right to buy or sell
PremiumThe amount paid by the option buyer to the option writer for the right
ExerciseProcess of deciding and advising option seller of intention to exercise the right under the option
In the moneyIt is likely that the option will be exercised based on current underlying market price (e.g.,65 ?>68)
Out of moneyIt is unlikely that the option will be exercised based on current underlying market price(e.g.,65 ?>62)
At the moneyThe strike price of option is equal to the current underlying market price
Call optionOption buyer has the right to buy the underlying (prise rise)
Put optionOption buy has the right to sell the underlying (pride fall)

Feature of Option

Exercise style

European option : An option that can only be exercised on the day of expiryAmerican option: An option that can be exercised at anytime from the date of purchase until it expires (More expensive)Option Exercise Settlement

Physical Settlement : the option is actually delivered with the underlying. The option seller of the option must deliver to the buyer of the option with the pre- defined amount of underlyingCash Settlement : cash is settled for the difference between the underlying market price and the option strike priceOTC vs Exchange

OTC:(over the counter)
customized contacts between 2 counterparties Exchange Trade Contract
The standardized contracts listed in Exchange
Margin call system with daily mark-to-market
Exchanges include: SIMEX, LIFFE, CBOT, CME , etc
Option Price

Popt=∑Pstock×Prob(P)?X
; where x = Strike

Option Price = Intrinsic Value + Time value

Intrinsic Value

Call option : Intrinsic value = Underlying price ? Strike pricePut option : Intrinsic value = Strike price ? Underlying priceTime Value

Time value = option price ? Intrinsic valueThe risk that the option will move in the money before expiry
StateCallPutRemarks
In-the-moneyX < SX > SIntrinsic Value > 0
At-the-moneyX = SX = SStrike price = Underlying security price
Out-of-the-moneyX > SX < SIntrinsic Value = 0 (?Have the right to exist)
Intrinsic ValueMax (0, S ? X)Max (0, X ? S)

where
X = Strike / Exercise price;
S = Underlying asset price

Complex Strategy

Strangles
Long Strangles: buying a call and put at different strike (call strike > = put strike)

Option Pricing
Put Call Parity Relationship

The arbitrage relationship which links European options markets to cash markets.
X = Option strike price
T = Time to maturity

ST
= Stock price at maturity (or forward price)
1. Alternative 1: C + long Bond PV(X)
Buy 1 Call (C) with strike X and long Bond at PV of strike X.

?

ST
< X

ST
> X
Long Call0

ST?X
PV(X)XX
Total Payoff at TX

ST

2. Alternative 2 : P＋

S0

Long Put (P) with strike X and long Physical Stock at

S0

?

ST
< X

ST
> X
Long Put

X?ST
0
PV(X)

ST

ST
Total Payoff at TX

ST

Both alternatives have same payoff at T
Therefore, to avoid arbitrage at

T0
,

C+BorrowingPV(X)=P+S0

or

C?P=S0?BorrowingPV(X)

or

C?P=S0?Xe?rT

or

C=P+S0?Xe?rT

?
Put-Call Parity

Binomial Model
Assumption

The stock price follows a random walkIn each time step, it has a certain probability of moving up or down by a certain amountArbitrage opportunities do not existIn the riskless portfolio, the return it earns must equal the risk-free interest rateBinomial Model Parameter

Input parameter
S = Current Stock Price
X = Stock Call Option Strike/Exercise Price
T = Option life expiration in year
σ = Volatility
r = Risk free interest rate
n = no. of steps in bonomial treeIntermediate calculated parameter
p = Risk neutral probability of up jump size
u = Up jump size (e.g.ΔS = 10%, u = 1.10)
d = Down jump size
?t = period interval in each binomial nodes = T/nTo estimate

f=Currentoptionprice

Generalization

?CurrentUp at TDown at T
Stock Price

S
Su

Sd
Derivative Price

f
fu

fd

where ? is Hedge Ratio

Then, Derivative Price
r = risk-free interest rate
PV of portfolio =

(SuΔ?fu)e?rT

Thus,

SuΔ?f=(SuΔ?fu)e?rT

f=e?rT[pfu+(1?p)fd]

where

p=e?rT?du?d

Thus,

SerΔt=pSu+(1?p)Sd

u=1d
condition by CRR
At last,

p=erΔt?du?d
;

u=eσΔt√
;

d=e?σΔt√

Black Sholes Model
Recall Ito’s Lemma

dx=a(x,t)dt+b(x,t)dz

If

G(x,t)
is some function of x and t,

dG=(?G?xa+?G?t+12?2G?x2b2)dt+?G?xbdz

Black Sholes Model

dS=μSdt+?Sdz

With

a=μS
,

b=?S
, applying to Ito’s Lemma, taking

G=C=max(ST?X,0)

we have

dC=(?C?SμS+?Cpartialt+12σ2S2?2C?S2)dt+?C?SσSdt??√

Option Greeks
DeltaGammaVegaThetaRho

Risk Management

There is no return without risk
- Market Risk
- Credit Risk
- Liquidity Risk
- Operational Risk
- Model Risk
- Settlement Risk
- Regulatory Risk
- Legal Risk
- Tax Risk
- Accounting Risk
- Sovereign and Political Risk