Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을...

113
Financial Numerical Recipes in C++ C C + + + + 60 80 100 120 140 KOSPI200 0.2 0.4 0.6 0.8 잔존만기 0 20 40 60 옵션가격 60 80 100 120 140 KOSPI200 0.2 0.4 0.6 0.8 잔존만기 Bernt Arne Ødegaard PDF created with pdfFactory trial version www.pdffactory.com

Transcript of Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을...

Page 1: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

Financial Numerical Recipes in C++

CCC++++++ 프프프로로로그그그래래래밍밍밍을을을 이이이용용용한한한 금금금융융융수수수치치치해해해석석석

60 80 100120 140KOSPI200

0.20.4

0.60.8잔존만기

0

20

40

60

옵션가격

60 80 100120 140KOSPI200

0.20.4

0.60.8잔존만기

Bernt Arne Ødegaard

PDF created with pdfFactory trial version www.pdffactory.com

Page 2: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

1 ⓒ 2004, 홍창수

목차 / Contents

• 목차

• 서

• 현금흐름(cash flow)

현재 가치

내부 수익율(IRR)

해의 유일성의 확인

• 기본적인 옵션과 분석적 해(해석해)

o 개요

o 유럽형 콜과 풋 옵션:블랙-숄즈 분석

§ 유럽형·콜과 매각 선택권:블랙-숄즈 해석

§ 옵션가격의 분석:블랙-숄즈모형의 경우

§ 편미분으로 나타내지는 가격 지표

§ Δ (Delta)

§ Γ (Gamma)

§ Θ (Theta)

§ γ (Vega)

§ ρ (Rho)

§ Black Scholes 편미분의 컴퓨터 알고리즘

§ 내재변동성(implied volatility)

§ 이항근사에 의한 컴퓨터알고리즘

§ Newton-Raphson법에 따르는 컴퓨터 알고리즘

o 본원적 자산가치의 지불의 보정

§ 본원적 자산가치의 연속 지불

PDF created with pdfFactory trial version www.pdffactory.com

Page 3: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

2 ⓒ 2004, 홍창수

§ 배당

§ 배당이 있는 자산의 유럽형 옵션

o 미국형 옵션

§ 배당이 1번만 있는 미국형 콜옵션

• 이항모델에 의한 옵션 가격 설정

o 서 ,유럽형 옵션

§ 컴퓨터 프로그램 Computer algorithm.

o 미국형 옵션

o 헤지 파라미터의 추정

§ 델타(Delta)

§ 그 외의 헤지 파라미터

o 이항모형에 의한 추정과 배당

§ 비례 배당

§ 이산 배당

§ 이항모형에 의한 이산 배당 첨부의 가격 결정의 컴퓨터 프로그램

• 유한 차분법

o 유럽형 옵션

o 미국형 옵션

• 시뮬레이션

o 표본경로의 시뮬레이션

o 헤지 파라미터

• 근사

o Barone-Adesi-Whaley법에 따르는 미국형 션가격의 2차 근사

o Geske-Johnson법에 따르는 미국형 옵션 풋 가격의 근사

• 선물의 계산

PDF created with pdfFactory trial version www.pdffactory.com

Page 4: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

3 ⓒ 2004, 홍창수

o 선물의 가격 설정

o 선물옵션 (Options on futures)

§ Black 모형

§ 이항모형에 의한 추정

• 외국 통화 옵션의 계산

o 외국 통화 옵션

§ 유럽형 옵션

§ 미국형 옵션

• 채권 가격의 계산

o 채권 가격

o 만기수익률(YTM)

o 듀레이션

§ 단순 듀레이션

§ 맥콜레이·듀레이션

§ 수정 듀레이션

o 볼록성

• 이색옵션

o 룩 백 옵션

• 시뮬레이션에 의한 옵션 가격 설정의 일반적 접근

o 자산 가격의 시뮬레이션

o 손익구조의 정의

o 가격 설정

o 추정치의 개선·변수의 제어

• Black Scholes 형 공식의 대체 방정식

o Jump diffusion 모델

PDF created with pdfFactory trial version www.pdffactory.com

Page 5: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

4 ⓒ 2004, 홍창수

o 추계적 변동성(stochastic volatility)

• 평균 분산 분석

o 서

o 평균 분산 포트폴리오

o 공매도(short sales)의 제한 조건

• 기간 구조의 알고리즘

o 기간 구조의 계산

o 관측된 기간 구조의 이용

§ 선형 보간

§ 수익률의 선형 보간

§ 선도금리의 선형 보간

o 기간 구조의 추정

§ Nelson Siegel 함수형 (1987)

§ Bliss 모델 (1989)

§ 3차 스프라인

o 기간구조 모형(Term structure models)

§ Vasicek 모델

§ Cox Ingersoll Ross 모델

§ 할인율의 계산

§ 컴퓨터 프로그램

§ CIR 모델에 의한 추정

§ 할인율

• 고정 수익 모델링(조건부 청구권을 중심으로)

o Black Scholes 모형에 의한 bond pricing.

§ 컴퓨터 프로그램

PDF created with pdfFactory trial version www.pdffactory.com

Page 6: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

5 ⓒ 2004, 홍창수

o Rendleman Bartter 모델

§ 새로운 학습을 위해서

o Vasicek 모델

• 정규 분포의 근사치

o 레퍼런스

• C++에 관한 노트와 원시 코드

o 원시 코드의 입수

o 라이브러리

o 비C++프로그래머를 위한 C++해설

o 수학 기호

§ 지수함수

§ 증분·감 분

o 배열의 동적 정의

o for 스테이트먼트의 서식

o #include 의 구조

o 클래스의 개념

o 다른 언어에 있어서의 알고리즘 구현(implementation)

o 레퍼런스

• 사례

• 용어 색인

• 참고 문헌

PDF created with pdfFactory trial version www.pdffactory.com

Page 7: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

6 ⓒ 2004, 홍창수

서론 / Introduction

재무론 강의를 할 때 자주 질문받는 내용이 주어진 수치를 계산해주는 공식에 대해 많은 질문을 받는다.실제로 어떻게

계산하는지를 자신의 눈으로 확인하는 것은 매우 중요하다. 이 문서에서는, 금융에 사용되는 몇개의 알고리즘에 대해

실제로 어떻게 계산되는지를 설명하려고 시도하고 있다.그리고 그것을 컴퓨터의 서브루틴으로서 알고리즘을 구현해 보았다.

실제 프로그래밍 언어는 어떤것으로 실행해 보아도 상관없으나, 실제알고리즘을 시험해 볼 수가 없으면 의미가 없어,

필자는C++프로그래밍을 선택했다. 필자는 할 수 있는 한 개별 언어에 의존하지 않게 알고리즘을 범용적으로(generic)

기술하려고 노력했지만, 몇개의 알고리즘에 대해서는 새로운 C++의 STL (The Standard Template Library)를 이용할

필요가 있었다.그러나, 불행히도, 특히 금리의 기간 구조에 관한 알고리즘은 완전하게 범용적인 기술은 할 수 없는 것을

알았다.많은 금융 알고리즘에서는 기간 구조를 집어 넣은 현재 가치를 이용하고 있다.문제는 기간구조를

계산/추정/모델화할 방법이 상당히 많이 존재하는것이다.필자는 이 문제를 회피하기 위해서 클래스를 정의해 기간 구조의

기술을 추상화 했던 것이다.만약 클래스를 완전하게 기술하려고 하면 매우 긴 시간이 걸릴 것이 될 것이다.클래스에 관한

문서는 필자의 홈페이지로부터 입수할 수 있게 되어 있다.우선 알고리즘을 기록하고 나서,그것을 실행해보는 코드를 적고

있다.그러나 이것들은 강의를 위한 자료이며, 알고리즘의 정확성에 관해서는 보증 하기 힘들므로 주의 해주시길

바란다.또한, 보시면 알겠지만 이 문서는 결코 완성된 것이 아니고, 필자가 시간이 있을 때 서서히 추가 한 것 들이다.

이것은 기본적인 이론을 위한 교과서는 아니며, 기본이론서로는 많은 것들을 선택할수 있다. 그 중에서도 최선의 것은 Hull

(1993)의 책일 것이다.1본 문서에 있어서의 표기법(notation)도 Hull 책을 따르고 있다.

현금흐름(cash flow) / Cash flow algoritms.

재무론에(특히 프로젝트 평가등으로 자주 이용된다)에 자주나오는 몇개의 기본적인 계산을 알아보자.

Subsections

• 현재 가치

• 내부 이익율

o 해의 유일성의 확인

현재 가치 / Present value

현재 가치의 계산은 재무론에서의 기본적 계산중의 하나이다.현재 가치는 일련의 미래 지불액의 현시점에서의

가치이다. 할인율을 했을 때의 시각 에 있어서의 현금흐름(cash flow)를 로 해, 회의 현금흐름(cash flow)이,

시각 에 있어 발생하는 것으로 한다.이 때, 연속복리이면 현재 가치는 이하와 같이 계산된다.

1 John Hull교수의 책은 1993년 3판에 이어 꾸준한 업데이트가 진행되어 현재 최신판은 5판(2001)이 발행되어 있다.(역자주)

PDF created with pdfFactory trial version www.pdffactory.com

Page 8: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

7 ⓒ 2004, 홍창수

또 이 계산의 C++원시 코드는 아래와 같다.

// file cflow_pv.cc

// author: Bernt Arne Oedegaard.

#include <cmath>

#include <vector>

double cash_flow_pv( vector<double>& cflow_times, vector<double>& cflow_amounts, double r){

// calculate present value of cash flow, continous discounting

double PV=0.0;

for (unsigned int t=0; t<cflow_times.size() ;t++) {

PV += cflow_amounts[t] * exp( -r * cflow_times[t]);

};

return PV;

};

만일, 할인(discounting)이 이산적이라면 현재가치는 아래와 같이 계산된다.

이 원시 코드는 아래와 같다.

// file cflow_pv_discrete.cc

// author: Bernt Arne Oedegaard.

// calculate the present value of a stream of cash flows using discrete compounding

#include <cmath>

#include <vector>

PDF created with pdfFactory trial version www.pdffactory.com

Page 9: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

8 ⓒ 2004, 홍창수

double cash_flow_pv_discrete( vector<double>& cflow_times,

vector<double>& cflow_amounts,

double r){

double PV=0.0;

for (unsigned int t=0; t<cflow_times.size() ;t++) {

PV += cflow_amounts[t] / pow(1+r, cflow_times[t]);

};

return PV;

};

내부 수익율 / Internal rate of return.

현금흐름(cash flow)의 내부 수익율(IRR)은, 현금흐름(cash flow)의 현재 가치를 0으로 만드는 금리이다. 내부 수익률을

알기위해 아래 방정식의 근을 발견하면 된다.

그런데 ,Brealey and Myers (1996), Ross et al. (1996) or Sharpe and Alexander (1990)와 같은 금융분야의 기본적인

텍스트에서는 내부 수익율에는 얼마든지의 문제가 잠복하고 있는 것이 지적되고 있다. 즉, 많게는 상기의 방정식의 해가

복수 존재하고 있는 것에 유래한다.만약 내부 수익율이 1개인 것을 알고 있다면 이후에서 논할, 이분법(bisection)의

적용이 가장 간단하고 쉽다. 제9장으로 논해지고 있는 ,Press et al. (1992)의 방법의 한가지 적용이다. 다만 이 방법은 단

하나의 금리 발견하는것임에 유의하자. 만약 내부수익률이 복수의 해가 존재한다면, 할인율을 횡축에, 현재 가치를

세로축에 그래프를 그리고 판단하는 것이 가장 간단하고 쉬운 방법이 된다.

// file cflow_irr.cc

// author: Bernt A Oedegaard

#include <cmath>

#include <algorithm>

#include <vector>

#include "fin_algoritms.h"

const double ERROR=-1e30;

double cash_flow_irr(vector<double>& cflow_times, vector<double>& cflow_amounts) {

// simple minded irr function. Will find one root (if it exists. )

// adapted from routine in Numerical Recipes in C.

if (cflow_times.size()! =cflow_amounts.size()) return ERROR;

const double ACCURACY = 1.0e-5;

const int MAX_ITERATIONS = 50;

PDF created with pdfFactory trial version www.pdffactory.com

Page 10: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

9 ⓒ 2004, 홍창수

double x1=0. 0;

double x2 = 0.2;

// create an initial bracket, with a root somewhere between bot, top

double f1 = cash_flow_pv(cflow_times, cflow_amounts, x1);

double f2 = cash_flow_pv(cflow_times, cflow_amounts, x2);

int i;

for (i=0;i<MAX_ITERATIONS;i++) {

if ( (f1*f2) < 0.0) { break; }; //

if (fabs(f1) <fabs(f2)) { f1 = cash_flow_pv(cflow_times, cflow_amounts, x1+=1. 6*(x1-x2)); }

else {f2 = cash_flow_pv(cflow_times, cflow_amounts, x2+=1. 6*(x2-x1)); };

};

if (f2*f1>0. 0) { return ERROR; };

double f = cash_flow_pv(cflow_times, cflow_amounts, x1);

double rtb;

double dx=0;

if (f<0. 0) { rtb = x1; dx=x2-x1; }

else { rtb = x2; dx = x1-x2; };

for (i=0;i<MAX_ITERATIONS;i++){

dx *= 0.5;

double x_mid = rtb+dx;

double f_mid = cash_flow_pv(cflow_times, cflow_amounts, x_mid);

if (f_mid<=0. 0) { rtb = x_mid; }

if ( (fabs(f_mid) <ACCURACY) || (fabs(dx) <ACCURACY) ) return x_mid;

};

return ERROR; // error.

};

해의 유일성의 확인

만약 내부 수익률(IRR)의 해가 복수 존재할것인지가 염려된다면 아래에 나타내는 프로그램으로 체크하는것이 좋다. 해

유일하다라고 하는 것이(충분조건이 아니라) 필요 조건이니까, 만약[아래와 같은 프로그램의 실행 결과적으로]False가

돌아가라면, 아직 그 밖에 자주(잘) 정의된 내부 이익율이 있다고 이해해도 좋다. 최초의 테스트는 현금흐름(cash

flow)의 부호의 변화의 회수를 카운트 하는 것이다. 1번 밖에 부합이 변화하지 않으면 실수회는 다만 1개인 것을 알 수

있고 있기 때문이다. 만약 여러 차례 부호가 변화하면, 한층 더 진행된 테스트가 필요하다. (Norstrom (1972)나Berck and

Sydsæter (1995)를 참조. )

// file cflow_irr_test_unique.cc

PDF created with pdfFactory trial version www.pdffactory.com

Page 11: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

10 ⓒ 2004, 홍창수

// author Bernt A Oedegaard

#include <cmath>

#include <vector>

inline int sgn(double& r){ if (r>=0) {return 1;} else {return -1;}; };

bool cash_flow_unique_irr(vector<double>& cflow_times, vector<double>& cflow_amounts) {

// check whether the cash flow has a unique irr.

int sign_changes=0; // first check Descartes rule

for (unsigned t=1;t<cflow_times.size() ;++t){

if (sgn(cflow_amounts[t-1]) ! =sgn(cflow_amounts[t])) sign_changes++;

};

if (sign_changes==0) return false; // can not find any irr

if (sign_changes==1) return true;

double A = cflow_amounts[0]; // check the aggregate cash flows, due to Norstrom

sign_changes=0;

for (unsigned t=1;t<cflow_times.size() ;++t){

if (sgn(A) ! = sgn(A+=cflow_amounts[t])) sign_changes++;

};

if (sign_changes<=1) return true;

return false;

}

기본적인 옵션가격결정, 분석적 해(해석해) / Basic Option Pricing, analytical solutions.2

옵션의 가격 결정이나 그 도구에 대해서는 현실에의 금융 이론의 적용을 통해 획기적인 발전을 초래되어 왔다.Black and

Scholes (1973)나 Merton (1973)의 논문 발표 이후, 많은 실용적 이론적인 발전이 있어왔다. 이 장에서는, 원 논문에

근거해 옵션가격의 계산방법에 대해 논할 예정이다. 논의는 불충분할지도 모르지만, 표준적인 텍스트, 예를 들, Hull (1993)

등의 책으로 관련된 내용을 보충할 수 있을것이다.

Subsections

2 금융공학을 공부할 때 우리는 어떤종류의 모형을 금융시장에 사용할것인가를 결정해야한다. 여러 답이 나올수 있으나 연속시간

(continuos-time model ) 모형과 이산시간(discrete-time model) 모형, 두가지로 분류할 수 있다. 이산시간 모형의 장점은 이것을 연

구하거나, 실무에서 사용할 때 복잡한 수학을 사용하지 않는다는 점이다. 다른 한편, 연속시간 모형은 더 복잡한 수리적 지식을 요구한다.

연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간 모형으로 해를 도출할

수 있다. 연속시간 모형을 대표하는 모형으로는 Black-Scholes(1973)모형이 있고, 이산시간 모형을 대표하는 모형은 Cox, Ross, and

Rubinstein(1979) 모형이 있다. 실제적으로 이산시간 모형으로 계산된 옵션의 가치는 연속시간 모형으로 계산된 옵션가치에 수렴한다.

(“ 금융공학 의 이해” , ch 1. 금융공학개론, 홍창수, pp 3~4, unpublished manuscript)

PDF created with pdfFactory trial version www.pdffactory.com

Page 12: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

11 ⓒ 2004, 홍창수

• 개요

• 유럽형·콜과 풋옵션:블랙-숄즈 해석

o 유럽형·콜(매수 선택권)과 풋옵션(매각 선택권):블랙-숄즈 해석

§ 옵션가격의 분석:블랙-숄즈모델의 경우

o 편미분으로 나타내지는 가격 지표

§ Δ (Delta)

§ Γ (Gamma)

§ Θ (Theta)

§ γ (Vega)

§ ρ (Rho)

§ Black Scholes 편미분의 알고리즘구현

o 내재변동성(Implied volatility)

§ 이항근사에 의한 알고리즘구현

§ Newton-Raphson법 알고리즘 구현

• 기초자산 배당의 조정

o 본원적 자산가치의 연속 지불

o 배당

§ 배당이 있는 자산의 유럽형 옵션

• 미국형 옵션

o 1번만 배당이 있는 미국형·콜·옵션

§ Roll-Geske-Whaley call 공식 알고리즘구현

Subsections

• 옵션가격의 분석:블랙-숄즈 모형의 경우

• 편미분으로 나타내지는 가격 지표

o Δ (Delta)

PDF created with pdfFactory trial version www.pdffactory.com

Page 13: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

12 ⓒ 2004, 홍창수

o Γ (Gamma)

o Θ (Theta)

o γ (Vega)

o ρ (Rho)

o Black Scholes 편미분 알고리즘구현

• 내재변동성(Implied volatility)

o 이항근사에 의한 알고리즘 구현

o Newton-Raphson법 알고리즘 구현

유럽형 콜과 풋 옵션:블랙-숄즈 해석

콜(또는 풋)옵션은 그 보유자에게, 어느 기초자산을, 특정시점 또는 그 이전에, 특정의 가격 -권리행사 가격(the

exercise price)이라고 말한다-에서 사거나 팔수 있는 권리(의무는 아니다)를 주는 것을 말한다.만약 옵션이 유럽형이면

권리행사는 만기일(the maturity date)에 있어서만 가능하다.옵션이 미국형이면 만기일 이전의 임의의 시점에서 권리행사

가능하다. 여기에서는 아래와 같은 기호를 이용한다.

• : 기초자산 가격(예:주가)

• :권리행사 가격

• : 무위험 이자율

• :기초자산 가격의 표준 편차

• :현재 시점

• :만기일

• :만기까지의 시간(잔존만기)

만기일의 시점에서는 콜 옵션(매수 선택권)은 가치는 아래와 같다.

아울러, 풋옵션(매각 선택권)의 가치는 다음과 같다.

PDF created with pdfFactory trial version www.pdffactory.com

Page 14: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

13 ⓒ 2004, 홍창수

이것들은 편미분 방정식(PDE)3에 대한 경계조건으로 정의되기 때문에, 이 PDE를 풀면 원하는 옵션가격을 구할수 있다.

옵션가격의 분석:블랙-숄즈모형의 경우

경계 조건을 가진 PDE, 즉,

는 Black and Sholes에 의해 아래 함수형태의 해석 해(analytical solution)를 도출하였다.

여기서,

가 된다. 풋옵션의 경우도 아래와 같이 쓸 수 있다.

// file: black_scholes_call

// author: Bernt A Oedegaard

// Calculation of the Black Scholes option price formula.

3 PDE 즉, 편미분방정식은 옵션 가치평가에 있어서 중심이 된다. 옵션 가치를 계산하기 위한 편미분 방정식은 기초자산 가치와 옵션가치

가 시간의 변화에 따라 각각의 입력변수에 대해 서로 만족해야 한다는 조건을 나타내고 있다. 금융옵션에서 PDE전개는 주가가 지닌 불

확실성의 본질을 조심스럽게 정의하면서 생겨나기 시작했다. 금융옵션은 연속적으로 변화하는것을 모델링하며, 연속확률변수에 대한 연구

는 단지 주식시장에만 한정되는 것이 아니라 물리학에서도 중요한 의미를 가지고 있어 물리학에서의 Rocket scientist 가 금융분야로 활발하게 진출하게 하는 기반을 마련해주고 있다. (역자주)

PDF created with pdfFactory trial version www.pdffactory.com

Page 15: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

14 ⓒ 2004, 홍창수

#include <cmath> // mathematical library

#include "normdist.h" // this defines the normal distribution

double option_price_call_black_scholes( double S, // spot price

double X, // Strike (exercise) price,

double r, // interest rate

double sigma,

double time)

{

double time_sqrt = sqrt(time);

double d1 = (log(S/X) +r*time)/(sigma*time_sqrt) + 0.5*sigma*time_sqrt;

double d2 = d1-(sigma*time_sqrt);

double c = S * N(d1) - X * exp(-r*time) * N(d2);

return c;

};

편미분으로 표현한 가격 지표

옵션거래에서는 편미분으로 나타내지는 계수로 중요한 의미를 가지는 것이 몇개인가 있다.

델타 (Δ , Delta)4

옵션의 1차 편미분으로 나타내지는 지표는Δ (delta)로 불리는 것이다. 옵션 헤지에 중요하며, 많은 사람들이 이것을

이용한다.

델타는 빈번하게 사용되므로, 서브루틴으로 계산되도록 되어있다.

// file: black_scholes_delta_call.cc

4 식을 보면, 콜 또는 풋옵션의 가격을 기초자산의 가격으로 편미분 하고 있는 것이므로, 「기초자산의 가격이 변화했을 때, 옵션가격이 어

느 정도 변화하는가?」를 나타내고 있는 지표가 델타가 된다.이것을 이용하여, 기초자산의 변동에 대해서Δ 만큼 반대 매매를 해 두면, 기초자산의 손익을 옵션의 손익으로 상쇄할 수 있다. 이것을 「Δ 델타헤지(delta hedge)」라고 한다. (역자주)

PDF created with pdfFactory trial version www.pdffactory.com

Page 16: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

15 ⓒ 2004, 홍창수

// author: Bernt A Oedegaard

// The delta of the Black - Scholes formula

#include <cmath>

#include "normdist.h"

double option_price_delta_call_black_scholes(double S, // spot price

double X, // Strike (exercise) price,

double r, // interest rate

double sigma, // volatility

double time){ // time to maturity

double time_sqrt = sqrt(time);

double d1 = (log(S/X) +r*time)/(sigma*time_sqrt) + 0.5*sigma*time_sqrt;

double delta = N(d1);

return delta;

};

다른 지표는 좀처럼 사용되지 않지만, 그것들은 서로 관계가 있다.

감마(Γ , Gamma)5

옵션가격의 2차 미분으로 나타내지는 지표이다.콜에 대해서도 풋에 대해서도 같은 값이 된다.

쎄타(Θ , Theta)

옵션가격에 대한 만기까지의 시간(잔존만기, Time to maturity)에 관한 편미분 지표이다. 옵션가격은 시간의 경과와 함께

감소해 나간다(Time Decay). 즉, 그 감소 속도를 나타내는 지표가 쎄타가 된다.

5 델타(Δ )를 기초자산 가격으로 편미분 하고 있는 것이므로, 기초자산의 가격이 변화했을 때,델타(Δ )가 어느 정도 변할까」를 나타내고

있는 지표가 감마(Gamma)가 된다. 즉,「델타(Δ )헤지」에 있어 조정해야 할 속도를 나타내는 것이 델타라고 하면, 감마는 가속도가 된다.

실제로 변동성 매매(델타 헤지트레이딩/ Delta neutral trading)을 하는 옵션 딜러의 경우 델타의 수치(선물 환산델타등을 표기)를 가장 중

요하게 생각하나(일중매매시 델타 한도부여), 그 옵션 포트폴리오의 잠재적 위험은 감마값(오버나잇 매매시 한도부여)에 의해 결정된다. 아울러, 영업용 순자본비율 산정시에도 델타 플러스법을 이용하여 옵션 포지션의 위험을 계산하고 있다. (역자주)

PDF created with pdfFactory trial version www.pdffactory.com

Page 17: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

16 ⓒ 2004, 홍창수

베가(γ, Vega) 변동성(volatility)에 대한 편미분을 말한다. 즉, 변동성(volatility)의 변화에 대해서 옵션가격이 변동하는지를 나타내는

지표이다. 이것은 사람에 따라서 「카파」라고 부르는 경우도 있다. 그 경우는 「Κ」또는 「κ 」이다.

로(ρ, Rho)

로(rho)는 이자율에 대한 편미분이다.

Black Scholes 편미분의 컴퓨터 알고리즘

// black_scholes_partials_call.cc

// author: Bernt A Oedegaard

// The partial derivatives of the Black - Scholes formula

#include <cmath>

#include "normdist.h"

void option_price_partials_call_black_scholes( double S, // spot price

double X, // Strike (exercise) price,

double r, // interest rate

double sigma, // volatility

PDF created with pdfFactory trial version www.pdffactory.com

Page 18: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

17 ⓒ 2004, 홍창수

double time, // time to maturity

double& Delta, // partial wrt S

double& Gamma, // second prt wrt S

double& Theta, // partial wrt time

double& Vega, // partial wrt sigma

double& Rho){ // partial wrt r

double time_sqrt = sqrt(time);

double d1 = (log(S/X) +r*time)/(sigma*time_sqrt) + 0.5*sigma*time_sqrt;

double d2 = d1-(sigma*time_sqrt);

Delta = N(d1);

Gamma = n(d1)/(S*sigma*time_sqrt);

Theta =- (S*sigma*n(d1)) / (2*time_sqrt) - r*X*exp( -r*time) *N(d2);

Vega = S * time_sqrt * n(d1);

Rho = X * time * exp(-r * time) * N(d2);

};

내재변동성(implied volatility)

옵션 가격 결정의 공식을 계산하는 경우, 특히 블랙-숄즈 공식에서 계산하는 경우, 알수없는 변수는 기초자산 가격의 표준

편차뿐이다.공통의 문제는, 주어진 관측치로부터 변동성(volatility)을 계산하는 것이다 .예를 들면 시장에서 거래되고 있는

콜·옵션가격 이 주어지면 다음의 식을 만족시키는 변동성 (volatility) 인, 를 계산할 수가 있다. 이것이 시장에

내재되어 있는 변동성 즉, 내재변동성이다. 6

유감스럽게도 이 식으로부터 해를 도출하는 것은 곤란하며(no closed form solution), 수치적인 방법(numerical

method)으로 해를 도출하는 것이 효과적이다. 가장 단순한 방법은 이항근사로 탐색해 나가는 방법이다.

6 내재변동성과 관련하여 다른 변동성의 여러특징에 대해 살펴보기로 하자. 여기서는,변동성미소(volatility smile)에 대한 설명을 해보기로 한

다.블랙-숄즈공식에서 역사적변동성은 옵션의 잔존기간동안 일정하다고 가정한다.여기서 특정주식(예를들어, 삼성전자)대한 내재변동성 값

을 계산해보자.삼성전자에 대한 유럽형 콜옵션의 일 이론적으로 다른 행사가격의 옵션에 대한 내재변동성은 동일해야한다.그러나, 실제로

내재변동성은 각 행사가격마다 다른 패턴을 보여주고 있다. 이러한 현상에 대해 오랜기간동안 다양한 설명이 제기되고 있다. 한가지 기억할만한것으로는 옵션 매수자는 단지 주식의 역사적 변동성보다 더많은 시장정보를 가지고 있다는것이다.특정기업의 구체적인 정보를 이용

하여 그들은 더 정확한게 미래를 예측할 가능성이 있다.변동성 미소는 이러한 추가적인 직관을 반영하는것일수 있다.아울러, 변동성 미소

는기초자산의 수익률분포가 정규분포가 아닌 두터운 꼬리분포를 가지기 때문이다. (‘ 금융공학 의 이해’ , ch 9. 변동성 계산과 예측, 홍창

수, pp 102~103, unpublished manuscript)

PDF created with pdfFactory trial version www.pdffactory.com

Page 19: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

18 ⓒ 2004, 홍창수

내재변동성(IV)의 컴퓨터 알고리즘 (binomial search) / 이분법(bisection method)

// file black_scholes_imp_vol_bisect.cc

// author: Bernt A Oedegaard

// calculate implied volatility of Black Scholes formula

#include "fin_algoritms.h"

#include <cmath>

double option_price_implied_volatility_call_black_scholes_bisections(

double S, double X, double r, double time, double option_price)

{ // check for arbitrage violations:

// if price at almost zero volatility greater than price, return 0

double sigma_low=0.0001;

double price = option_price_call_black_scholes(S, X, r, sigma_low, time);

if (price>option_price) return 0.0;

// simple binomial search for the implied volatility.

// relies on the value of the option increasing in volatility

const double ACCURACY = 1.0e-5; // make this smaller for higher accuracy

const int MAX_ITERATIONS = 100;

const double HIGH_VALUE = 1e10;

const double ERROR = -1e40;

// want to bracket sigma. first find a maximum sigma by finding a sigma

// with a estimated price higher than the actual price.

double sigma_high=0.3;

price = option_price_call_black_scholes(S, X, r, sigma_high, time);

while (price < option_price) {

sigma_high = 2.0 * sigma_high; // keep doubling.

price = option_price_call_black_scholes(S, X, r, sigma_high, time);

if (sigma_high>HIGH_VALUE) return ERROR; // panic, something wrong.

};

for (int i=0;i<MAX_ITERATIONS;i++){

double sigma = (sigma_low+sigma_high)*0.5;

price = option_price_call_black_scholes(S, X, r, sigma, time);

double test = (price-option_price);

if (fabs(test) <ACCURACY) { return sigma; };

if (test < 0.0) { sigma_low = sigma; }

PDF created with pdfFactory trial version www.pdffactory.com

Page 20: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

19 ⓒ 2004, 홍창수

else { sigma_high = sigma; }

};

return ERROR;

};

Newton-Raphson법

이항근사에 의한 탐색방법 대신에, 실제 이쪽의 방법이 계산상의 속도가 빨라 사용 될수 있다.단일 변수의 방정식의 해

를 발견하는데 뉴턴-랩슨(Newton-Raphson)법을 사용할수 있다.

는 우리가 풀어야 할 방정식이다. 우선 초기치 를 줘서,

이 될 때까지 아래 작업을 반복하여 계산하면 된다.

여기서, 는 정확성의 허용도이다. 옵션의 경우 풀어야할 방정식은 다음과 같다.

여기서, 는 시장에서 관측된 옵션가격이며, 는 블랙-숄즈 방정식에 의한 값이다. 다음과 같은 반복식을

계산하면 된다.

뉴턴-랩슨(Newton-Raphson)법을 사용하기위해서는 옵션가격을 도출하는 것이 필요하다는 것에 주의할 필요가 있다. 블

랙-숄즈 공식은 널리 알려져 있어, 이 공식을 사용하면 된다. 그러나, 이항모형과 같은 공식의 가격결정에 대한 편미분

(greeks)은 계산하는 것이 쉽지않아, 단순 이분법(simple bisection)이 추천되는 알고리즘이다.

PDF created with pdfFactory trial version www.pdffactory.com

Page 21: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

20 ⓒ 2004, 홍창수

내재변동성(IV)의 컴퓨터 알고리즘 / 뉴튼-랩슨 방법(Newton steps)

// file black_scholes_imp_vol_newt.cc

// author: Bernt A Oedegaard

// calculate implied volatility of Black Scholes formula using newton steps

#include "fin_algoritms.h"

#include "normdist.h"

#include <cmath>

double option_price_implied_volatility_call_black_scholes_newton(

double S, double X, double r, double time, double option_price)

{

// check for arbitrage violations:

// if price at almost zero volatility greater than price, return 0

double sigma_low = 1e-5;

double price = option_price_call_black_scholes(S, X, r, sigma_low, time);

if (price > option_price) return 0.0;

const int MAX_ITERATIONS = 100;

const double ACCURACY = 1.0e-4;

double t_sqrt = sqrt(time);

double sigma = (option_price/S)/(0.398*t_sqrt); // find initial value

for (int i=0;i<MAX_ITERATIONS;i++){

price = option_price_call_black_scholes(S, X, r, sigma, time);

double diff = option_price -price;

if (fabs(diff) <ACCURACY) return sigma;

double d1 = (log(S/X) +r*time)/(sigma*t_sqrt) + 0.5*sigma*t_sqrt;

double vega = S * t_sqrt * n(d1);

sigma = sigma + diff/vega;

};

return -99e10; // something screwy happened, should throw exception

};

Further Reading

Newton-Raphson법에 대해서는 원시 코드는 Press et al. (1992) 의 9장에 있으므로 참조할 것.

PDF created with pdfFactory trial version www.pdffactory.com

Page 22: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

21 ⓒ 2004, 홍창수

3.3기초 자산가치에 대한 배당의 조정

Subsections

• 기초자산에 대한 연속 배당

• 배당

o 배당이 있는 자산의 유럽형 옵션

주식 이외의 금융적인 자산의 옵션을 고려하는 경우, 옵션의 이용 가능 기간중에 지불이 발생하는 일도 있다고 하는

사실을 인정할 필요가 있다.예를 들면 상품의 옵션을 취급하고 있으면, 본원적 자산을 구입하는 것으로 옵션을 헤지 하고

싶으면 보유비용이 필요하다.

3.3.1 기초자산에 대한 연속 배당

가장 단순한 것은, 연속적으로 지불을 하는 경우이다.유러피언 옵션을 평가하기 위해서는 블랙-숄즈 공식을 수정하면

충분한다. 를 본원적 자산에 대한 연속 지불액이라고 하자.이 때, 유러피언 콜과 풋의 가격은 이하의 식에서

주어진다.(Hull, 1997, pg 263를 참조할 것.)

다만,

으로 한다. 또 알고리즘의 구현은 다음과 같다.

// file: black_scholes_price_payout_call.cc

// author: Bernt A Oedegaard

// Calculation of the Black Scholes option price formula,

// special case where the underlying is paying out a yield of q.

PDF created with pdfFactory trial version www.pdffactory.com

Page 23: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

22 ⓒ 2004, 홍창수

#include <cmath> // mathematical library

#include "normdist.h" // this defines the normal distribution

double option_price_european_call_payout( double S, // spot price

double X, // Strike (exercise) price,

double r, // interest rate

double q, // yield on underlying

double sigma, // volatility

double time) { // time to maturity

double sigma_sqr = pow(sigma, 2);

double time_sqrt = sqrt(time);

double d1 = (log(S/X) + (r-q + 0.5*sigma_sqr) *time)/(sigma*time_sqrt);

double d2 = d1-(sigma*time_sqrt);

double call_price = S * exp(-q*time)* N(d1) - X * exp(-r*time) * N(d2);

return call_price;

};

3.3.2 배당

본원적 자산가치에의 지불이 배당인 특별한 경우가 있다.만약 배당으로 지불된다면, 가치가 바뀌어 버리기 때문에 계산

공식은 수정되지 않으면 안 된다. 연속배당의 경우는 취급이 간단하다.이것은 지금까지 봐 온 것 같은 연속 지불의 경우와

대응한다.문제는 많은 배당이 이산적으로 지불된다고 하는 점에 있다.

배당이 있는 주식에 대한 유럽형 옵션

기존의 배당의 유럽형 옵션에 대해서는, 단지 블랙-숄즈 공식에서 계산되는 본원적 자산의 현재가격으로부터 현재의

배당액을 줄이는 것만으로 좋다.

// file: bserudiv.cc

// author: Bernt A Oedegaard

#include <cmath> // mathematical library

#include "fin_algoritms.h" // define the black scholes price

#include <vector>

double option_price_european_call_dividends( double S,

double X,

double r,

double sigma,

double time_to_maturity,

PDF created with pdfFactory trial version www.pdffactory.com

Page 24: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

23 ⓒ 2004, 홍창수

vector<double>& dividend_times,

vector<double>& dividend_amounts )

// reduce the current stock price by the amount of dividends.

{

for (int i=0;i<dividend_times.size() ;i++) {

if (dividend_times[i]<=time_to_maturity){

S -= dividend_amounts[i] * exp(-r*dividend_times[i]);

};

};

return option_price_call_black_scholes(S, X, r, sigma, time_to_maturity);

};

Subsections

• 배당이 있는 경우의 미국 옵션의 평가식

o Roll-Geske-Whaley (RGW) 콜 공식

3.4미국형 옵션

미국형 옵션은 유럽형 옵션보다 취급이 어렵다. 이는 만기가 오기 전에 권리행사하는 것이 최적인 경우가 있을 수 있기

때문이다. 최적인 권리행사 정책은 옵션 가치에 영향을 주고, 권리행사 정책이 주어지고 처음으로 편미분 방정식을 풀 수가

있다. 그러므로에 일반적인 미국형 옵션의 해석해는 주어지지 않고, 특수해가 몇개인가 요구되고 있는 것만으로 있다.

미국의 콜 옵션을 위해서 지불을 가지고 있지 않은 자산 위에, 미국의 전화 가격은 유럽형과 비교해 같다, 지불이 없는

미국형 콜옵션은, 최적 권리행사 정책은 권리행사하지 않는 것이므로 유러피언·옵션과 같은 가격이 된다. 또 미국형

풋옵션(put option)에서는 조기에 권리행사해도 괜찮다. 주지의 미국형 옵션의 해석해는 주지의 배당를 지불하는 경우이며,

이것은 후에 논한다. 그 이외의 경우는 후의 장으로 설명하는, 이항근사나 편미분 방정식에 의한 수치해로 밖에 얻지

못하고 있다.

3.4.1주식이 1회만 배당될 때의 정확한 미국형 콜옵션 공식

배당을 지불하는 경우, 주가에 대한 콜 옵션은, 배당이 지불된 직후에 권리행사되는 것이 최적이겠지. 한 번만 배당을

지불하는 경우의 분석은 Roll-Geske-Whaley (RGW)에 의해 되고 있다. 최초의 정식화는Roll (1977)로 행해졌지만

이것에는 잘못이 있어,Geske (1979)로 부분적으로 정정되어 최종적으로는Whaley (1981)로 주어지는 형태에 침착하고

있다. 또Hull (1993)의 10장이나 참조하는 것. 덧붙여 여기에서는 이하의 기법을 이용한다.

• 주가

• 권리행사 가격

• :배당 지불 총량

PDF created with pdfFactory trial version www.pdffactory.com

Page 25: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

24 ⓒ 2004, 홍창수

• :배당 지불일

• :옵션 만기일

• :배당 지불까지 기간

• :만기까지의 기간 (잔존만기)

• 아메리칸·콜 가격

조기 권리행사의 경우, 이하와 같이 된다.

부등식이 성립하고 있다면 조기 권리행사는 최적해가 아니고, 이하의 식에서 주어진다.

다만, 는 통상의 블랙-숄즈 공식으로 한다.

반대로 등식이 성립하고 있다면, 미국형 콜의 가치를 주는 식은 이하와 같이 된다.

여기서,

PDF created with pdfFactory trial version www.pdffactory.com

Page 26: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

25 ⓒ 2004, 홍창수

이 때 하

된다.

Roll-Geske-Whaley call옵션 공식 알고리즘 구현(RGW)

// file anal_price_am_call_div.cc

// author: Bernt A Oedegaard

// calculate dividend adjusted formula for american call option.

#include <cmath>

#include "normdist.h" // define the normal distribution functions

#include "fin_algoritms.h" // the regular black sholes formula

double option_price_american_call_dividend(double S,

double X,

double r,

double sigma,

double tau,

double D1,

double tau1)

{

PDF created with pdfFactory trial version www.pdffactory.com

Page 27: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

26 ⓒ 2004, 홍창수

if (D1 <= X* (1.0-exp(-r*(tau-tau1)))) // check for no exercise

return option_price_call_black_scholes(S-exp(-r*tau1) *D1, X, r, sigma, tau);

double ACCURACY = 1e-6; // decrease this for more accuracy

double sigma_sqr = sigma*sigma;

double tau_sqrt = sqrt(tau);

double tau1_sqrt = sqrt(tau1);

double rho = - sqrt(tau1/tau);

double S_bar = 0; // first find the S_bar that solves c=S_bar+D1-X

double S_low=0; // the simplest: binomial search

double S_high=S; // start by finding a very high S above S_bar

double c = option_price_call_black_scholes(S_high, X, r, sigma, tau-tau1);

double test = c-S_high-D1+X;

while ( (test>0. 0)

&& (S_high<=1e10) ) {

S_high *= 2.0;

c = option_price_call_black_scholes(S_high, X, r, sigma, tau-tau1);

test = c-S_high-D1+X;

};

if (S_high>1e10) { // early exercise never optimal, find BS value

return option_price_call_black_scholes(S-D1*exp(-r*tau1), X, r, sigma, tau);

};

S_bar = 0.5 * S_high; // now find S_bar that solves c=S_bar-D+X

c = option_price_call_black_scholes(S_bar, X, r, sigma, tau-tau1);

test = c-S_bar-D1+X;

while ( (fabs(test) >ACCURACY)

&& ((S_high-S_low) >ACCURACY) ) {

if (test<0. 0) { S_high = S_bar; }

else { S_low = S_bar; };

S_bar = 0.5 * (S_high + S_low);

c = option_price_call_black_scholes(S_bar, X, r, sigma, tau-tau1);

test = c-S_bar-D1+X;

};

double a1 = (log((S-D1*exp(-r*tau1)) /X) +( r+0. 5*sigma_sqr) *tau)

/ (sigma*tau_sqrt);

double a2 = a1 - sigma*tau_sqrt;

double b1 = (log((S-D1*exp(-r*tau1)) /S_bar) + (r+0. 5*sigma_sqr) *tau1)

PDF created with pdfFactory trial version www.pdffactory.com

Page 28: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

27 ⓒ 2004, 홍창수

/ (sigma*tau1_sqrt);

double b2 = b1 - sigma * tau1_sqrt;

double C = (S-D1*exp(-r*tau1)) * N(b1)

+ (S-D1*exp(-r*tau1)) * N(a1, -b1, rho)

- (X*exp(-r*tau)) *N(a2, -b2, rho)

- (X-D1) *exp(-r*tau1) *N(b2);

return C;

};

Chapter4. 이항모형에 의한 옵션 가격 결정7

Subsections

• 서론

• 유럽형 옵션

o 컴퓨터 프로그램( Computer algorithm)

• 미국형 옵션

• 헤지 파라미터의 추정

o 델타(Delta)

o 그 외의 헤지 파라미터

• 이항모형에 의한 추정과 배당

o 비례 배당

o 이산 배당

§ 이항모델에 의한 이산 배당 첨부의 가격 결정 프로그램

7 이항모형(binomial model)은 주식, 선물, 통화등에 대한 미국형 옵션의 가격을 결정하는데 가장널리 사용되는 수치해석적 방법이다. 이항모

형을 포함하는 수치해석적 방법의 유용성은 Black-Sholes공식에 의해 해석 해(analytical solution)가 존재하는 유럽형 옵션의 가격을 결정하는

데 이용될수 있을뿐 아니라, 해가 존재하지 하지 않는-수치해(numerical solution)로 계산해야하는- 미국형 옵션이나 이색옵션등의 가격도 구할 수 있다는 점이다.(역자주)

PDF created with pdfFactory trial version www.pdffactory.com

Page 29: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

28 ⓒ 2004, 홍창수

4.1 서론

이항 접근법으로 옵션 가치를 평가하려면, 기초 옵션 가격은 임의의 시간으로 가격이 상승 또는 하강하는 과정(binomial

process)을 따른다고 가정한다.

무엇이 발생할수 있을지에 관해 생각할수 있는 방법은 옵션만기일에 기초자산 가격의 최종분포를 추정하는것이다. 이

트리의 각 노드에 대해 옵션 가치는 단순한 무재정 가정(arbitrage argument)을 이용해 계산할수 있다.. 이것은 옵션의

손익함수를 복제하기위해 무위험 차입과 위험 자산을 결합해서 포트폴리오를 구성하여 그 가격을 정할 수가 있다. 이

접근법으로 옵션 가격 결정을 하기 위해, 만기까지의 기간 을 기간차수 으로 명시화하여, 기간차수를 가진

이항트리를 사용하여 옵션을 계산하게된다. 주어진 변수 와 기간의 분할구간인 에 대해,

우리는 “ 위험 중립 확률(risk reutral probabilities)” 을 정의할수 있다.

S

uS

dS

udS

ddS

uuS

PDF created with pdfFactory trial version www.pdffactory.com

Page 30: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

29 ⓒ 2004, 홍창수

옵션가격을 발견하기 위해, 「역방향 계산(roll backwards)」를 실시한다. 노드 에 대해 시점에서 취할 수 있는

2개의 가능한 결과의 함수로써 콜옵션의 가격을 계산한다. 예를 들어 1 단계로 하면,

이므로, 시점 0 에 있어서 콜옵션 가격은,

가 된다.8 이항모델에 의한 옵션 가격 결정의 원 소스는 Cox et al. (1979)에 있다. 좋은 텍스트로서는Cox and Rubinstein

(1985) 과 Hull (1993)이 있다.

Subsections

• 컴퓨터 프로그램

8 위의 식은 현재의 옵션값 C는 미래의 옵션가격 uC 와 dC 를 p와 1-p로 가중평균하여 무위험이자율로 할인한 형태임을 알 수 있다.

그런데 가중치들의 합이 1 이므로 확률의 개념으로 해석할 경우 du CppC )1( −+ 는 만기시 옵션의 기대값이라 할 수 있다. 따라서

현재의 옵션 값은 미래옵션 값의 기대값을 무위험 이자율로 할인한 형태가 된다. 여기서 주의할 점은 미래옵션 값의 기대값을 구하면서 실

제의 기초자산의 움직임에 대한 투자자들의 기대확률을 사용한 것이 아니라 일중의 유사확률 p와 1-p만을 사용하였다는 점이다. 그리고

유사확률 p와 1-p는 다음과 같은 점에서 위험중립을 가정한 상태에서의 확률로 해석할 수 있다.이 접근법을 이용하여 옵션의 가치를 평

가하기 위해, 시간구간을 만기 (T-t)로 분리해서 기간 N을 명시화해야한다. 그리고 기간수를 가진 이항트리를 이용하여 옵션가격을 계산

한다. (역자주)

상승, ),0( XSuMaxCu −=

하락, ),0( XSMaxC dd −=

C0

PDF created with pdfFactory trial version www.pdffactory.com

Page 31: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

30 ⓒ 2004, 홍창수

4.2유럽형 옵션

유럽형 옵션에 대해서는 블랙숄즈모델에 의해 정확한 해를 얻을 수 있으므로 이항모형은 그다지 많이 이용되지

않는다.그러나 미국형 옵션의 경우,조기행사 여부에 관계없이 이항트리(binomial tree)의 구축이 유용하다.

컴퓨터 프로그램

이항모델의 컴퓨터 프로그램에는 다음와 같은 이점이 있다. 1개의 콜 옵션 벡터가 있으면 좋다. 시점과 시점의

2개의 값이 필요라고 생각하는 사람이 있을지도 모른다.(이하의 프로그램을 읽기 전에 스스로 어떻게 푸는지 내리 써 보면

좋다.) 그러나 트리의 가지가 재결합한다고 하는 사실을 이용하면 이 문제를 회피할 수 있다.어떻게 움직일까 확인해

주셨으면 한다.그것은 이항모델에 의한 옵션 가격 설정의 이해에 유용하다.

// file bin_eur_call.cc

// author: Bernt A Oedegaard

// calculate the binomial option pricing formula for an european call

#include <cmath> // standard mathematical library

#include <algorithm> // defining the max() operator

#include <vector> // STL vector templates

double option_price_call_european_binomial( double S, // spot price

double X, // exercice price

double r, // interest rate

double sigma, // volatility

double t, // time to maturity

int steps) // no steps in binomial tree

{

double R = exp(r*(t/steps)); // interest rate for each step

double Rinv = 1.0/R; // inverse of interest rate

double u = exp(sigma*sqrt(t/steps)); // up movement

double uu = u*u;

double d = 1.0/u;

double p_up = (R-d)/(u-d);

double p_down = 1.0-p_up;

vector<double> prices(steps+1); // price of underlying

prices[0] = S*pow(d, steps); // fill in the endnodes.

for (int i=1; i<=steps; ++i) prices[i] = uu*prices[i-1];

vector<double> call_values(steps+1); // value of corresponding call

for (int i=0; i<=steps; ++i) call_values[i] = max(0.0, (prices[i]-X)); // call payoffs at maturity

PDF created with pdfFactory trial version www.pdffactory.com

Page 32: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

31 ⓒ 2004, 홍창수

for (int step=steps-1; step>=0; --step) {

for (int i=0; i<=step; ++i) {

call_values[i] = (p_up*call_values[i+1]+p_down*call_values[i]) *Rinv;

};

};

return call_values[0];

};

4.3미국형 옵션

미국형옵션은 권리행사 가능성에 대해 유럽형 옵션과 다르다. 만기시 밖에 권리행사할 수 없는 유럽형 옵션과는 달라,

미국형 옵션은 언제라도 권리행사할 수 있다. 일반적으로 말하면 불행하게도 아메리칸 옵션에 대한 해석적인 해법은

없지만, 몇개의 조건의 아래에서는 해법이 발견되고 있다. 예를 들면 배당이 없는 이경우의 콜 옵션은 유러피언 옵션과

동등하게 된다. 미국형 옵션의 경우는 조기 행사를 허락하고 있으므로 이항모델에 의한 접근방법이 유효하다. 각 노드에

대해 다음의 기간의 가격을 이용해 가치를 계산해, 현시점에서 권리를 행사해야할 것인가의 확인을 실시한다.

// file bin_am_call.cc

// author: Bernt A Oedegaard

// calculate the binomial option pricing formula for an American call

#include <cmath> // standard mathematical library

#include <algorithm> // defining the max() operator

#include <vector> // STL vector templates

double option_price_call_american_binomial( double S, // spot price

double X, // exercice price

double r, // interest rate

double sigma, // volatility

double t, // time to maturity

int steps) { // no steps in binomial tree

double R = exp(r*(t/steps)); // interest rate for each step

double Rinv = 1.0/R; // inverse of interest rate

double u = exp(sigma*sqrt(t/steps)); // up movement

double uu = u*u;

double d = 1.0/u;

double p_up = (R-d)/(u-d);

double p_down = 1.0-p_up;

vector<double> prices(steps+1); // price of underlying

vector<double> call_values(steps+1); // value of corresponding call

prices[0] = S*pow(d, steps); // fill in the endnodes.

PDF created with pdfFactory trial version www.pdffactory.com

Page 33: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

32 ⓒ 2004, 홍창수

for (int i=1; i<=steps; ++i) prices[i] = uu*prices[i-1];

for (int i=0; i<=steps; ++i) call_values[i] = max(0.0, (prices[i]-X)); // call payoffs at maturity

for (int step=steps-1; step>=0; --step) {

for (int i=0; i<=step; ++i) {

call_values[i] = (p_up*call_values[i+1]+p_down*call_values[i]) *Rinv;

prices[i] = d*prices[i+1];

call_values[i] = max(call_values[i], prices[i]-X); // check for exercise

};

};

return call_values[0];

};

Subsections

• 델타(Delta)

• 그 외의 헤지 파라미터

4.4 헤지 모수(Greeks)의 추정

옵션가격과 같이, 항상 헤지 모수(parameter)도 계산해 두는 것이 필요하다. 이항모델은 이러한 경우 유효하다.

자세하게는 Hull (1993)의 14장을 참조하면될것이다. 또, 이하의 코드는 배당이 없는 경우이다.

델타(Delta)

델타: 기초자산에 대한 옵션가격의 미분

// file bin_am_delta_call.cc

// author Bernt Arne Oedegaard

#include <cmath>

#include <algorithm>

#include <vector>

double option_price_delta_american_call_binomial(double S,

double X,

double r,

double sigma,

double t,

int no_steps) // steps in binomial

{

PDF created with pdfFactory trial version www.pdffactory.com

Page 34: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

33 ⓒ 2004, 홍창수

vector<double> prices (no_steps+1);

vector<double> call_values (no_steps+1);

double R = exp(r*(t/no_steps));

double Rinv = 1.0/R;

double u = exp(sigma*sqrt(t/no_steps));

double d = 1.0/u;

double uu= u*u;

double pUp = (R-d)/(u-d);

double pDown = 1.0 - pUp;

prices[0] = S*pow(d, no_steps);

int i;

for (i=1; i<=no_steps; ++i) prices[i] = uu*prices[i-1];

for (i=0; i<=no_steps; ++i) call_values[i] = max(0.0, (prices[i]-X));

for (int CurrStep=no_steps-1 ; CurrStep>=1; --CurrStep) {

for (i=0; i<=CurrStep; ++i) {

prices[i] = d*prices[i+1];

call_values[i] = (pDown*call_values[i]+pUp*call_values[i+1]) *Rinv;

call_values[i] = max(call_values[i], prices[i]-X); // check for exercise

};

};

double delta = (call_values[1]-call_values[0])/(S*u-S*d);

return delta;

};

그 외의 헤지 파라미터(Other hedge parameters)

// file bin_part.cc

// author Bernt Arne Oedegaard

#include <cmath>

#include <algorithm>

#include "fin_algoritms.h"

void option_price_partials_american_call_binomial(double S, // spot price

double X, // Exercise price,

double r, // interest rate

double sigma, // volatility

double time, // time to maturity

int no_steps, // steps in binomial

double& delta, // partial wrt S

PDF created with pdfFactory trial version www.pdffactory.com

Page 35: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

34 ⓒ 2004, 홍창수

double& gamma, // second prt wrt S

double& theta, // partial wrt time

double& vega, // partial wrt sigma

double& rho) // partial wrt r

{

vector<double> prices(no_steps+1);

vector<double> call_values(no_steps+1);

double delta_t =(time/no_steps);

double R = exp(r*delta_t);

double Rinv = 1.0/R;

double u = exp(sigma*sqrt(delta_t));

double d = 1.0/u;

double uu= u*u;

double pUp = (R-d)/(u-d);

double pDown = 1.0 - pUp;

prices[0] = S*pow(d, no_steps);

for (int i=1; i<=no_steps; ++i) prices[i] = uu*prices[i-1];

for (int i=0; i<=no_steps; ++i) call_values[i] = max(0.0, (prices[i]-X));

for (int CurrStep=no_steps-1; CurrStep>=2; --CurrStep) {

for (int i=0; i<=CurrStep; ++i) {

prices[i] = d*prices[i+1];

call_values[i] = (pDown*call_values[i]+pUp*call_values[i+1]) *Rinv;

call_values[i] = max(call_values[i], prices[i]-X); // check for exercise

};

};

double f22 = call_values[2];

double f21 = call_values[1];

double f20 = call_values[0];

for (int i=0;i<=1;i++) {

prices[i] = d*prices[i+1];

call_values[i] = (pDown*call_values[i]+pUp*call_values[i+1]) *Rinv;

call_values[i] = max(call_values[i], prices[i]-X); // check for exercise

};

double f11 = call_values[1];

double f10 = call_values[0];

prices[0] = d*prices[1];

call_values[0] = (pDown*call_values[0]+pUp*call_values[1]) *Rinv;

call_values[0] = max(call_values[0], S-X); // check for exercise on first date

PDF created with pdfFactory trial version www.pdffactory.com

Page 36: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

35 ⓒ 2004, 홍창수

double f00 = call_values[0];

delta = (f11-f10)/(S*u-S*d);

double h = 0.5 * S * ( uu - d*d);

gamma = ( (f22-f21)/(S*(uu-1)) - (f21-f20)/(S*(1-d*d)) ) / h;

theta = (f21-f00) / (2*delta_t);

double diff = 0.02;

double tmp_sigma = sigma+diff;

double tmp_prices

= option_price_call_american_binomial(S, X, r, tmp_sigma, time, no_steps);

vega = (tmp_prices-f00) /diff;

diff = 0.05;

double tmp_r = r+diff;

tmp_prices = option_price_call_american_binomial(S, X, tmp_r, sigma, time, no_steps);

rho = (tmp_prices-f00) /diff;

};

Subsections

• 비례 배당

• 이산 배당

o 이항모형에 의한 이산 배당 첨부의 가격 설정의 컴퓨터 프로그램

4.5이항모형에 의한 추정, 배당

만기까지의 기간에 원자산에 대한 배당을 지불하는 주식이다면, 옵션의 지불 조건은 이 현금 지불을 반영하고 있지 않고,

배당 지불을 반영해 둘 필요가 있다.이항모델에서는 배당에 관한 보정은, 배당이 이산일까 비례일까에 따라서 다르다.

4.5.1비례 배당

비례 배당의 경우, 배당 지불일에 가격에 보정 계수를 걸치는 것만으로 좋다.이항트리에 있어서의 노드는 다시 결합해,

역방향 계산("rolling back") 을 사용할 수 있다.

// file bin_am_prop_div_call.cc

// author: Bernt Arne Oedegaard

// binomial option pricing adjusting for dividends.

#include <cmath>

#include <algorithm>

#include <vector>

PDF created with pdfFactory trial version www.pdffactory.com

Page 37: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

36 ⓒ 2004, 홍창수

#include "fin_algoritms.h"

double option_price_call_american_proportional_dividends_binomial(

double S,

double X,

double r,

double sigma,

double time,

int no_steps,

vector<double>& dividend_times,

vector<double>& dividend_yields)

// given a dividend yield, the binomial tree recombines

{

int no_dividends=dividend_times.size();

if (no_dividends == 0) // just take the regular binomial

return option_price_call_american_binomial(S, X, r, sigma, time, no_steps);

double R = exp(r*(time/no_steps));

double Rinv = 1.0/R;

double u = exp(sigma*sqrt(time/no_steps));

double uu= u*u;

double d = 1.0/u;

double pUp = (R-d)/(u-d);

double pDown = 1.0 - pUp;

vector<int> dividend_steps(no_dividends); // when dividends are paid

for (int i=0; i<no_dividends; ++i) {

dividend_steps[i] = (int)(dividend_times[i]/time*no_steps);

};

vector<double> prices(no_steps+1);

vector<double> call_prices(no_steps+1);

prices[0] = S*pow(d, no_steps);

for (int i=0; i<no_dividends; ++i) { prices[0]*=(1.0-dividend_yields[i]); };

for (int i=1; i<=no_steps; ++i) prices[i] = uu*prices[i-1]; // terminal tree nodes

for (int i=0; i<=no_steps; ++i) call_prices[i] = max(0.0, (prices[i]-X));

for (int step=no_steps-1; step>=0; --step) {

for (int i=0;i<no_dividends;++i) { // check whether dividend paid

if (step==dividend_steps[i]) {

for (int j=0;j<=step;++j) {

prices[j]*=(1.0/(1.0-dividend_yields[i]));

};

PDF created with pdfFactory trial version www.pdffactory.com

Page 38: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

37 ⓒ 2004, 홍창수

};

};

for (int i=0; i<=step; ++i) {

prices[i] = d*prices[i+1];

call_prices[i] = (pDown*call_prices[i]+pUp*call_prices[i+1]) *Rinv;

call_prices[i] = max(call_prices[i], prices[i]-X); // check for exercise

};

};

return call_prices[0];

};

4.5.2 이산 배당

문제는, 일정 금액을 배당으로서 지불하는 경우이다.이 경우는 2항트리는 재결합하지 않고, 트리의 가지의 수는

계산하는 것에 따라 극적으로 증가한다. 여기에 나타내는 재결합 없음의 알고리즘은, 배당 지불일까지의 이항트리를

구성해, 그 트리의 마지막 노드에 대해 배당과 배당 지불일까지의 잔여 기간을 수반하는 계산을 재귀적으로 호출한다.배당

지불일에 있어서의 옵션 가치의 계산은 지불기일전의 권리행사에 비 다투어진다.단순화 된 계산에 있어서의 재귀적인

방법(recursive method)은 계산 시간이 길게 걸린다.큰 이항트리 모델 물어 구두인가의 배당을 포함한 모델에서는 다대한

시간이 필요하다.그러한 경우는 재귀적 호출을 그만두면 빠르게 할 수가 있다.이것에 관해서는Hull, 1993, pg 347 을 봐라.

이항모형에 의한 이산 배당 첨부의 가격 결정 알고리즘

// file bin_am_div_call.cc

// author: Bernt Arne Oedegaard

// binomial option pricing adjusting for dividends.

#include <cmath>

#include <vector>

#include "fin_algoritms.h"

double option_price_call_american_discrete_dividends_binomial(double S,

double X,

double r,

double sigma,

double t,

int steps,

vector<double>& dividend_times,

vector<double>&

dividend_amounts)

// given an amount of dividend, the binomial tree does not recombine, have to

PDF created with pdfFactory trial version www.pdffactory.com

Page 39: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

38 ⓒ 2004, 홍창수

// start a new tree at each ex-dividend date.

// do this recursively, at each ex dividend date, at each step, call the

// binomial formula starting at that point to calculate the value of the live

// option, and compare that to the value of exercising now.

{

int no_dividends = dividend_times.size();

if (no_dividends == 0) // just take the regular binomial

return option_price_call_american_binomial(S, X, r, sigma, t, steps);

int steps_before_dividend = (int)(dividend_times[0]/t*steps);

double R = exp(r*(t/steps));

double Rinv = 1.0/R;

double u = exp(sigma*sqrt(t/steps));

double uu= u*u;

double d = 1.0/u;

double pUp = (R-d)/(u-d);

double pDown = 1.0 - pUp;

double dividend_amount = dividend_amounts[0];

vector<double> tmp_dividend_times(no_dividends-1); // temporaries with

vector<double> tmp_dividend_amounts(no_dividends-1); // one less dividend

for (int i=0;i<no_dividends-1;++i){

tmp_dividend_amounts[i] = dividend_amounts[i+1];

tmp_dividend_times[i] = dividend_times[i+1] - dividend_times[0];

};

vector<double> prices(steps_before_dividend+1);

vector<double> call_values(steps_before_dividend+1);

prices[0] = S*pow(d, steps_before_dividend);

for (int i=1; i<=steps_before_dividend; ++i) prices[i] = uu*prices[i-1];

for (int i=0; i<=steps_before_dividend; ++i){

double value_alive

= option_price_call_american_discrete_dividends_binomial(

prices[i]-dividend_amount,

X, r, sigma,

t-dividend_times[0], // time after first dividend

steps-steps_before_dividend,

tmp_dividend_times,

tmp_dividend_amounts);

// what is the value of keeping the option alive? Found recursively,

// with one less dividend, the stock price is current value

PDF created with pdfFactory trial version www.pdffactory.com

Page 40: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

39 ⓒ 2004, 홍창수

// less the dividend.

call_values[i] = max(value_alive, (prices[i]-X)); // compare to exercising now

};

for (int step=steps_before_dividend-1; step>=0; --step) {

for (int i=0; i<=step; ++i) {

prices[i] = d*prices[i+1];

call_values[i] = (pDown*call_values[i]+pUp*call_values[i+1]) *Rinv;

call_values[i] = max(call_values[i], prices[i]-X); // check for exercise

};

};

return call_values[0];

};

Chapter 5. 유한 차분법(Finite Difference Method)

이 방법은 주어진 미분 방정식을 수치 해석적으로 풀기 위해서 유한 차분에 근사 해 푸는 방법이다.자세한 설명은

Hull(1993) 의 14장을 참조할 것. 유한차분법은 암묵적 유한차분법(implicit finite differences ), 명시적

유한차분법(explicit finite differences)으로 나뉘어진다.

Subsections

• 유럽형·옵션

o 암묵적 유한차분법

o 명시적 유한차분법

• 아메리칸 옵션

o 암묵적 유한차분법

o 명시적 유한차분법

o 더자세한정보

Subsections

• 암묵적 유한차분법의 컴퓨터 프로그램

• 명시적 유한차분법의 컴퓨터 프로그램

5.1 유럽형 옵션

PDF created with pdfFactory trial version www.pdffactory.com

Page 41: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

40 ⓒ 2004, 홍창수

유럽형 옵션의 경우는 유한 차분법을 이용할 필요는 없지만, 비교의 목적으로 어떻게 계산이 이루어지는지를 나타내기

위해서 설명한다.

암묵적 유한차분법 (implicit finite differences)

이하의 소스는 Hull (1993, P.354) 의 책을 근거로 하고 있다.이 알고리즘 단순화 하기 위해 선형대수(linear algebra)를

사용하였다.

#include <cmath>

#include "newmat.h" // definitions for newmat matrix library

#include <vector> // standard STL vector template

#include <algorithm>

double option_price_put_european_finite_diff_implicit(

double S, double X, double r, double sigma, double time,

int no_S_steps, int no_t_steps)

{

double sigma_sqr = sigma*sigma;

// need no_S_steps to be even:

int M; if ((no_S_steps%2)==1) { M=no_S_steps+1; } else { M=no_S_steps; };

double delta_S = 2.0*S/M;

vector<double> S_values(M+1);

for (int m=0;m<=M;m++) { S_values[m] = m*delta_S; };

int N=no_t_steps;

double delta_t = time/N;

BandMatrix A(M+1, 1,1); A=0.0;

A.element(0,0) = 1.0;

for (int j=1;j<M;++j) {

A.element(j, j-1) = 0.5*j*delta_t*(r-sigma_sqr*j); // a[j]

A.element(j, j) = 1.0 + delta_t*(r+sigma_sqr*j*j); // b[j];

A.element(j, j+1) = 0.5*j*delta_t*(-r-sigma_sqr*j); // c[j];

};

A.element(M, M)=1.0;

ColumnVector B(M+1);

for (int m=0;m<=M;++m){ B.element(m) = max(0.0, X-S_values[m]); };

ColumnVector F=A.i() *B;

for(int t=N-1;t>0;--t) {

B = F;

F = A.i() *B;

PDF created with pdfFactory trial version www.pdffactory.com

Page 42: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

41 ⓒ 2004, 홍창수

};

return F.element(M/2);

};

명시적 유한차분법(explicit finite differences)

암묵적 유한차분법의 대체법으로서 명시적 유한차분법이 있다. 명시적 유한차분법 쪽이 계산이 빠르지만, 반드시

수렴되지 않는다는 문제점이 있다.이하의 소스는 Hull (1993, P.356) 을 근거로 하고 있다.

// findiff_exp_eur_put.cc

// author: Bernt A Oedegaard

#include <cmath>

#include <algorithm>

#include <vector>

double option_price_put_european_finite_diff_explicit(double S,

double X,

double r,

double sigma,

double time,

int no_S_steps,

int no_t_steps) {

double sigma_sqr = sigma*sigma;

unsigned int M; // need M = no_S_steps to be even:

if ((no_S_steps%2)==1) { M=no_S_steps+1; } else { M=no_S_steps; };

double delta_S = 2.0*S/M;

vector<double> S_values(M+1);

for (unsigned m=0;m<=M;m++) { S_values[m] = m*delta_S; };

int N=no_t_steps;

double delta_t = time/N;

vector<double> a(M);

vector<double> b(M);

vector<double> c(M);

double r1=1.0/(1.0+r*delta_t);

double r2=delta_t/(1.0+r*delta_t);

for (unsigned int j=1;j<M;j++){

a[j] = r2*0.5*j*(-r+sigma_sqr*j);

PDF created with pdfFactory trial version www.pdffactory.com

Page 43: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

42 ⓒ 2004, 홍창수

b[j] = r1*(1.0-sigma_sqr*j*j*delta_t);

c[j] = r2*0.5*j*(r+sigma_sqr*j);

};

vector<double> f_next(M+1);

for (unsigned m=0;m<=M;++m) { f_next[m]=max(0.0, X-S_values[m]); };

double f[M+1];

for (int t=N-1;t>=0;--t) {

f[0]=X;

for (unsigned m=1;m<M;++m) {

f[m]=a[m]*f_next[m-1]+b[m]*f_next[m]+c[m]*f_next[m+1];

};

f[M] = 0;

for (unsigned m=0;m<=M;++m) { f_next[m] = f[m]; };

};

return f[M/2];

};

Subsections

• 암묵적 유한차분법의 컴퓨터 프로그램

• 명시적 유한차분법의 컴퓨터 프로그램

• 새로운 학습을 위해서

5.2 미국형 옵션

유럽형 옵션과 같은 알고리즘으로 소스를 나타내므로 각각의 포인트로 비교해 주었으면 한다.

암묵적 유한차분법의 컴퓨터 프로그램

#include <cmath>

#include "newmat.h" // definitions for newmat matrix library

#include <vector>

#include <algorithm>

double option_price_put_american_finite_diff_implicit(

double S, double X, double r, double sigma, double time,

int no_S_steps, int no_t_steps)

{

double sigma_sqr = sigma*sigma;

PDF created with pdfFactory trial version www.pdffactory.com

Page 44: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

43 ⓒ 2004, 홍창수

// need no_S_steps to be even:

int M; if ((no_S_steps%2)==1) { M=no_S_steps+1; } else { M=no_S_steps; };

double delta_S = 2.0*S/M;

double S_values[M+1];

for (int m=0;m<=M;m++) { S_values[m] = m*delta_S; };

int N=no_t_steps;

double delta_t = time/N;

BandMatrix A(M+1, 1,1); A=0.0;

A.element(0,0) = 1.0;

for (int j=1;j<M;++j) {

A.element(j, j-1) = 0.5*j*delta_t*(r-sigma_sqr*j); // a[j]

A.element(j, j) = 1.0 + delta_t*(r+sigma_sqr*j*j); // b[j];

A.element(j, j+1) = 0.5*j*delta_t*(-r-sigma_sqr*j); // c[j];

};

A.element(M, M)=1.0;

ColumnVector B(M+1);

for (int m=0;m<=M;++m){ B.element(m) = max(0.0, X-S_values[m]); };

ColumnVector F=A.i() *B;

for(int t=N-1;t>0;--t) {

B = F;

F = A.i() *B;

for (int m=1;m<M;++m) { // now check for exercise

F.element(m) = max(F.element(m), X-S_values[m]);

};

};

return F.element(M/2);

};

명시적 유한 차분법의 컴퓨터 프로그램

// file: findiff_exp_am_put.cc

// author: Bernt A Oedegaard

#include <cmath>

#include <algorithm>

#include <vector>

double option_price_put_american_finite_diff_explicit( double S,

double X,

PDF created with pdfFactory trial version www.pdffactory.com

Page 45: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

44 ⓒ 2004, 홍창수

double r,

double sigma,

double time,

int no_S_steps,

int no_t_steps) {

double sigma_sqr = sigma*sigma;

int M; // need M = no_S_steps to be even:

if ((no_S_steps%2)==1) { M=no_S_steps+1; } else { M=no_S_steps; };

double delta_S = 2.0*S/M;

vector<double> S_values(M+1);

for (int m=0;m<=M;m++) { S_values[m] = m*delta_S; };

int N=no_t_steps;

double delta_t = time/N;

vector<double> a(M);

vector<double> b(M);

vector<double> c(M);

double r1=1.0/(1.0+r*delta_t);

double r2=delta_t/(1.0+r*delta_t);

for (int j=1;j<M;j++){

a[j] = r2*0.5*j*(-r+sigma_sqr*j);

b[j] = r1*(1.0-sigma_sqr*j*j*delta_t);

c[j] = r2*0.5*j*(r+sigma_sqr*j);

};

vector<double> f_next(M+1);

for (int m=0;m<=M;++m) { f_next[m]=max(0.0, X-S_values[m]); };

vector<double> f(M+1);

for (int t=N-1;t>=0;--t) {

f[0]=X;

for (int m=1;m<M;++m) {

f[m]=a[m]*f_next[m-1]+b[m]*f_next[m]+c[m]*f_next[m+1];

f[m] = max(f[m], X-S_values[m]); // check for exercise

};

f[M] = 0;

for (int m=0;m<=M;++m) { f_next[m] = f[m]; };

};

return f[M/2];

}

PDF created with pdfFactory trial version www.pdffactory.com

Page 46: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

45 ⓒ 2004, 홍창수

새로운 학습을 위해서

Brennan and Schwartz (1978) 는 유한 차분법의 금융론 분야에의 최초의 적용예이다. Hull (1993) 의 섹션 14.7 에는

유한 차분법에의 짧은 소개부분이 있다.Wilmott et al. (1994) 에는 미분 방정식에 의한 옵션 가격 결정의 원시 코드가

있다.

Subsections

• Monte Carle method에 따르는 유럽형 옵션의 계산

Chapter6. 자산 가격경로의 시뮬레이션9

본 절에서는 시뮬레이션을 이용하여 옵션의 가격을 추정해보기로 한다. 콜옵션에 대해, 아래 공식의 현재 기대값을

구하는것이다.

),0max( XST −

혹은,

콜옵션의 가치를 추정하는 한가지 방법은 기초자산의 확률과정에 의한 TS 의 표본값의 대수(large number)를 시뮬레이션

하는것이다. 시뮬레이션 값의 평균에 따라 추정된 콜옵션의 가격을 차는것이다. 즉, 대수의 법칙(law of large number)에

따라, 이 평균값은 실제 콜옵션의 가치에 수렴하게 될것이다. 그리고, 그 수렴율(rate of convergence)은 표본경로를

시뮬레이션하는 방식에 의존하고 있으며, 아울러 우리가 얼마나 많은 시뮬레이션을 실행하는가에 달려 있다.

6. 표본경로의 시뮬레이션

기초자산의 가격 과정은 기하 브라운 운동(GBM)에 따르는 것으로 가정한다.

dBdtS

dSσµ +=

또는,

SdBdtSdS σµ +=

이것을 시뮬레이션하려면, 이 확률과정(stochastic process)의 구간을 이산화(discretise) 10할 필요가 있다.즉, 이는 0

으로부터 T까지의 시간을 구간의 수로 분할하는 것을 말한다.

9 시뮬레이션 모형은 현재부터 의사결정 시점까지 기초자산의 가능한 전개경로를 모두 포함하여 계산할 수 있다. 일반적으로 사용되는 몬

테카를로 시뮬레이션 방식은 각 경로의 최종시점에서 최적 투자전략을 결정하고 손익함수를 계산하며, 손익함수의 평균을 낸 다음 평균치

를 현가로 할인해서 옵션의 현재가치를 얻게된다. 몬테카를로 시뮬레이션은 경로의존적인 옵션-옵션의 가치가 기초자산가치뿐만 아니라

기초자산에 수반되는 특정경로에 따라서도 달라지는 옵션-의 가치평가에 많이 사용된다. (역자주) 10 몬테카를로 시뮬레이션에서 시간구간의 이산화 과정(discretization)는 시뮬레이션을 위해 자산가격의 시간경로를 아주 잘게 분할하는 것을 말한다. (역자주)

)],0[max()( XSEec TtTr

t−= −−

PDF created with pdfFactory trial version www.pdffactory.com

Page 47: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

46 ⓒ 2004, 홍창수

브라운 운동 )(dB 에 근거한 기간을 시뮬레이션 하기위해서, 브라운 운동의 특징이 어떤 유한소의 길이에 대한 증분이

평균 0, 분산이 s를 가진 정규분포라는 것을 기억할 필요가 있다. 분산이 s이므로, 표준 편차는 s 이다.따라서

만일 tε 가 평균 0, 분산 1의 정규 분포에 따른다면, 아래와 같이 이산 과정(discrete process) 이용해 시뮬레이션 하는

것이 가능하다.

또는,

이 식을 이용하면 추출된 표본의 간격 가 감소함에 따라 브라운 운동 과정의 표본경로를 근사시킬수 있는 일련의

표본경로를 생성할 수가 있다.11그러나, 이 이산화 방법(discretization)은 실제 사용을 위해 추천 할 수 없다. 여기서

우리는 기초자산 가격의 대수가 브라운 운동에 따른다는 것을 고려해 볼수 있으며, 이는 이하의 식과 같이 나타낼수 있다.

11 몬테카를로 시뮬레이션 : 기초자산이 둘인 경우 몬테카를로 시뮬레이션은 두개의 기초자산에 대한 옵션으로 쉽게 확장 될 수 있다.

ttSSS t ∆+∆−=∆+ ,11211111 )

21exp[( ασσµ

ttSSS t ∆+∆−=∆+ ,222221222 )

21exp[( ασσµ

두개의 기초자산간의 상관관계는 다음과 같이 설정될 수 있다.

tt ,1,1 εα =

2,2,1,2 1 ρερεα −+= ttt

여기서, t,1ε 와 t,2ε 는 표준정규분포로부터 추출한 독립적인 난수이다. 두개의 상관관계가 있는 자산에 대한 대부분의 옵션은 분석적인

방법이나, 3차원 이항격자모형을 통해 더욱 효율적으로 계산할 수 있다. 기초자산이 둘인 경우의 몬테카를로 시뮬레이션의 한 예로, 유럽

형 아시안 옵션(European asian spread option)의 가격결정에 이방법이 유용하게 사용될 수 있다. 이것은 만기에 두가지 자산의 산술평균간의

차이에 손익구조가 의존하는 옵션이다. 이것에 관한 내용과 VBA Code는 ‘ The Complete Guide To Option Pricing Formulas’ , Espen Gaarder

Haug, 1998, p142 를 참조하면 된다. (역자주)

PDF created with pdfFactory trial version www.pdffactory.com

Page 48: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

47 ⓒ 2004, 홍창수

이것은 손익구조가 기간 전체를 통한 자산의 전개에 의존하는 경우의 이산화 방법(discretization)이다.이것에 관해서는

이색 옵션에 관한 장을 참조하라.다만, 유러피언 콜과 풋에 대해서는, 경로에 의존적이지 않기 때문에-어떤 중간의

관찰값에 의존하지 않는- 기초자산의 최종 관찰값만을 시뮬레이션 할 필요성이 있다.

Monte Carle method에 의한 유럽형 옵션의 계산

// file: simulated_call_euro.cc

// author: Bernt Arne Oedegaard

#include <cmath> // standard mathematical functions

#include "random.h" // definition of random number generator

#include <algorithm> // define the max() function

double option_price_call_european_simulated( double S,

double X,

double r,

double sigma,

double time,

int no_sims)

{

double sigma_sqr = sigma * sigma;

double R = (r - 0.5 * sigma_sqr) *time;

double SD = sigma * sqrt(time);

double sum_payoffs = 0.0;

for (int n=1; n<=no_sims; n++) {

double S_T = S* exp(R + SD * random_normal());

sum_payoffs += max(0.0, S_T-X);

};

double c = exp(-r*time) * (sum_payoffs/double(no_sims));

return c;

};

PDF created with pdfFactory trial version www.pdffactory.com

Page 49: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

48 ⓒ 2004, 홍창수

Chapter7. 근사법(Approximation)

7.1 Barone-Adesi-Whaley법에 따르는 아메리칸 옵션가격의 2차 근사

Barone-Adesi and Whaley (1987)(BAW)에 나타나는, 연속 배당이 있는 상품에 대한 아메리칸 옵션의 가격의 근사에

관해서 알아보자.해법의 테크닉은 미분 방정식의 근사해를 찾는것이다.

를 상품에 대한 연속 배당의 액수이다고 하자.이 때 는 조건부 청구권의 가격을 결정하는 알려지지않은 공식이다.

유러피언 옵션의 경우는 Black Scholes 식에 의한 해에 의해 명시적으로 풀 수가 있다.그러나 아메리칸 옵션의 경우에는

해석해(analytic solution)는 주어지지 않았다. 이러한 근사해를 구하기 위해, BAW 는 아메리칸 옵션가격을 유러피언

옵션가격과 그 조기 권리행사 프리미엄으로 분해했다.즉

여기에 는 조기 권리행사 프리미엄이다.이것은 또한 편미분 방정식을 만족해야한다.BAW 의 근사식에서 를 포함한

항은 무시할 수 있으므로 이것을 제외해, 최종적으로 해법이 표준적인 선형 2차의 방정식으로 종결하여 공식을 얻을 수

있다. 근사치의 함수형은 아래와 같다.

여기서,

PDF created with pdfFactory trial version www.pdffactory.com

Page 50: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

49 ⓒ 2004, 홍창수

이며, 는 아래의 식을 채운다.

구현의 유일한 문제는 을 요구하는 것이다가, 이것은 고전적인 방정식의 문제이다.

이 식은 뉴턴법(newton’ s algoritm)을 이용하면 해를 요구할 수가 있다.

초기치 가 있으면 계산을 시작할 수가 있다.다음의 근사치 는 이하의 식에서 주어진다.

여기서, 각 단계에 있어 와 의 값을 평가할 필요가 있다.이 때 콜 옵션은 이하와 같이 해 구할 수 있다.

여기서, 은 그 상품에 대한 Black Scholes 식에 의해 요구한 값이다. 풋옵션의 근사는

PDF created with pdfFactory trial version www.pdffactory.com

Page 51: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

50 ⓒ 2004, 홍창수

를 다시 뉴턴법을 이용해 푸는 것으로 아래의 공식을 얻는다.

// file approx_am_call.cc

// author: Bernt Arne Oedegaard

// implements the quadratic approximation of Barone-Adesi and Whaley

// described in Journal of Finance, june 87.

#include <cmath>

#include <algorithm>

#include "normdist.h" // normal distribution

#include "fin_algoritms.h" // define other option pricing formulas

const double ACCURACY=1.0e-6;

double option_price_american_call_approximated_baw( double S,

double X,

double r,

double b,

double sigma,

double time)

{

double sigma_sqr = sigma*sigma;

double time_sqrt = sqrt(time);

PDF created with pdfFactory trial version www.pdffactory.com

Page 52: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

51 ⓒ 2004, 홍창수

double nn = 2.0*b/sigma_sqr;

double m = 2.0*r/sigma_sqr;

double K = 1.0-exp(-r*time);

double q2 = (-(nn-1) +sqrt(pow((nn-1), 2.0)+(4*m/K)))*0.5;

// seed value from paper

double q2_inf = 0.5 * ( (-nn-1.0) + sqrt(pow((nn-1), 2.0)+4.0*m));

double S_star_inf = X / (1.0 - 1.0/q2_inf);

double h2 = -(b*time+2.0*sigma*time_sqrt)*(X/(S_star_inf-X));

double S_seed = X + (S_star_inf-X)*(1.0-exp(h2));

int no_iterations=0; // iterate on S to find S_star, using Newton steps

double Si=S_seed;

double g=1;

double gprime=1.0;

while ((fabs(g) > ACCURACY)

&& (fabs(gprime) >ACCURACY) // to avoid exploding Newton's

&& ( no_iterations++<500)

&& (Si>0.0)) {

double c = option_price_european_call_payout(Si, X, r, b, sigma, time);

double d1 = (log(Si/X)+(b+0.5*sigma_sqr) *time)/(sigma*time_sqrt);

g=(1.0-1.0/q2) *Si-X-c+(1.0/q2) *Si*exp((b-r) *time) *N(d1);

gprime=( 1.0-1.0/q2)*(1.0-exp((b-r) *time) *N(d1))

+(1.0/q2) *exp((b-r) *time) *n(d1)*(1.0/(sigma*time_sqrt));

Si=Si-(g/gprime);

};

double S_star = 0;

if (fabs(g) >ACCURACY) { S_star = S_seed; } // did not converge

else { S_star = Si; };

double C=0;

double c = option_price_european_call_payout(S, X, r, b, sigma, time);

if (S>=S_star) {

C=S-X;

}

else {

double d1 = (log(S_star/X)+(b+0.5*sigma_sqr) *time)/(sigma*time_sqrt);

double A2 = (1.0-exp((b-r) *time) *N(d1))* (S_star/q2);

C=c+A2*pow((S/S_star), q2);

};

return max(C, c); // know value will never be less than BS value

PDF created with pdfFactory trial version www.pdffactory.com

Page 53: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

52 ⓒ 2004, 홍창수

}

자세하게는 Barone Adesi 2차 근사를 참조. 원시 코드는 원 논문 Barone-Adesi and Whaley (1987) 에 있다.이

근사에 대해서는 Hull (1993) 의 섹션 14A 에서도 접할 수 있다.

7.2 Geske-Johnson법에 따르는 미국형옵션 풋 가격의 근사

Geske and Johnson (1984) 에서는 아메리칸 풋에 관한 매우 좋은 근사 방법이 나타나고 있다.해법의 테크닉으로서는

행사일의 수가 증가하는,Bermudan 옵션의 시퀀스로 미국형 풋옵션을 간주하는것이다. 진정한 값은 이 수열의 극한으로서

요구된다. 권리행사일이 일 남아 있는 풋옵션의 가격을 이라고 정의한다. 는 만기일에 1번 권리행사하는

유러피언 옵션이다.또 는 만기일까지 1번, 만기일에 한번 더 권리행사하는 것 같은 옵션의 가격을 의미한다. Geske

와 Johnson 는 이러한 옵션이 근사치값의 시퀀스가 정확한 가격에 어떻게 수렴되는지를 보여주었다. 즉, 3개의

옵션으로부터의 점화식

여기서 는 통상의(유러피언 옵션의) Black Scholes 식에서 주어지는 가격이며,

여기서,

이다. 와 의 값은 용이하게 멈추지만, 의 평가에서의 문제는 3변량 정규 누적 분포가 필요하다.정규 분포에

관한 주석을 보면 좋지만, 이것은 수치적분(numerical integration)을 포함한, 무시할 수 없는 문제이다.

PDF created with pdfFactory trial version www.pdffactory.com

Page 54: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

53 ⓒ 2004, 홍창수

Chapter 8. 선물 알고리즘(Futures algoritms)

본 장에서는 선물 계약의 가치평가에 사용되는 알고리즘에 대해 논의해보고자 한다.

Subsections

• 선물계약의 가격결정(Pricing of futures contract)

• 선물옵션(Option on futures )

o 블랙 모형(Black's model)

§ 컴퓨터 알고리즘(Computer algoritm)

o 이항근사(Binomial approximation.)

8.1 선물계약의 가격결정

// file futurpri.cc

// author: Bernt A Oedegaard.

#include <cmath>

double futures_price(double S, // value of underlying

double r, // risk free interest

double time_to_maturity) {

return exp(r*time_to_maturity)*S;

};

Subsections

• Black 모델

o 컴퓨터 프로그램

PDF created with pdfFactory trial version www.pdffactory.com

Page 55: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

54 ⓒ 2004, 홍창수

• 이항모델에 의한 추정

8.2 선물옵션(Options on futures)

선물에 대한 옵션(Options on futures)의 가치평가는 선물계약에 관련된 흥미로운 문제중의 하나이다.

8.2.1 Black 모델12

선물에 대한 유럽형 옵션은 Black Scholes 모형의 수정이 일부 수정된 Black (1976) 모형을 사용 하는 것이 좋다.Hull,

1993,(Ch 11.4)책도 참조하여 본고를 보시기 바란다.

• : 선물가격

• : 권리행사 가격

• : 이자율

• : 변동성(volatility)

• : 만기까지의 일수(잔존만기)

컴퓨터 프로그램

// file futures_opt_call_black.cc

// author: Bernt A Oedegaard

12 국채선물옵션(Option on KTB Futures)의 가격결정시 Black(1976)의 모형이 사용될수 있다. 다만, 선물거래소에서의 이론가격은 증권거래

소에서 사용하는 KOSPI200 옵션의 이론가 도출에서와 같이 이항모형(49 node)으로 이론가격을 계산하고 있다. (역자주)

PDF created with pdfFactory trial version www.pdffactory.com

Page 56: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

55 ⓒ 2004, 홍창수

#include <cmath> // mathematics library

#include "normdist.h" // normal distribution

double futures_option_price_call_european_black(

double F, // futures price

double X, // exercise price

double r, // interest rate

double sigma, // volatility

double time) // time to maturity

{

double sigma_sqr = sigma*sigma;

double time_sqrt = sqrt(time);

double d1 = (log (F/X) + 0.5 * sigma_sqr * time) / (sigma * time_sqrt);

double d2 = d1 - sigma * time_sqrt;

return exp(-r*time)*(F * N(d1) - X * N(d2));

};

8.2.2이항모형에 의한 추정(Binomial approximation)

미국형 옵션은 조기 권리행사의 가능성이 있기 때문에, 옵션 가치의 추정에 이항모형이 자주 이용된다.

// file: futures_opt_call_bin.cc

// author: Bernt A Oedegaard

#include <cmath>

#include <algorithm>

#include <vector>

double futures_option_price_call_american_binomial(

double F, double X, double r, double sigma, double time, int no_steps) {

vector<double> futures_prices(no_steps+1);

vector<double> call_values (no_steps+1);

double t_delta= time/no_steps;

double Rinv = exp(-r*(t_delta));

double u = exp(sigma*sqrt(t_delta));

double d = 1.0/u;

double uu= u*u;

double pUp = (1-d)/(u-d); // note how probability is calculated

double pDown = 1.0 - pUp;

PDF created with pdfFactory trial version www.pdffactory.com

Page 57: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

56 ⓒ 2004, 홍창수

futures_prices[0] = F*pow(d, no_steps);

int i;

for (i=1; i<=no_steps; ++i) futures_prices[i] = uu*futures_prices[i-1]; // terminal tree nodes

for (i=0; i<=no_steps; ++i) call_values[i] = max(0.0, (futures_prices[i]-X));

for (int step=no_steps-1; step>=0; --step) {

for (i=0; i<=step; ++i) {

futures_prices[i] = d*futures_prices[i+1];

call_values[i] = (pDown*call_values[i]+pUp*call_values[i+1]) *Rinv;

call_values[i] = max(call_values[i], futures_prices[i]-X); // check for exercise

};

};

return call_values[0];

};

Chapter 9. 통화 알고리즘/ Foreign Currency Algoritms

Subsections

• 통화옵션

o 유럽형 옵션.

§ 컴퓨터 알고리즘, 유럽형 통화옵션

§ 참고자료

o 미국형 옵션

§ 컴퓨터 알고리즘, 이항 통화옵션

Subsections

• 유러피언 옵션

o 컴퓨터 프로그램:유러피언 통화 옵션

o 참고 자료

• 아메리칸 옵션

o 컴퓨터 프로그램:이항통화 옵션

PDF created with pdfFactory trial version www.pdffactory.com

Page 58: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

57 ⓒ 2004, 홍창수

통화 옵션

유럽형 옵션

유럽형 옵션을 평가하기 위해서는, Black-Scholes 식을 이자율의 미분으로 나타내도록 수정을 하는 것이 좋다.

• : 환율

• : 권리행사 가격

• : 국내 통화의 이자율

• : 외국 통화의 이자율

• : 환율의 변동성(volatility)

• : 만기일까지의 시간(잔존만기)

여기서,

컴퓨터 프로그램:유럽형 통화 옵션

// file currency_opt_euro_call.cc

// author: Bernt A Oedegaard

#include <cmath>

#include "normdist.h" // define the normal distribution function

double currency_option_price_call_european( double S, // exchange_rate,

PDF created with pdfFactory trial version www.pdffactory.com

Page 59: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

58 ⓒ 2004, 홍창수

double X, // exercise,

double r, // r_domestic,

double r_f, // r_foreign,

double sigma, // volatility,

double time) // time to maturity

{

double sigma_sqr = sigma*sigma;

double time_sqrt = sqrt(time);

double d1 = (log(S/X) + (r-r_f+ (0.5*sigma_sqr)) * time)/(sigma*time_sqrt);

double d2 = d1 - sigma * time_sqrt;

return S * exp(-r_f*time) * N(d1) - X * exp(-r*time) * N(d2);

};

참고 자료

유럽형 통화옵션의 원 공식은 Garman and Kohlhagen (1983) 와 Grabbe (1983) 에 있다.교재의 참조물로는 (Hull,

1993, Ch 11.3)을 참조할 것.

미국형 옵션

미국형 옵션에 대한 통상의 방법은, 이항트리를 사용하여 근사화 하는것이다.(각 노드에서 금리차에 기인되는 조기행사

가능성을 체크한다)

컴퓨터 프로그램: 이항통화 옵션

// file currency_opt_bin_call.cc

// author: Bernt A Oedegaard

#include <cmath>

#include <algorithm>

#include <vector>

double currency_option_price_call_american_binomial(

double S, double X, double r, double r_f, double sigma,

double time, int no_steps) {

vector<double> exchange_rates(no_steps+1);

vector<double> call_values(no_steps+1);

double t_delta= time/no_steps;

double Rinv = exp(-r*(t_delta));

PDF created with pdfFactory trial version www.pdffactory.com

Page 60: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

59 ⓒ 2004, 홍창수

double u = exp(sigma*sqrt(t_delta));

double d = 1.0/u;

double uu= u*u;

double pUp = (exp((r-r_f) *t_delta) -d)/(u-d); // adjust for foreign int.rate

double pDown = 1.0 - pUp;

exchange_rates[0] = S*pow(d, no_steps);

int i;

for (i=1; i<=no_steps; ++i) {

exchange_rates[i] = uu*exchange_rates[i-1]; // terminal tree nodes

}

for (i=0; i<=no_steps; ++i) call_values[i] = max(0.0, (exchange_rates[i]-X));

for (int step=no_steps-1; step>=0; --step) {

for (i=0; i<=step; ++i) {

exchange_rates[i] = d*exchange_rates[i+1];

call_values[i] = (pDown*call_values[i]+pUp*call_values[i+1]) *Rinv;

call_values[i] = max(call_values[i], exchange_rates[i]-X); // check for exercise

};

};

return call_values[0];

};

Chapter10. 채권 알고리즘 구현

이 장에서는 채권과 유사 고정수익증권에 관해 알아볼것이다.채권을 구별 짓는 것은 채권이 발행될 때 미래

현금흐름(이표와 원금) 이 결정되는 방식이다.

10.1채권 가격

국채 가격은 미래의 현금흐름의 현재 가치이다.미국채(T-Bond)와 같이 이표채를 고려해보면, 현금흐름은

과 나타낼 수 있으므로, 채권의 현재 가치는, 이산형의 경우

PDF created with pdfFactory trial version www.pdffactory.com

Page 61: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

60 ⓒ 2004, 홍창수

되어, 연속형의 경우

된다.다만 이자율 은 일정해, 이 조건을 기간 구조가 「평탄(flat)」이다고 한다.

연속형의 경우의 채권 가격의 계산방법을 아래에 두가지방식을 표기해본다.

// file bonds_price_both.cc

// author: Bernt A Oedegaard.

#include <cmath>

#include <vector>

double bonds_price(const vector<double>& coupon_times,

const vector<double>& coupon_amounts,

const vector<double>& principal_times,

const vector<double>& principal_amounts,

const double& r)

// calculate bond price when term structure is flat,

// given both coupon and principals

{

double p = 0;

for (unsigned i=0;i<coupon_times.size() ;i++) {

p += exp(-r*coupon_times[i]) *coupon_amounts[i];

};

for (unsigned i=0;i<principal_times.size() ;i++) {

p += exp(-r*principal_times[i]) *principal_amounts[i];

};

return p;

};

// file bonds_price.cc

// author: Bernt A Oedegaard.

#include <cmath>

#include <vector>

double bonds_price(const vector<double>& cashflow_times,

PDF created with pdfFactory trial version www.pdffactory.com

Page 62: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

61 ⓒ 2004, 홍창수

const vector<double>& cashflows,

const double& r) {

// calculate bond price when term structure is flat,

double p=0;

for (unsigned i=0;i<cashflow_times.size() ;i++) {

p += exp(-r*cashflow_times[i]) *cashflows[i];

};

return p;

};

2개의 방법 중 한편은 이자율과 원금 벡터를 이용하고 있지만, 한편은 현금흐름(cash flow) 밖에 이용하고 있지

않다.쿠폰과 원금의 차이는 그다지 중요하지 않고, 쿠폰의 화와 원금인 현금흐름를 생각하면 좋다.이 차이가 중요하게 되는

경우도 있어, 세금을 포함한 경우가 그 중의 하나이다.그 경우는 어떤 것이 이자이며, 어떤 것이 원본이었는지를 분명히 할

필요가 있다.그러나 여기에서는 단순한 경우를 생각하고 있으므로 현금흐름(cash flow)만을 보고 있으면

자주(잘).프로그램은 뒤쫓기 쉬워지고 있다.이하에 이산(연차) 복리계산의 경우를 보자.

// file bonds_price.cc

// author: Bernt A Oedegaard.

#include <cmath>

#include <vector>

double bonds_price_discrete(const vector<double>& cashflow_times,

const vector<double>& cashflows,

const double& r) {

// calculate bond price when term structure is flat,

double p=0;

for (unsigned i=0;i<cashflow_times.size() ;i++) {

p +=cashflows[i]/(pow((1+r), cashflow_times[i]));

};

return p;

};

먼저 기간 구조가 평탄하다라고 가정했지만, 이것은 많은 경우 타당한 가정은 아니다.따라서 할인을 위해서 일반적인

기간 구조를 사용한다.

PDF created with pdfFactory trial version www.pdffactory.com

Page 63: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

62 ⓒ 2004, 홍창수

다만 은 평가를 실시할 때 각 에 있어서의 지불을 할인하는 함수이다.예를 들어 기간 구조가 평탄한 경우는 단순한

할인함수가 된다.

기간 구조를 포함한 르틴·term_structure클래스를 가정해도 괜찮다.알고리즘을 나타내는 페이지의 목적으로 해 할인율

또는 일드를 돌려주는 기능을 추출할 수 있으면 좋으니까이다.

// file bonds_price_termstru.cc

// author: Bernt Arne Odegaard

#include <vector>

#include "term_structure_class.h"

double bonds_price(const vector<double>& cashflow_times,

const vector<double>& cashflows,

const term_structure_class& d) {

double p = 0;

for (unsigned i=0;i<cashflow_times.size() ;i++) {

p += d.discount_factor(cashflow_times[i]) *cashflows[i];

};

return p;

};

Subsections

• 단순 듀레이션(Simple duration)

• 맥콜레이·듀레이션(Macaulay Duration)

• 수정 듀레이션(Modified Duration)

PDF created with pdfFactory trial version www.pdffactory.com

Page 64: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

63 ⓒ 2004, 홍창수

10.3듀레이션

10.3.1 단순 듀레이션

여기서,

• 는 시점에 있어서 현금흐름(cash flow)이며,

• 는 할인율이며,$1를 지불하는 할인채의 시점에 있어서의 현재가격

우선, 사례에서의 기간구조는 플랫(flat)하다고 본다.

// file bonds_duration.cc

// author: Bernt Arne Odegaard

#include <cmath>

#include <vector>

double bonds_duration(const vector<double>& cashflow_times,

const vector<double>& cashflows,

const double& r)

// calculate the duration of a bond, simple case where the term

// structure is flat, interest rate r.

{

double S=0;

double D1=0;

for (unsigned i=0;i<cashflow_times.size() ;i++){

S += cashflows[i] * exp(-r*cashflow_times[i]);

D1 += cashflow_times[i] * cashflows[i] * exp(-r*cashflow_times[i]);

};

return D1 / S;

};

보다 일반적으로는

PDF created with pdfFactory trial version www.pdffactory.com

Page 65: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

64 ⓒ 2004, 홍창수

// file duration.cc

// author: Bernt A Oedegaard.

#include <vector>

#include "term_structure_class.h"

double bonds_duration(const vector<double>& cashflow_times,

const vector<double>& cashflow_amounts,

const term_structure_class& d ) {

double S=0;

double D1=0;

for (unsigned i=0;i<cashflow_times.size() ;i++){

S += cashflow_amounts[i] * d.discount_factor(cashflow_times[i]);

D1 += cashflow_times[i] * cashflow_amounts[i] * d.discount_factor(cashflow_times[i]);

};

return D1/S;

};

10.3.2 맥콜레이 듀레이션

다만

• 는 기간 에 있어서의 현금흐름(cash flow),

• 는 (연속적인) 만기 수익률(YTM)

// file bonds_duration_macaulay.cc

// author: Bernt A Oedegaard.

// calculate Macaulay duration.

#include "fin_algoritms.h"

double bonds_duration_macaulay(const vector<double>& cashflow_times,

PDF created with pdfFactory trial version www.pdffactory.com

Page 66: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

65 ⓒ 2004, 홍창수

const vector<double>& cashflows,

const double& bond_price) {

double y = bonds_yield_to_maturity(cashflow_times, cashflows, bond_price);

return bonds_duration(cashflow_times, cashflows, y); // use YTM in duration

};

10.3.3 수정 듀레이션

// file bonds_duration_modified.cc

// author: Bernt A Oedegaard.

#include <vector>

#include "fin_algoritms.h"

double bonds_duration_modified (const vector<double>& cashflow_times,

const vector<double>& cashflow_amounts,

const double& bond_price,

const double& r)

{

double dur = bonds_duration(cashflow_times, cashflow_amounts, r);

double y = bonds_yield_to_maturity(cashflow_times, cashflow_amounts,

bond_price);

return dur/y;

};

10.4볼록성(Convexity)

볼록성(Convexity)는 듀레이션을 이용하고 있을 때 그 변화를 추정할 때에 이용한다.이하의 식에서 계산된다.

PDF created with pdfFactory trial version www.pdffactory.com

Page 67: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

66 ⓒ 2004, 홍창수

// file bonds_convexity.cc

// author: Bernt A Oedegaard.

// calculate convexity of a bond.

#include <cmath>

#include <vector>

double bonds_convexity(const vector<double>& cashflow_times,

const vector<double>& cashflow_amounts,

const double& y )

{

double C=0;

for (unsigned i=0;i<cashflow_times.size() ;i++){

double t = cashflow_times[i];

C+= cashflow_amounts[i] * t * t * exp(-y*t);

};

return C;

};

Chapter11.이색옵션(Exotic options)

이색옵션은, 통상의 풋이나 콜보다 복잡한 손익(payoff) 구조를 가지는 옵션이라고 이해하면 좋다.가상적이게는 무한정

이색 옵션이 있지만, 현실적으로 상상을 따라잡는 것은 한정되어 있다.실제로 이용되는 것은 적다.이색 옵션의 수많은

해석해(analytical solition)에 대해서는Rubinstein (1993)을 참고할 것.

Subsections

• 룩 백 옵션

o 참고 자료

Subsections

• 참고 자료

11.1룩 백 옵션(look back option)

룩 백 옵션의 손익구조(payoff)는 기간을 통해서의 자산 가격의 최대치 또는 최소치에 의존한다.이 옵션에 관한 해석해는

Goldman et al. (1979) 에 의해 소개되고 있다. 아래에 컴퓨터 그 알고리즘을 구현(implementing)한것이다.

PDF created with pdfFactory trial version www.pdffactory.com

Page 68: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

67 ⓒ 2004, 홍창수

// file exotics_lookback_call.cc

// author: Bernt A Oedegaard

#include <cmath>

#include "normdist.h"

double exotics_lookback_european_call(double S,

double Smin,

double r,

double q,

double sigma,

double time){

if (r==q) return 0;

double sigma_sqr=sigma*sigma;

double time_sqrt = sqrt(time);

double a1 = (log(S/Smin) + (r-q+sigma_sqr/2.0) *time)/(sigma*time_sqrt);

double a2 = a1-sigma*time_sqrt;

double a3 = (log(S/Smin) + (-r+q+sigma_sqr/2.0) *time)/(sigma*time_sqrt);

double Y1 = 2.0 * (r-q-sigma_sqr/2.0) *log(S/Smin) /sigma_sqr;

return S * exp(-q*time) *N(a1)

- S * exp(-q*time)*(sigma_sqr/(2.0*(r-q))) *N(-a1)

- Smin * exp(-r*time)*(N(a2)-(sigma_sqr/(2*(r-q))) *exp(Y1) *N(-a3));

};

여러가지 이색 옵션을 평가하려면 시뮬레이션을 통해서 실행하는 일이 많다.이하의 장에서는 그 일반적인 방법을

나타낸다.

참고 자료

Hull (1993) 의 16장에 이러한 옵션의 짧은 소개가 되어 있다.

Chapter12. 시뮬레이션에 의한 옵션 가격 설정의 일반적 접근법

이전의 장에서는 유러피언 콜 옵션 가격을을 시뮬레이션 추정을 이용하는 것을 살표보았다.시뮬레이션에 의한 추정은

아주 일반적이 되었고, 어떠한 유럽형 파생상품 상의 가격 추정에도 이용할 수가 있다.최적인 권리행사 정책이 분명하지

않기 때문에 미국형 파생상품에는 시뮬레이션 방법을 이용할수 없다.만약 이것의 형태가 알려진다면 폐쇄형 해(closed

form solution)를 만들어 낼수 있다. 유럽형 파생상품에서 시뮬레이션방법은 적당하다. 이색 옵션에 관해서는 유일한

해법이라고 말해도 좋다. 아래에서는 파생상품 가격의 시뮬레이션에 관한 일반적인 구조를 알아보기로 한다.

PDF created with pdfFactory trial version www.pdffactory.com

Page 69: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

68 ⓒ 2004, 홍창수

Subsections

• 자산 가격의 시뮬레이션

• 손익구조의 정의

• 가격 설정

• 추정치의 개선·변수의 제어

자산 가격의 시뮬레이션

첫번째는 어떻게 가격이 시뮬레이션 되는지를 살펴보자. 2개 경우를 생각한다. 1개는 임의 시점에 있어서의 최종

가격만이 필요한 경우이다. 이것은 이 기초자산에만 의존하는 옵션으로, 기본적인 콜이나 풋과 같이 최종 가격만이 중요한

정보가 되는 경우이다.

// file simulate_underlying_terminal.cc

#include <math.h>

#include "random.h"

double simulate_terminal_price(double S, // current value of underlying

double r, // interest rate

double sigma, // volatitily

double time) // time to final date

{

double R = (r - 0.5 * pow(sigma, 2) ) *time;

double SD = sigma * sqrt(time);

return S * exp(R + SD * random_normal());

};

보다 일반적으로는 파생상품의 전기간에 걸쳐서 다양한 시점에 있어서의 가격을 시뮬레이션 할 필요가 있다. 알고리즘의

구현은 아래의 내용을 참조할 것.

// file: simulate_underlying_sequence.cc

#include <math.h>

#include <vector.h>

#include "random.h"

PDF created with pdfFactory trial version www.pdffactory.com

Page 70: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

69 ⓒ 2004, 홍창수

void simulate_price_sequence(double S, // current value of underlying

double r, // interest rate

double sigma, // volatitily

double time, // time to final date

int no_steps, // number of steps

vector<double>& prices ) {

if (prices.size() < no_steps) {

prices.clear();

prices = vector<double>(no_steps);

};

double delta_t = time/no_steps;

double R = (r-0. 5*sigma*sigma) *delta_t;

double SD = sigma * sqrt(delta_t);

double S_t = S; // initialize at current price

for (int i=0; i<no_steps; ++i) {

S_t = S_t * exp(R + SD * random_normal());

prices[i]=S_t;

};

};

손익구조(payoff)의 정의

우리가 분석 파생상품의(derivative)의 손익구조를 정의하는 일반적인 함수 만들고 싶다.손익구조는 최종 가격이나 가격의

전체 경로(history), 그 외의 파라미터로 기술되는 함수이다.예를 들면 유러피언 콜이나 풋의 손익구조는 자산의 최종

가격과 옵션의 권리행사 가격의 함수이다.

>

손익구조(수익함수)는 최종 가격과 권리행사 가격의 2개의 값에 의해 계산되도록 프로그램 되고 있다.

// file payoff_black_scholes.cc

#include <algo.h>

double payoff_european_call(double& price, double& X){

return max(0.0, price-X);

};

PDF created with pdfFactory trial version www.pdffactory.com

Page 71: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

70 ⓒ 2004, 홍창수

double payoff_european_put(double& price, double& X){

return max(0.0, X-price);

};

다음의 예로서 가격의 열의 최대 또는 최소에 의존하는 옵션을 생각해 보자.여기에 전체 가격의 경로가 포함되 있다.

// file payoff_max_min

#include <vector.h>

#include <algo.h>

double payoff_max(vector<double>& prices) {

double m = *max_element(prices.begin(), prices.end());

return m-prices.back(); // max is always larger or equal.

};

double payoff_min(vector<double>& prices) {

double m = *min_element(prices.begin(), prices.end());

return prices.back() -m; // always positive or zero

};

이 정의에서 알려줄 한가지는 max_element함수를 이용하고 있다는 점이다.그것은 그것을 통과한 변수의 최대 집합을

산출한다. 이것은 최근에 C++ 언어에 추가된 부분이며, STL(Standard Template Library)의 알고리즘이다.

또다른 예: 평균옵션(Options on the average)

// file payoff_average.cc

#include <math.h>

#include <algo.h>

#include <vector.h>

PDF created with pdfFactory trial version www.pdffactory.com

Page 72: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

71 ⓒ 2004, 홍창수

double payoff_arithmetric_average(vector<double>& prices) {

double sum=accumulate(prices.begin(), prices.end(), 0.0);

double avg = sum/prices.size();

return max(0.0, avg-prices.back());

};

double payoff_geometric_average(vector<double>& prices) {

double logsum=log(prices[0]);

for (unsigned i=1;i<prices.size() ;++i){ logsum+=log(prices[i]); };

double avg = exp(logsum/prices.size());

return max(0.0, avg-prices.back());

};

가격 결정

지금까지의 2개의 루틴을 이용해 다소 일반적인 시뮬레이션 루틴을 작성할 수가 있다.

// file simulate_general.cc

// author: Bernt A Oedegaard

// estimation of an option price by simulation.

// This is a general routine, the payoff is defined by the user as a function

// payoff(vector<double>&) or

// payoff(vector<double>&, X),

// depending on whether there are other arguments beside the prices of the underlying needed.

#include <math.h>

#include <vector.h>

#include <algo.h>

#include "fin_algoritms.h"

double derivative_price_european_simulated ( double S, double X, double r, double sigma, double time,

double payoff(double& price, double& X),

int no_sims) {

double sum_payoffs=0;

for (int n=0; n<no_sims; n++) {

double S_T = simulate_terminal_price(S, r, sigma, time);

sum_payoffs += payoff(S_T, X);

};

return exp(-r*time) * (sum_payoffs/no_sims);

};

PDF created with pdfFactory trial version www.pdffactory.com

Page 73: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

72 ⓒ 2004, 홍창수

double derivative_price_european_simulated ( double S, double r, double sigma, double time,

double payoff(vector<double>& prices),

int no_steps, int no_sims) {

double sum_payoffs=0;

vector <double> prices(no_steps);

for (int n=0; n<no_sims; n++) {

simulate_price_sequence(S, r, sigma, time, no_steps, prices);

sum_payoffs += payoff(prices);

};

prices.clear();

return exp(-r*time) * (sum_payoffs/no_sims);

};

double derivative_price_european_simulated ( double S, double X, double r, double sigma, double time,

double payoff(vector<double>& prices, double& X),

int no_steps, int no_sims) {

double sum_payoffs=0;

vector <double> prices(no_steps);

for (int n=0; n<no_sims; n++) {

simulate_price_sequence(S, r, sigma, time, no_steps, prices);

sum_payoffs += payoff(prices, X);

};

prices.clear();

return exp(-r*time) * (sum_payoffs/no_sims);

};

추정의 정치화

시뮬레이션을 개선하기 위해서 제어 변동법(control variate technique)을 이용한다.

// file simulate_general_control_variate.cc

#include "fin_algoritms.h"

#include <math.h>

double derivative_price_european_simulated_control_variate (

double S,

double r,

double sigma,

double time,

PDF created with pdfFactory trial version www.pdffactory.com

Page 74: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

73 ⓒ 2004, 홍창수

double payoff(vector<double>& prices),

int no_steps,

int no_sims)

{

double X = S;

double c_bs = option_price_call_black_scholes(S, X, r, sigma, time);

vector <double> prices(no_steps, 0.0);

double sum_payoffs=0;

double sum_payoffs_bs=0;

for (int n=0; n<no_sims; n++) {

simulate_price_sequence(S, r, sigma, time, no_steps, prices);

sum_payoffs += payoff(prices);

sum_payoffs_bs += payoff_european_call(prices.back(), X);

};

double c_sim = exp(-r*time) * (sum_payoffs/no_sims);

double c_bs_sim = exp(-r*time) * (sum_payoffs_bs/no_sims);

c_sim += (c_bs-c_bs_sim);

return c_sim;

};

Chapter 13. Black Scholes 형 공식의 대체 방정식

블랙-숄즈(Black Scholes) 모형을 수정해, 대안적인 공식으로 제기된 모형은 아주 많이 개발되어 왔다.그러나 널리

이용되는 것은 극히 적은 수에 불과하다. 아래에서는 이러한 공식중 몇가지 공식에 대해서만 알아보기로 하자.

Subsections

• Jump diffusion 모델

• 추계적 변동성(stochastic volatility)

Jump diffusion 모형

Merton 는 브라운 운동(Brownian Motion)에 기초자산이 점프라 불리는 가격과정을 덧붙여 모형을 개발했다.이 점프의

위험은 가격 결정이 되지 않는다고 가정한다. 이하에 나타내는 것은, 점프의 크기는 정규 분포에 따른다는 것을 가정하는

Merton 모형의 특수한 경우이다. (Hull, 1993(pg 454)에 기록되고 있다 ). 아울러, 와 는 점프 분포(jump

distribution)의 모수이다. 이 때 유럽식 콜 옵션의 가격은,

PDF created with pdfFactory trial version www.pdffactory.com

Page 75: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

74 ⓒ 2004, 홍창수

이 된다. 여기서,

는 Black Scholes 공식이다. 한층 더

이 식을 구현하기 위해서는, 어떤 시점의 유한화를 요구할 필요가 있다.그렇지만 팩토리얼 함수는 매우 빠르게 커지기

때문에, 이 점은 문제가 되지 않고, 근처에서 끝내면 좋다. 계산상의 어려움을 피하기 위해서는 아래의 식에서

계산하면 좋다.

// file merton_jump_diff_call.cc

// author: Bernt Arne Oedegaard

#include <cmath>

#include "fin_algoritms.h"

double option_price_call_merton_jump_diffusion( double S,

double X,

double r,

PDF created with pdfFactory trial version www.pdffactory.com

Page 76: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

75 ⓒ 2004, 홍창수

double sigma,

double time_to_maturity,

double lambda,

double kappa,

double delta) {

const int MAXN=50;

double tau=time_to_maturity;

double sigma_sqr = sigma*sigma;

double delta_sqr = delta*delta;

double lambdaprime = lambda * (1+kappa);

double gamma = log(1+kappa);

double c = exp(-lambdaprime*tau)*

option_price_call_black_scholes(S, X, sigma, r-lambda*kappa, tau);

double log_n = 0;

for (int n=1;n<=MAXN; ++n) {

log_n += log(n);

double sigma_n = sqrt( sigma_sqr+n*delta_sqr/tau );

double r_n = r-lambda*kappa+n*gamma/tau;

c += exp(-lambdaprime*tau+n*log(lambdaprime*tau) -log_n)*

option_price_call_black_scholes(S, X, sigma_n, r_n, tau);

};

return c;

};

추계적 변동성(stochastic volatility)

추계적 변동성13은 이다.이 분야는 옵션가격 공식에 있어서 변화하는 변동성(volatility)을 얼마나 조정시킬지에 대해 꾸준히

연구되고 있는 분야이다.

평균 분산 분석

Subsections

• 서

• 평균 분산 포트폴리오

• 공매도의 제한 조건

13 “ 추계(推 計)하다” 라는 용어는 estimate의 의미를 가진다. 추계학(theory of statistical inference)을 stochastics 라고 하며, 추계학자(an inductive statistician)를 stochastician 이라고 한다.(역자주)

PDF created with pdfFactory trial version www.pdffactory.com

Page 77: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

76 ⓒ 2004, 홍창수

평균 분산 선택이라고 하는 기법은 금융 분야에서도는 옛부터 이용되고 있던 것으로, 마코윗츠(Markowitz)가 제창한

것이다.기본적인 가정은, 리스크는 분산으로 측정 되며, 선택기준으로부터의 결정은 주어진 기대 수익에서 분산을 최소화

하거나 또는 주어진 분산 아래에서의 기대 수익의 최대화라고 하는 기준으로 행해진다. 평균 분산 분석은 벡터 연산 에서

극히 간결하게 기술할 수가 있다.

를 개의 자산의 기대 수익이 되며,,

를 공분산 행렬로 한다.즉

이다.여기서 자산의 포트폴리오는

과 나타내진다.포트폴리오의 기대 수익은

분산은 다음식과 같이 나타낼 수가 있다.

// file mv_calc.cc

// author: Bernt A Oedegaard

PDF created with pdfFactory trial version www.pdffactory.com

Page 78: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

77 ⓒ 2004, 홍창수

// basic calculations for mean variance analysis

#include "newmat.h"

#include <cmath>

double mv_calculate_mean(const Matrix& e, const Matrix& w){

Matrix tmp = e.t() *w;

return tmp.element(0,0);

};

double mv_calculate_variance(const Matrix& V, const Matrix& w){

Matrix tmp = w.t() *V*w;

return tmp.element(0,0);

};

double mv_calculate_st_dev(const Matrix& V, const Matrix& w){

double var = mv_calculate_variance(V, w);

return sqrt(var);

};

평균 분산 포트폴리오

공매도의 제약 조건이 없는 경우에는, 어떤 주어진 기대수익률의 최소분산 포트폴리오 해석해(analytic solution)이며,

쉽게 산출될수 있다. 주어진.기대 수익률 은 이하의 식을 채우는 값이다.

조약조건 없는 MV(평균분산) 프런티어의 산출식에 관해서는 Huang and Litzenberger (1988)의 3장을 참조하라.

// file mv_calc_port_unconstrained.cc

// author: Bernt A Oedegaard

#include "newmat.h"

ReturnMatrix mv_calculate_portfolio_given_mean_unconstrained(const Matrix& e,

const Matrix& V,

double r){

int no_assets=e.Nrows();

Matrix ones = Matrix(no_assets, 1); for (int i=0;i<no_assets;++i){ ones.element(i, 0) = 1; };

PDF created with pdfFactory trial version www.pdffactory.com

Page 79: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

78 ⓒ 2004, 홍창수

Matrix Vinv = V.i(); // inverse of V

Matrix A = (ones.t() *Vinv*e); double a = A.element(0,0);

Matrix B = e.t() *Vinv*e; double b = B.element(0,0);

Matrix C = ones.t() *Vinv*ones; double c = C.element(0,0);

Matrix D = B*C - A*A; double d = D.element(0,0);

Matrix Vinv1=Vinv*ones;

Matrix Vinve=Vinv*e;

Matrix g = (Vinv1*b - Vinve*a)*(1.0/d);

Matrix h = (Vinve*c - Vinv1*a)*(1.0/d);

Matrix w = g + h*r;

w.Release();

return w;

};

공매도(short sales)의 제약조건

실제의 거래에서는 공매도가 빈번하게 행해지지 않는다.그 경우에는 포트폴리오의 가중치에 0 혹은 그 이상이라고 하는

제약 조건을 붙이지 않으면 안 된다.

공매도의 제한을 붙였을 경우에는, 이하의 최적화 문제를 풀 필요가 있다.

여기서,

이 계산 (2차 프로그램) 프로그램의 전모를 기술하는 것은 이 노트의 목적을 넘어서 버린다.그러므로에 이하의 코드는

cfsqp 로 불리는 2차 헤찾기(quadratic solver)를 이용해 계산을 하고 있다. 현재 OR부서에서 이것은 전적으로 이용되고

있다. 비록 그 코드는 전형적 단계가 일반적인 최적화 루틴으로 작성된다. 우리가 할수 있는 것은 목적 함수를 정의하여

제한 조건의 집합을 C 의 서브루틴으로서 옵티마이저(optimizer)와의 인터페이스를 작성하는 것 뿐이다.

// file mv_short.cc

// author: Bernt Arne Oedegaard

PDF created with pdfFactory trial version www.pdffactory.com

Page 80: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

79 ⓒ 2004, 홍창수

// calculate a mean variance portfolio under short sales constraints

#include "mv_calc.h"

#include "cfsqp_op.h" // optimize using CFSQP

#include "mymatrix.h" //

int MV_SHORT_no_assets; // global values because they need to be

double MV_SHORT_r; // available in criterion function

Matrix* MV_SHORT_e;

Matrix* MV_SHORT_V;

double MV_SHORT_objective(double x[]){

Matrix X(MV_SHORT_no_assets, 1);

for (int i=0;i<MV_SHORT_no_assets;++i){

X.element(i, 0) =x[i];

};

return mv_calculate_variance(*MV_SHORT_V, X);

}

double MV_SHORT_constraints(double x[], int constraint_no){

Matrix X(MV_SHORT_no_assets, 1);

for (int i=0;i<MV_SHORT_no_assets;++i){

X.element(i, 0) =x[i];

};

if (constraint_no==1) { // constraint w'1=1

Matrix A = (X.t() *ones_matrix(MV_SHORT_no_assets, 1));

return A.element(0,0)-1.0;

};

if (constraint_no==2) { // constraint w'e=r

Matrix A = (X.t()*(*MV_SHORT_e));

return A.element(0,0) -MV_SHORT_r;

};

return 0;

};

ReturnMatrix mv_calculate_portfolio_given_mean_no_short_sales( Matrix& e,

Matrix& V,

double r){

// solve the quadratic program to minimize variance given constraints

// all weights are in [0,1]

// the weights sum to one

PDF created with pdfFactory trial version www.pdffactory.com

Page 81: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

80 ⓒ 2004, 홍창수

// expected return equals r

MV_SHORT_no_assets = e.Nrows();

MV_SHORT_V = &V;

MV_SHORT_e = &e;

MV_SHORT_r = r;

Matrix w = null_matrix(MV_SHORT_no_assets, 1);

// check whether it is feasible to find optimum. Only if r is between

// min and max in e;

double r_min = e.element(0,0);

double r_max = e.element(0,0);

int i_min = 0;

int i_max = 0;

int i;

for (i=1;i<MV_SHORT_no_assets;++i) {

if (e.element(i, 0) <r_min) {

r_min = e.element(i, 0);

i_min = i;

};

if (e.element(i, 0) >r_max) {

r_max = e.element(i, 0);

i_max = i;

};

};

if ( (r>r_max) || (r<r_min) ) {

cerr << " can not perform optimization " << endl;

w.Release(); // returning zeros as weight

return w;

};

double *x = new double[MV_SHORT_no_assets];

double *x_min = new double[MV_SHORT_no_assets];

double *x_max = new double[MV_SHORT_no_assets];

for (i=0;i<MV_SHORT_no_assets;++i) {

x[i] = 0;

x_min[i] = 0;

x_max[i] = 1;

};

// now generate feasible portfolio by combining r_max and r_min;

double lambda = (r-r_max)/(r_min-r_max);

x[i_min]=lambda;

x[i_max]=(1-lambda);

PDF created with pdfFactory trial version www.pdffactory.com

Page 82: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

81 ⓒ 2004, 홍창수

double min_var = CFSQP_optimize_with_constraints_and_bounds(

x,

MV_SHORT_no_assets,

MV_SHORT_objective,

0,0,0,2, // 2

linear equality constraints

MV_SHORT_constraints,

x_min,

x_max);

for (i=0; i<MV_SHORT_no_assets; ++i) {

w.element(i, 0) =x[i];

};

delete [] x;

delete [] x_min;

delete [] x_max;

w.Release();

return w;

};

15. 기간구조(term structure) 알고리즘14

이장은 기간구조(투자기간과 이자율간의 관계)를 추정하는 여러 알고리즘을 살펴보기로 한다.

Subsections

• 기간구조의 계산

• 현재 관측된 기간구조의 이용

o 선형보간(線形補間 )

§ 수익률의 선형보간

§ 선도금리의 선형보간(線形補間 )

14 이자율 기간구조(term structure)는 선형보간, McCulloch(1975, 3차 스플라인), Nelson-Siegel모형등 채권시장에서 관찰된 자료를 이

용하여 기간구조를 잘 나타내는 함수형태를 찾는 통계적방법과 단기 이자율의 확률모형(Stocastic process)을 설정한후 그에 따른 금리

기간구조를 추정하는 이론적 방법 (금리모형)이 있다. (역자주)

PDF created with pdfFactory trial version www.pdffactory.com

Page 83: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

82 ⓒ 2004, 홍창수

• 기간구조의 추정(期間構造의 推定 )

o Nelson Siegel 함수형태(1987)

o Bliss (1989)

o 3차 스플라인

• Term structure models.

o Vasicek 모형

o Cox Ingersoll Ross 모형

§ 할인율의 계산(割引率의 計算)

o Brown과 Dydvig에 사용된 CIR 모형 추정

§ 할인율(割引率 )

관측된 기간 구조의 이용

현재의 기간 구조를 이용하기위해, 시장의 움직임으로부터 추정하는 방법이 있다.그 가장 간단한 방법이 현재 관측된

수익률을 선형 보간하는 방식이다.

선형 보간(Linear Interpolation)

다양한 만기까지의 기간을 가지는 수익률의 집합이 있으면, 기간 구조를 추정하는 방법으로서는 선형 회귀를 하는 것이

가장 단순한 방법이다.많은 경우는 그것으로 충분하다(good enough).

수익률의 선형 보간

이 알고리즘은 만기가 다가와 수익률이 상승해 나가는 것과 가정하고 있는 것에 주의해라.

// file lin_intp.cc

// author: Bernt A Oedegaard.

// given a set of yields, produce a term structure by linear interpolation.

#include "fin_algoritms.h"

double term_structure_yield_linearly_interpolated(double time,

const vector<double>& obs_times,

const vector<double>& obs_yields)

PDF created with pdfFactory trial version www.pdffactory.com

Page 84: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

83 ⓒ 2004, 홍창수

// assume the yields are in increasing time to maturity order.

{

int no_obs = obs_times.size();

if (no_obs<1) return 0;

double t_min = obs_times[0];

if (time <= t_min) return obs_yields[0]; // earlier than lowest obs.

double t_max = obs_times[no_obs-1];

if (time >= t_max) return obs_yields[no_obs-1]; // later than latest obs

int t=1; // find which two observations we are between

while ( (t<no_obs) && (time>obs_times[t])) { ++t; };

double lambda = (obs_times[t]-time)/(obs_times[t]-obs_times[t-1]);

// by ordering assumption, time is between t-1, t

double r = obs_yields[t-1] * lambda + obs_yields[t] * (1.0-lambda);

return r;

};

As an alternative to

선도금리의 선형 보간

이 알고리즘은 만기까지 기간차수가 증가하고 있다는 것을 순서화 하였다.

// file lin_intp.cc

// author: Bernt A Oedegaard.

// given a set of forward yields, produce a term structure by linear interpolation.

#include "fin_algoritms.h"

double term_structure_forward_linearly_interpolated(double time,

const vector<double>& obs_times,

const vector<double>& obs_forwards) {

// assume observations in increasing time to maturity order.

int no_obs = obs_times.size();

if (no_obs<1) return 0;

double t_min = obs_times[0];

if (time <= t_min) return obs_forwards[0]; // earlier than lowest obs.

double t_max = obs_times[no_obs-1];

PDF created with pdfFactory trial version www.pdffactory.com

Page 85: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

84 ⓒ 2004, 홍창수

if (time >= t_max) return obs_forwards[no_obs-1]; // later than latest obs

int t=1; // find which two observations we are between

while ( (t<no_obs) && (time>obs_times[t])) { ++t; };

double lambda = (obs_times[t]-time)/(obs_times[t]-obs_times[t-1]);

// by ordering assumption, time is between t-1, t

double r = obs_forwards[t-1] * lambda + obs_forwards[t] * (1.0-lambda);

return r;

};

Subsections

• Nelson Siegel 함수형(1987)

• Bliss 모델(1989)

• 3차 스프라인

기간 구조의 추정

기간 구조를 명시적으로 추정하는 대신에 함수형으로 기술하는 방법이 있다.이하에 나타내는 것은 그 3개의 예 Nelson

and Siegel (1987), Bliss (1989), McCulloch (1971)이다.처음 두가지 예는 수익률을, McCulloch 모델은 할인율을

모델화하고 있다.

Nelson Siegel 함수형 (1987)

// file nels_sie.cc

// author: Bernt A Oedegaard

// purpose: Calculate the term structure proposed by Nelson and Siegel

// Parsimonious Modeling of Yield Curves, Journal of Business, (1987)

#include <math.h>

double term_structure_yield_nelson_siegel(double t,

double beta0, double beta1, double beta2,

double lambda ) {

if (t==0.0) return beta0;

PDF created with pdfFactory trial version www.pdffactory.com

Page 86: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

85 ⓒ 2004, 홍창수

double tl = t/lambda;

double r = beta0 + (beta1+beta2) * ((1-exp(-tl)) /tl) + beta2 * exp(-tl);

return r;

};

Bliss 모델(1989)

Nelson and Siegel (1987) 모델의 확장으로서Bliss (1989)가 제창되었다.

이것에는 5개의 파라미터 의 추정이 필요하다.

// file termstru_yield_bliss.cc

// author: Bernt A Oedgaard

#include <math.h>

double term_structure_yield_bliss(double t, double gamma0, double gamma1, double gamma2,

double lambda1, double lambda2) {

double r;

double t1 = t/lambda1;

double t2 = t/lambda2;

r = gamma0

+ gamma1 * ( (1-exp(-t1)) / t1 )

+ gamma2 * ( ( 1-exp(-t2)) / t2 )

+ gamma2 * ( -exp(-t2));

return r;

};

Cubic spline( 3차 스프라인)

3차 스플라인 곡선을 이용한 기간 구조 추정의 방법은 McCulloch (1971) 에 의해 제창되었다.후에 세금을 고려한 모델

McCulloch (1975) 도 제창했다.또 이것과는 별도로 Litzenberger and Rolfo (1984) 도 3차 스플라인 곡선을 이용하고

있다.

PDF created with pdfFactory trial version www.pdffactory.com

Page 87: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

86 ⓒ 2004, 홍창수

여기에 를 사건 에 대한 지시함수이다. 근사의 점(Knot)이라고 한다.곡선을 추정하기 위해서는 개의

무수가 필요하다.

스프라인 근사의 점(knot)이 알려진다면, 이것은 단순한 선형 회귀가 된다.

// file: cu_spline.cc

// author: Bernt A Oedegaard

#include <math.h>

#include <vector.h>

double term_structure_discount_factor_cubic_spline(double t,

double b1,

double c1,

double d1,

const vector<double>& f,

const vector<double>& knots)

{

// calculate the discount factor for the spline functional form.

double d = 1.0

+ b1*t

+ c1*(pow(t, 2))

+ d1*(pow(t, 3));

for (int i=0;i<knots.size() ;i++) {

if (t >= knots[i]) { d += f[i] * (pow((t-knots[i]), 3)); }

else { break; };

};

return d;

};

Subsections

• Vasicek 모델

PDF created with pdfFactory trial version www.pdffactory.com

Page 88: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

87 ⓒ 2004, 홍창수

• Cox Ingersoll Ross 모델

o 할인율의 계산

o 컴퓨터 프로그램

• CIR 모델에 의한 추정

o 할인율

기간 구조 모델15

이전 절( section)에서는 기간 구조의 함수를 비 모수적인 방법으로 추정하는 접근방법을 보았다.다음으로 기간 구조의

경제모델(economic model)을 살펴보기로 한다.

Vasicek 모델

Vasicek (1977)에 의해 개발되었다.

// file vasicek.cc

// author: Bernt A Oedegaard

#include "math.h"

double term_structure_discount_factor_vasicek(double time,

double r,

double a, double b, double sigma){

double A, B;

double sigma_sqr = sigma*sigma;

double aa = a*a;

15 단기이자율의 확률과정(stochastic process)에 대해 모형화 하고 그에 맞는 이자율 기간구조를 추정하는

방법(이론적 방법)에는 균형모형과 무차익거래모형이 있다. 균형모형은Vasicek(1977), CIR(1985), CKLS(1992)모형

있으며, 무차익거래모형은 Ho-Lee(1986), BDT(1990), Hull-White(1990, 1993), Black-Karasinski(1991), HJM(1992)모

형이 있다. 균형가격결정모형( Equilibrium Pricing Model)은 고전경제학의 이론에 기반을 두고 있다. 이는 시장에

확률적 기초부나 확률적 생산기술과 특정한 선호체계를 가진 시장참여자가 존재한다고 가정한다. 또한 시장참여자는

주어진 제약하에서 자신의 효용을 극대화 하는 최적투자, 즉 수요함수를 도출하고 여기에 시장균형조건, 즉 수요와 공

급의 일치를 도입하는 문제를 해결하는 과정에서 확률적 할인요인은 내생적으로 결정된다고 보고 있다. 반면, 차익거

래모형( No Arbitrage Pricing Mode)은 시장에 존재하는 자산중에서 일부자산에 내재되어 있는 확률적 할인요인을

역함수를 이용하여 파악하는데 이를 역공학(reverse engineering)이 라 한다. 이 모형은 균형모형에서 시

장참여자들의 선호체계를 효용함수로 모형화 할 때 발생할 수 있는 misspecification문제가 생기지 않는

다는 장점이 있다. (역자주)

PDF created with pdfFactory trial version www.pdffactory.com

Page 89: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

88 ⓒ 2004, 홍창수

if (a==0.0){

B = time;

A = exp(sigma_sqr*pow(time, 3))/6.0;

}

else {

B = (1.0 - exp(-a*time)) /a;

A = exp( ((B-time)*(aa*b-0.5*sigma_sqr)) /aa -((sigma_sqr*B*B)/(4*a)));

};

double d = A*exp(-B*r);

return d;

}

Cox Ingersoll Ross 모델16

이 모델은 Cox et al. (1985) 에 기록되고 있어, 일반 균형 모델(equilibrium model)을 기초로 구축되고 있어 학술적인

분야에서는 잘 이용된다.

할인율의 계산

단기 이자율은

T 시점에 있어서의 할인율은

여기서,

16 Vasicek모형과는 달리 CIR모형의 경우는 dw항이 rσ 로 정의되는 차이가 있다. 제곱근 과정(square root process)은 단기이자율의 수준

이 낮을수록 변동성도 감소하게 되므로 Vasicek모형의 단점으로 지적된 이자율이 음(-)이 될수 있는 문제를 피할수 있다.(역자주)

PDF created with pdfFactory trial version www.pdffactory.com

Page 90: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

89 ⓒ 2004, 홍창수

또한 다섯가지 모수(parameter)의 의미는 이하와 같다.

1. - 단기 이자율

2. - 평균회귀 파라미터

3. - 시장 리스크 파라미터

4. - 장기 평균

5. - 분산

컴퓨터 알고리즘

// file termstru_discfact_cir.cc

// author: Bernt A Oedegaard

#include <math.h> // mathematics library

double term_structure_discount_factor_cir(double t,

double r,

double kappa,

double lambda,

double theta,

double sigma)

// this is the original CIR formulation of their term structure.

{

double sigma_sqr=pow(sigma, 2);

double gamma = sqrt(pow((kappa+lambda), 2)+2.0*sigma_sqr);

double denum = (gamma+kappa+lambda)*(exp(gamma*t)-1) +2*gamma;

double p=2*kappa*theta/sigma_sqr;

double enum1= 2*gamma*exp(0.5*(kappa+lambda+gamma) *t);

double A = pow((enum1/denum), p);

double B = (2*(exp(gamma*t)-1)) /denum;

double dfact=A*exp(-B*r);

return dfact;

};

PDF created with pdfFactory trial version www.pdffactory.com

Page 91: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

90 ⓒ 2004, 홍창수

Brown and Dybvig 에 의해 추정된 CIR 모델

Cox et al. (1985) 모형이 채권가격의 횡단면적으로 추정한것이라면, 모든 파라미터는 데이터로부터 식별할수 있는 것은

아니다..Brown and Dybvig (1986)가 모형을 제시한것처럼, 4개의 요소 가 따로 따로 추정 가능하다.

할인율

// file esti_cir.cc

// author Bernt Arne Oedegaard

#include <math.h>

double term_structure_discount_factor_estimated_cir( double t, // time to maturity.

double r, // short interest rate.

double phi1,

double phi2,

double phi3)

{

double tmp = (phi2*(exp(phi1*t)-1.0) +phi1);

double A = (phi1*exp(phi2*t)) /tmp;

A = pow(A, phi3);

double B = (exp(phi1*t)-1.0) /tmp;

double dfact = A*exp(-B*r);

return dfact;

}

PDF created with pdfFactory trial version www.pdffactory.com

Page 92: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

91 ⓒ 2004, 홍창수

Chapter 16. 고정수익 모델링

(조건부 청구권을 중점으로)

여기에서는 고정 수익 증권(fixed income securities)에 관한 파생상품(derivative)에 관한 모델에 접한다.

Subsections

• Black Scholes bond pricing.

o 컴퓨터 프로그램

• Rendleman Bartter 모델

o 새로운 학습을 위해서

• Vasicek 모델

Black Scholes모형에 의한 채권 가격결정

블랙-숄즈(Black Scholes)모형은 제한적인 가정하에서 사용될수 있으나, 채권가격의 변동성이 일정하다는 가정은

비현실적이다.

Computer Algoritm, Bond option price, Black Scholes

// file bondopt_bs_call.cc

// author: Bernt A Oedegaard.

#include <cmath>

#include "normdist.h"

double bond_option_price_call_zero_black_scholes(

double B, double X, double r, double sigma, double time)

{

double time_sqrt = sqrt(time);

double d1 = (log(B/X)+r*time)/(sigma*time_sqrt) + 0.5*sigma*time_sqrt;

double d2 = d1-(sigma*time_sqrt);

double c = B * N(d1) - X * exp(-r*time) * N(d2);

return c;

};

PDF created with pdfFactory trial version www.pdffactory.com

Page 93: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

92 ⓒ 2004, 홍창수

// file bondopt_call_coupon.cc

// author: Bernt A Oedegaard.

#include <cmath>

#include "normdist.h"

#include "fin_algoritms.h"

double bond_option_price_call_coupon_bond_black_scholes(

double B, double X, double r, double sigma, double time,

vector<double> coupon_times, vector<double> coupon_amounts){

for (unsigned int i=0;i<coupon_times.size();i++) { // subtract present value of coupons

if (coupon_times[i]<=time) { // coupon paid befor option expiry

B -= coupon_amounts[i] * exp(-r*coupon_times[i]);

};

};

return bond_option_price_call_zero_black_scholes(B,X,r,sigma,time);

};

Rendleman Bartter 모델

이자율 조건부 청구권의 가치평가에 있어 Rendleman Bartter 모형의 접근법은 아주 단순한 방법의 하나이다.

필수적으로, 블랙-숄즈 모형에서 사용하는것과 같은 옵션으로 근사시키는 이항트리모형과 동일한 이항모형.접근방법이

적용 가능하나ᅳ 여기에 확률 변수가 이자율이며, 어떤방식으로 할인하는가 하는 것 자체를 구현할 필요가 있다. 덧붙여

여기에서는 Hull (1993) (page 385)의 기법에 따르고 있다.

// file rend_bar.cc

// author: Bernt A Oedegaard

#include <cmath>

#include <algorithm>

#include <vector>

double bond_option_price_call_zero_american_rendleman_bartter(double X,

double option_maturity,

double S,

double M, // term structure paramters

double interest, // current short interest rate

double bond_maturity, // time to maturity for

underlying bond

double maturity_payment,

PDF created with pdfFactory trial version www.pdffactory.com

Page 94: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

93 ⓒ 2004, 홍창수

int no_steps) // call on a zero coupon

bond.

{

double delta_t = bond_maturity/no_steps;

double u=exp(S*sqrt(delta_t));

double d=1/u;

double p_up = (exp(M*delta_t) -d)/(u-d);

double p_down = 1.0-p_up;

vector<double> r(no_steps+1);

r[0]=interest*pow(d, no_steps);

double uu=u*u;

int i;

for (i=1;i<=no_steps;++i){ r[i]=r[i-1]*uu;};

vector<double> P(no_steps+1);

for (i=0;i<=no_steps;++i){ P[i] = maturity_payment; };

int no_call_steps=int(no_steps*option_maturity/bond_maturity);

for (int curr_step=no_steps;curr_step>no_call_steps;--curr_step) {

for (i=0;i<curr_step;i++) {

r[i] = r[i]*u;

P[i] = exp(-r[i]*delta_t)*(p_down*P[i]+p_up*P[i+1]);

};

};

vector<double> C (no_call_steps+1);

for (i=0;i<=no_call_steps;++i){ C[i]=max(0.0, P[i]-X); };

for (int curr_step=no_call_steps;curr_step>=0;--curr_step) {

for (i=0;i<curr_step;i++) {

r[i] = r[i]*u;

P[i] = exp(-r[i]*delta_t)*(p_down*P[i]+p_up*P[i+1]);

C[i]=max(P[i]-X, exp(-r[i]*delta_t)*(p_up*C[i+1]+p_down*C[i]));

};

};

return C[0];

};

새로운 학습을 위해서

Hull (1993)의 섹션 15에 짧은 논의가 게재되고 있다. 원논문은 Rendleman (1979) 및Rendleman and Bartter

(1980)를 봐라.

PDF created with pdfFactory trial version www.pdffactory.com

Page 95: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

94 ⓒ 2004, 홍창수

Vasicek 모델의 채권 가격 설정

기간 구조가 Vasicek 모델에 따른다면 Jamshidan (1989) 에 의한 무이표(zero coupon)모델의 가격의 해가 된다.

Vacisek 모델에서는 다음 식과 같이 가정한다.

여기서, , , 는 상수로 한다.이미 할인율의 계산방법은 알고 있다, 유러피언 콜의 계산은 이하와 같이 된다.

을 시점에 있어서의 할인율 의 무 이표(zero-coupon)채의 가격으로 한다. 만기 , 만기일에 있어서의

할인율이 인 유러피언 콜의 시점에 있어서의 가격은 이하와 같다.(Jamshidan (1989) 및 Hull (1993) 참조.)

여기서,

이다.

또 의 경우에는

PDF created with pdfFactory trial version www.pdffactory.com

Page 96: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

95 ⓒ 2004, 홍창수

된다.

// file bondopt_call_vasicek.cc

// author: Bernt A Oedegaard.

#include <cmath>

#include "normdist.h"

#include "fin_algoritms.h"

double bond_option_price_call_zero_vasicek(double X, // exercise price

double r, // current interest rate

double option_time_to_maturity,

double bond_time_to_maturity,

double a, // parameters

double b,

double sigma)

{

double T_t = option_time_to_maturity;

double s_t = bond_time_to_maturity;

double T_s = s_t-T_t;

double v_t_T;

double sigma_P;

if (a==0.0) {

v_t_T = sigma * sqrt ( T_t ) ;

sigma_P = sigma*T_s*sqrt(T_t);

}

else {

v_t_T = sqrt (sigma*sigma*(1-exp(-2*a*T_t))/(2*a));

double B_T_s = (1-exp(-a*T_s)) /a;

sigma_P = v_t_T*B_T_s;

};

double h = (1.0/sigma_P) * log (

term_structure_discount_factor_vasicek(s_t, r, a, b, sigma)/

(term_structure_discount_factor_vasicek(T_t, r, a, b, sigma) *X) )

+ sigma_P/2.0;

double c =

term_structure_discount_factor_vasicek(s_t, r, a, b, sigma) *N(h)

PDF created with pdfFactory trial version www.pdffactory.com

Page 97: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

96 ⓒ 2004, 홍창수

-X*term_structure_discount_factor_vasicek(T_t, r, a, b, sigma) *N(h-sigma_P);

return c;

};

정규 분포의 근사치 / Normal Distribution approximations.

1 변수 또는 2 변수의 정규 분포의 누적 분포 함수의 수치계산에 대해.

분포 함수를 아래의 식에서 준다.

만약 이 평균 0 분산 1 의 정규 분포에 따른다면 아래의 공식을 얻는다.

와 가 평균 0 분산 1 의 정규 분포에 따른다면, 이라고 의 상관계수를 로서 아래의 식을

얻는다.

// normdist.h

// author: Bernt A Oedegaard

#ifndef _NORMAL_DIST_H_

#define _NORMAL_DIST_H_

double n(double z); // normal distribution function

double n(double r, double mu, double sigmasqr); // normal distribution function

double N(double z); // cumulative probability of normal

double N(double a, double b, double rho); // cum prob of bivariate normal

#endif

PDF created with pdfFactory trial version www.pdffactory.com

Page 98: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

97 ⓒ 2004, 홍창수

// normdist.cc

// numerical approximations to univariate N(z) and bivariate N(a, b, rho)

// normal distributions

#include <cmath> // math functions.

#ifndef PI

#define PI 3.141592653589793238462643

#endif

double n(double z) { // normal distribution function

return (1.0/sqrt(2.0*PI)) *exp(-0.5*z*z);

};

double n(double r, double mu, double sigma) { // normal distribution function

double nv = 1.0/(sqrt(2.0*PI) *sigma);

double z=(r-mu) /sigma;

nv *= exp(-0.5*z*z);

return nv;

};

// cumulative univariate normal distribution.

// This is a numerical approximation to the normal distribution.

// See Abramowitz and Stegun: Handbook of Mathemathical functions

// for description. The arguments to the functions are assumed

// normalized to a (0,1 ) distribution.

double N(double z) {

double b1 = 0.31938153;

double b2 = -0.356563782;

double b3 = 1.781477937;

double b4 = -1.821255978;

double b5 = 1.330274429;

double p = 0.2316419;

double c2 = 0.3989423;

if (z > 6.0) { return 1.0; }; // this guards against overflow

PDF created with pdfFactory trial version www.pdffactory.com

Page 99: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

98 ⓒ 2004, 홍창수

if (z < -6.0) { return 0.0; };

double a=fabs(z);

double t = 1.0/(1.0+a*p);

double b = c2*exp((-z)*(z/2.0));

double n = ((((b5*t+b4) *t+b3) *t+b2) *t+b1) *t;

n = 1.0-b*n;

if ( z < 0.0 ) n = 1.0 - n;

return n;

}

// Numerical approximation to the bivariate normal distribution,

// as described e.g. in Hulls book

inline double f(double x, double y, double aprime, double bprime, double rho) {

double r = aprime*(2*x-aprime) + bprime*(2*y-bprime)

+ 2 * rho * (x-aprime) * (y-bprime);

return exp(r);

};

inline double sgn( double x) { // sign function

if (x>=0.0) return 1.0;

return -1.0;

};

double N(double a, double b, double rho) {

if ( (a<=0.0) && (b<=0.0) && (rho<=0.0) ) {

double aprime = a/sqrt(2.0*(1.0-rho*rho));

double bprime = b/sqrt(2.0*(1.0-rho*rho));

double A[4]={0.3253030, 0.4211071, 0.1334425, 0.006374323};

double B[4]={0.1337764, 0.6243247, 1.3425378, 2.2626645 };

double sum = 0;

for (int i=0;i<4;i++) {

for (int j=0; j<4; j++) {

sum += A[i]*A[j]* f(B[i], B[j], aprime, bprime, rho);

};

};

sum = sum * ( sqrt(1.0-rho*rho) /PI);

return sum;

}

else if ( a * b * rho <= 0.0 ) {

PDF created with pdfFactory trial version www.pdffactory.com

Page 100: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

99 ⓒ 2004, 홍창수

if ( ( a<=0.0 ) && ( b>=0.0 ) && (rho>=0.0) ) {

return N(a) - N(a, -b, -rho);

}

else if ( (a>=0.0) && (b<=0.0) && (rho>=0.0) ) {

return N(b) - N(-a, b, -rho);

}

else if ( (a>=0.0) && (b>=0.0) && (rho<=0.0) ) {

return N(a) + N(b) - 1.0 + N(-a, -b, rho);

};

}

else if ( a * b * rho >= 0.0 ) {

double denum = sqrt(a*a - 2*rho*a*b + b*b);

double rho1 = ((rho * a - b) * sgn(a)) /denum;

double rho2 = ((rho * b - a) * sgn(b)) /denum;

double delta=(1.0-sgn(a) *sgn(b))/4.0;

return N(a, 0.0, rho1) + N(b, 0.0, rho2) - delta;

};

return -99.9; // should never get here

};

참고문헌 / References

단일 변량 정규근사는 Abramowiz and Stegun (1964)를 참조. Hull, 1993, (현재 5판 2000)책의 이변량 정규분포에

관한 특정 알고리즘 구현을 참조할 것.

C++에 관한 노트와 원시 코드 / A note on C++ and the source code

Subsections

• 원시 코드의 입수

• 라이브러리

• 비C++플러그 라마를 위한 C++해설

• 수학 기호

o 지수함수

PDF created with pdfFactory trial version www.pdffactory.com

Page 101: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

100 ⓒ 2004, 홍창수

o 증분·감 분

• 배열의 동적 정의

• for 스테이트먼트의 서식

• #include 의 구조

• 클래스의 개념

• 다른 언어에 있어서의 실장

• 레퍼런스

소스 이용 / Source availability

원시 코드는 필자의 홈 페이지[역자주:구체적으로는 http://finance.bi.no/~bernt/gcc_prog/]로부터 ZIP 형식에서

압축된 파일로서 입수할 수 있다.이것들은GNU C++ 의 최신 버젼[역주:필자가 이 원고를 쓴 1999/9/9시점에서의

이야기.]그리고 동작 확인이 끝난 상태이다.원시 코드에서는 C++의 STL(Standard Template Library)를 이용하고 있기

때문에, 다른 컴파일러에서는 모든 파일이 컴파일 가능하지 않을지도 모르다.만약 당신이 사용의 컴파일러가 필요한 헤더

파일의 부족을 경고해 온다면, STL 헤더 파일이 다른 파일명칭이 아닌가 확인 해 주었으면 한다.원시 코드는

C++라이브러리를 위한 신ANSI 표준에 준거하고 있다.만약 당신의 사용의 컴파일러가 2~3년전의 것이면 그것은 STL에

대응하고 있지 않을지도 모르다.덧붙여 GCC 컴파일러는 인터넷 경유로 프리로 입수 가능하다 해, 현재 사용되고 있는

OS의 대부분으로 가동한다.

라이브러리 / Libraries

C++의 장점의 하나에, 언어를 확장하기 위한 라이브러리의 이용을 들 수 있다.가능한 한 라이브러리는 사용하지 말고,,

선형대수를 수행하는 라이브러리를 사용한다. 그것은 사용하지 않고 있는 것보다 사용하는 편이 프로그램에 벡터 표기를

사용할 수 있게 되는(그 덕분에 여분의 루프가 불필요하게 되어, 사소한 실수를 막을 수가 있다) 등 간결하고 알기 쉬운

것이 되기 때문이다.잘 정의된 라이브러리를 이용하면, 수식을 써 계산하는 것과 같이 기술하는 것으로 프로그램을 쓸 수가

있다. 본문서로 이용하고 있는 선형대수의 라이브러리는 newmat 로 불리고 있으며, 이것은 퍼블릭 라이센스이다.최신의

버젼은 주요한 FTP 사이트에서 newmat09.zip 또는 newmat09.tar.gz 로 찾아낼 수가 있을것이다.

[역주:2002/08/05시점에서는 newmat10 이다.다운로드는 http://www.robertnz.net/ol_doc.htm 로부터 가능.]

이 라이브러리를 이용하면 프로그램의 기술은 매우 간단하게 된다.예를 들면 아래와 같은 것이 된다.

PDF created with pdfFactory trial version www.pdffactory.com

Page 102: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

101 ⓒ 2004, 홍창수

상기에 대응해 행렬 A 와 열 b 를 정의하면(자),

역행열은 : Matrix Ainv = A.i(); 와

적은 : Matrix C = A * b.t(); 와

연립 방정식으로서의 의 해: Matrix x = A.i() *b; 로서 기술할 수가 있다.

선형대수의 경우는 행렬 연산의 표기가 가능하면 매우 유용하게 된다.우량한 라이브러리를 선택하면, 큰 효과를 발휘한다.

비C++프로그래머를 위한 C++해설

C 또는 C++를 모르는 경우에는 잘 모를 것이다, 몇개의 프로그램으로 사용하고 있는 C++특유의 일에 대해 설명한다.

Subsections

• 지수함수

• 증분과 감 분

수학 기호 / Mathematical operators

지수함수 / Exponentiation

사칙 연산 기호 ( )는 그대로 사용할 수 있지만, 지수함수는 언어의 일부에서는 없고, 수학 관계의 라이브러리

중에서 정의되는 함수로서 구현되고 있다.

• pow(x, n) 는 을 계산한다.

• exp(r) 는 을 계산한다.

증분과 감소 / Increment and decrement.

변수를 1씩 증가(또는 감소)시키고 싶을 때, 많은 언어에서는

int i=0

i = i+1

i = i-1

로 기술하지만, C++에서는 짧게 이하와 같이 기술할 수가 있다.

int i=0

PDF created with pdfFactory trial version www.pdffactory.com

Page 103: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

102 ⓒ 2004, 홍창수

i++

i--

이것은 직감적이라고는 말하기 어렵지만, 추상적인 데이터 구조를 취급해 때는 편리하게 될 수도 있어, 충분히 실용적인

것은 않다고 말할 수 있다.예를 들면date 라고 하는 클래스를 정의해, 그 「다음날 」의 값을 갖고 싶으면 이하와 같이

기술하는 것만으로 끝난다.

date d(1,1,1995)

d++

결과는 2jan95 가 된다.

배열의 동적 정의 / Dynamically sized arrays.

많은 프로그램 언어에서는 실행중의 배열의 사이즈 변경을 허락하지 않는다.Fortran 과 Pascal에서는 통상, 배열의

최대치로 정의해 두는 것이 많아, 가능한 한 실제로 사용하는 사이즈로부터 크게 초과하지 않는 것이 바람직하다.만약 크게

초과해 버렸다면 메모리를 낭비 한 것이 된다.

그러나 C++의 최신 버젼에서는 STL(Standard Template Library)를 짜넣고 있다.이 라이브러리에서 가장 유용한 것은

벡터 템플릿 <>으로, 이전의 배열에의 조작을 포함하여 자유로이 이용할 수가 있다. 대부분의 루틴으로 array 대신에

double을 이용하고 있는 이유는 파라미터의 수를 줄일 수가 있기 때문이다.

for 스테이트먼트의 서식 / The form of the for statement.

C 또는 C++에 있어서의 for 스테이트먼트는 Fortran 나 Pascal 보다 일반적이다.

조작을 n 회 반복하고 싶다면 이와 같이 기술한다.

for (int i 0; i n; i++) {

some_operation(i)

}

for 스테이트먼트는 3개의 부분으로부터 구성된다.최초의 부분은 개시 조건 (i=0)을 준다.다음의 부분은 종료 조건 ( i

n), 마지막 부분은 증분을 나타낸다.이것은 i++ 와 있으면 i 의 값을 반복할 것에 1개씩 늘어나 가는 것을

의미한다.이것이 for 스테이트먼트의 전형적인 서식이다.C에서는 프로그램의 간단함을 요구하기 위해서(가독성을 희생하는

일이 있지만), 본문서에서는 전형적 서식에서 통일하기 위하여 노력하고 있다.

#include 의 구조 / The #include construct.

컴파일러에서는 반드시 사용하기 전에 정의되어 있지 않으면 안 된다.그 때문에 C언어나 C++에서는 함수나 매크로를

정의한 헤더 파일(header file)을 이용한다. 예를 들면 본문서가 많은 공식에서 이용하는 정규 분포의 누적 정규 밀도 함수

N(z)에서는 normdist.h 로 선언하고 있다. 아래에는 그 코드를 보여주고 있다.

// normdist.h

// author: Bernt A Oedegaard

PDF created with pdfFactory trial version www.pdffactory.com

Page 104: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

103 ⓒ 2004, 홍창수

#ifndef _NORMAL_DIST_H_

#define _NORMAL_DIST_H_

double n(double z); // normal distribution function

double n(double r, double mu, double sigmasqr); // normal distribution function

double N(double z); // cumulative probability of normal

double N(double a, double b, double rho); // cum prob of bivariate normal

#endif

이 헤더 파일에서는 2개의 정규 분포의 확률 밀도 함수(1 변수의 경우와 2 변수의 경우)를 정의하고 있다. 만약 N()에

1개의 값만 건네받았을 경우에는 1 변수의 확률 밀도 함수가 참조된다.즉N(0.0)이면0.5를 돌려준다.

한편, 3개의 값이 건네받았을 경우, 2 변수의 확률 밀도 함수가 참조되어N(0.0, 0.0, 0.0) 는0.25를 돌려준다. 이

함수를 서브루틴으로서 이용하고 싶으면 include 스테이트먼트를 이용한다. 이 헤더 파일의 이름을 normdist.h 로 하면,

완전한 프로그램은 이하와 같이 된다.

#include "normdist.h"

int main(){

cout " Bivariate cum. normal dist (0,0,0) = "

<< N(0,0,0) << endl;

}

이 프로그램을 컴파일 해, 링크하여 실행하면 이하와 같은 표시가 된다.

Bivariate cum. normal dist (0,0,0) = 0.25

클래스의 개념 / The class concept.

다른 언어에 있어서의 알고리즘 구현/ (Implementation in other programming languages. )

다른 언어에의 알고리즘 구현에 대해 지금으로서는 문제가 되고 있는 것은, Fortran77 나 Pascal 에 대해,

서브루틴이나 함수 호출때의 인수의 길이의 가변성에 관한 제한이다.이러한 언어에서는 무엇인가 좋은 방법을 생각하지

않으면 안 된다. 무엇보다, 각각의 언어별의 수치해석 구현을 핸들링하는 방책이 없는 것은 아니지만. Mathmatica나

Matlab으로의 소스구현에는 큰 문제가 없다.

참고문헌 / References.

C++의 입문으로서는 Lippman (1992)가 좋을 것이다.주된 소스에 대해서는Stroustrup (1991)를 참고하라.STL에

대해서는Musser and Saini (1996)를 참조.

PDF created with pdfFactory trial version www.pdffactory.com

Page 105: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

104 ⓒ 2004, 홍창수

감사의 말씀 / Acknowledgements.

이 문서를 넷상에서 공개한 이래, 극히 많은 메일을 받았다.프로그램의 버그를 지적하는 것도 있었다.그 중에서도 특히

유용한 시사나 지적을 해 준 분들의 이름을 명기하여 감사의 뜻을 전한다.

[email protected]

Michael L Locher

Lars Gregori

Steve Bellantoni <[email protected]>

용어 색인 (用語索引)

Gamma

Gamma

Theta

Theta

Rho

Rho

Barone-Adesi and Whaley

Barone-Ades-Whaley법에 따르는 아메리칸 옵션가격의 2차 근사

binomial option price

이항모델에 의한 옵션 가격 설정

Black

futures option

Black 모델

bond

국채의 계산

price

국채 가격

yield

수익률

bond option

Black Scholes

Black Scholes 모델(국채의 가격 설정)

Vasicek

Vasicek 모델의 가격 설정

Brown and Dybvig

CIR 모델에 의한 추정

cash flow

현금흐름(cash flow)

PDF created with pdfFactory trial version www.pdffactory.com

Page 106: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

105 ⓒ 2004, 홍창수

CIR

estimated

CIR 모델에 의한 추정

class

클래스의 개념

Cox Ingersoll Ross, see CIR

CIR 모델에 의한 추정

currency

외국 통화 옵션의 계산

option

외국 통화 옵션

currency option

American

미국형 옵션

European

유럽형 옵션

delta

Delta

binomial

Delta

duration

듀레이션.

Macaulay

맥콜레이 듀레이션

modified

수정 듀레이션

simple

단순 듀레이션

early exercise premium

Barone-Ades-Whaley법에 따르는 아메리칸 옵션가격의 2차 근사

exotic option

이색 옵션

exp() (C++ statement)

지수함수

explicit finite differences

명시적 유한차분법의 컴퓨터 프로그램(유러피언 옵션) | 명시적 유한차분법의 컴퓨터 프로그램(아메리칸 옵션)

finite differences

유한 차분법

American

아메리칸 옵션

PDF created with pdfFactory trial version www.pdffactory.com

Page 107: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

106 ⓒ 2004, 홍창수

explicit

명시적 해법의 컴퓨터 프로그램(유러피언 옵션) | 명시적 해법의 컴퓨터 프로그램(아메리칸 옵션)

implicit

암묵적 해법의 컴퓨터 프로그램(유러피언 옵션) | 암묵적 해법의 컴퓨터 프로그램(아메리칸 옵션)

for (C++ statement)

for 스테이트먼트의 서식

futures

option

Options on futures

gamma

Gamma

geometric Brownian motion

개요

Geske and Johnson

Geske-Johnson법에 따르는 미국형 옵션 풋 가격의 근사

hedging parameters

Black Scholes

편미분으로 나타내지는 가격 지표

implicit finite differences

암묵적 유한차분법의 컴퓨터 프로그램(유러피언 옵션) | 암묵적 유한차분법의 컴퓨터 프로그램(아메리칸 옵션)

implied volatility

calculation

내재변동성(implied volatility)

include (C++ statement)

#include 의 구조

internal rate of return

내부 이익율

introduction

irr

내부 이익율

unique

해의 유일성의 확인

Jump Diffusion

Jump diffusion 모델

libraries

programming

라이브러리

lookback option

룩 백 옵션

PDF created with pdfFactory trial version www.pdffactory.com

Page 108: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

107 ⓒ 2004, 홍창수

Merton

Jump Diffusion

Jump diffusion 모델

modified duration

수정 듀레이션

np

현재 가치

option

currency

외국 통화 옵션

exotic

이색 옵션

futures

Options on futures | Black 모델

lookback

룩 백 옵션

option price

binomial

이항모델에 의한 옵션 가격 설정

simulated

시뮬레이션

partial derivatives

binomial

헤지 파라미터의 추정

Black Scholes

Black Scholes 편미분의 알고리즘 구현

partials

Black Scholes

Black Scholes 편미분의 알고리즘 구현

pow() (C++ statement)

지수함수

present value

현재 가치

quadratic approximation

Barone-Ades-Whaley법에 따르는 미국형 옵션가격의 2차 근사

rho

Rho

simulation

시뮬레이션

general

PDF created with pdfFactory trial version www.pdffactory.com

Page 109: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

108 ⓒ 2004, 홍창수

시뮬레이션에 의한 옵션 가격 설정의 일반적 접근법

theta

Theta

unique irr

해의 유일성의 확인

vega

Vega

volatility

implied

내재변동성(implied volatility)

PDF created with pdfFactory trial version www.pdffactory.com

Page 110: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

109 ⓒ 2004, 홍창수

참고문헌 / Bibliography

Milton Abramowiz and Irene A Stegun.

Handbook of Mathematical Functions.

National Bureau of Standards, 1964.

Giovanni Barone-Adesi and Robert E Whaley.

Efficient analytic approximation of American option values.

Journal of Finance, 42(2):-20, June 1987.

Per Berck and Knut Sydsæter.

Matematisk Formelsamling for økonomer.

Universitetsforlaget, 2 edition, 1995.

Fisher Black.

The pricing of commodity contracts.

Journal of Financial Economics, 3:-79, 1976.

Fisher Black and M S Scholes.

The pricing of options and corporate liabilities.

Journal of Political Economy, 7:-54, 1973.

Robert R Bliss.

Fitting term structures to bond prices.

Working paper, University of Chicago, January 1989.

Phelim P Boyle.

Options: A Monte Carlo approach.

Journal of Financial Economics, 4:-38, 1977.

Richard A Brealey and Stewart C Myers.

Principles of Corporate Finance.

McGraw-Hill, fourth edition, 1996.

Michael Brennan and Eduardo Schwartz.

Finite difference methods and jump processes arising in the pricing of contingent claims: A synthesis.

Journal of Financial and Quantitative Analysis, 13:-74, 1978.

Stephen J Brown and Philip H Dybvig.

The empirical implications of the Cox, Ingersoll, Ross theory of the term structure of interest rates.

Journal of Finance, 41:-32, 1986.

J Cox, S Ross, and M Rubinstein.

Option pricing: A simplified approach.

Journal of Financial Economics, 7:-263, 1979.

John Cox and Mark Rubinstein.

Options markets.

Prentice-Hall, 1985.

PDF created with pdfFactory trial version www.pdffactory.com

Page 111: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

110 ⓒ 2004, 홍창수

John C Cox, Jonathan E Ingersoll, and Stephen A Ross.

A theory of the term structure of interest rates.

Econometrica, 53:-408, 1985.

M B Garman and S W Kohlhagen.

Foreign currency option values.

Journal of International Money and Finance, 2:-37, 1983.

Robert Geske.

The valuation of compound options.

Journal of Financial Economics, 7:-81, March 1979.

Robert Geske and H E Johnson.

The american put valued analytically.

Journal of Finance, XXXIX(5), December 1984.

M Barry Goldman, Howard B Sosin, and Mary Ann Gatto.

Path-dependent options: Buy at the low, sell at the high.

Journal of Finance, 34, December 1979.

J O Grabbe.

The pricing of call and put options on foreign exchange.

Journal of International Money and Finance, 2:-53, 1983.

Chi-fu Huang and Robert H. Litzenberger.

Foundations for financial economics.

North-Holland, 1988.

John Hull.

Options, Futures and other Derivative Securities.

Prentice-Hall, second edition, 1993.

John Hull.

Options, Futures and other Derivatives.

Prentice-Hall, third edition, 1997.

F Jamshidan.

An exact bond option pricing formula.

Journal of Finance, 44:-9, March 1989.

Stanley B Lippman.

C++ primer.

Addison-Wesley, 2 edition, 1992.

Robert H. Litzenberger and Jaques Rolfo.

An international study of tax effects on government bonds.

Journal of Finance, 39:-22, 1984.

J Houston McCulloch.

Measuring the term structure of interest rates.

Journal of Business, 44:-31, 1971.

PDF created with pdfFactory trial version www.pdffactory.com

Page 112: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

111 ⓒ 2004, 홍창수

J Houston McCulloch.

The tax adjusted yield curve.

Journal of Finance, 30:-829, 1975.

Robert C Merton.

The theory of rational option pricing.

Bell Journal, 4:-183, 1973.

David R Musser and Atul Saini.

STL Tutorial and Reference Guide: C++ programming with the standard template library.

Addison-Wesley, 1996.

Charles R Nelson and Andrew F Siegel.

Parsimonious modelling of yield curves.

Journal of Business, 60(4):-89, 1987.

Carl J Norstrom.

A sufficient conditions for a unique nonnegative internal rate of return.

Journal of Financial and Quantitative Analysis, 7(3):-39, 1972.

William Press, Saul A Teukolsky, William T Vetterling, and Brian P Flannery.

Numerical Recipes in C.

Cambridge University Press, second edition, 1992.

Richard J Rendleman and Brit J Bartter.

Two-state option pricing.

Journal of Finance, 34(5):-1110, December 1979.

Richard J Rendleman and Brit J Bartter.

The pricing of options on debt securities.

Journal of Financial and Quantitative Analysis, 15(1):-24, March 1980.

Richard Roll.

An analytical formula for unprotected American call options on stocks with known dividends.

Journal of Financial Economics, 5:-58, 1977.

Stephen A Ross, Randolph Westerfield, and Jeffrey F Jaffe.

Corporate Finance.

Irwin, fourth edition, 1996.

Mark Rubinstein.

Exotic options.

University of California, Berkeley, working paper, 1993.

William F Sharpe and Gordon J Alexander.

Investments.

Prentice-Hall, 4 edition, 1990.

Bjarne Stroustrup.

The C++ Programming language.

Addison-Wesley, 2 edition, 1991.

O Vasicek.

PDF created with pdfFactory trial version www.pdffactory.com

Page 113: Bernt Arne Ødegaard - MM(MacroMicro) · 연속시간 모형에 있어 미분방정식을 이용하여 구할 수 없는 경우 수치해석기법(numerical method) 즉, 이산시간

2004-9-20

112 ⓒ 2004, 홍창수

An equilibrium characterization of the term structure.

Journal of Financial Economics, 5:-88, 1977.

Robert E Whaley.

On the valuation of American call options on stocks with known dividends.

Journal of Financial Economics, 9:-1, 1981.

Paul Wilmott, Jeff Dewynne, and Sam Howison.

Option Pricing, Mathematical models and computation.

Oxford Financial Press, 1994.

ISBN 0 9522082 02.

PDF created with pdfFactory trial version www.pdffactory.com