全部版块 我的主页
论坛 金融投资论坛 六区 金融学(理论版) 金融工程(数量金融)与金融衍生品
6279 11
2013-10-09
好像没人传过。作者是挪威大学一个教授,常年用C++做实证分析,写了一本书,用C++实现了绝大多数金融模型。。代码可读性很强,有点像C Style的C++ code。 当年学geske模型时候仔细参考过此书,收获很大.


numerical receipe in finance .rar
大小:(1.06 MB)

 马上下载

本附件包括:

  • numerical receipe in finance .pdf





二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2013-10-9 07:20:48
Financial Numerical Recipes in C++.
Bernt Arne Ødegaard
April 2007

Contents
1 On C++ and programming. 5
1.1 Compiling and linking . . . . . . . . . . . . . . . 5
1.2 The structure of a C++ program . . . . . . . . . 6
1.2.1 Types . . . . . . . . . . . . . . . . . . . . 6
1.2.2 Operations . . . . . . . . . . . . . . . . . 6
1.2.3 Functions and libraries . . . . . . . . . . . 7
1.2.4 Templates and libraries . . . . . . . . . . 7
1.2.5 Flow control . . . . . . . . . . . . . . . . . 8
1.2.6 Input Output . . . . . . . . . . . . . . . . 8
1.2.7 Splitting up a program . . . . . . . . . . . 8
1.2.8 Namespaces . . . . . . . . . . . . . . . . . 9
1.3 Extending the language, the class concept. . . . 9
1.3.1 date, an example class . . . . . . . . . . . 10
1.4 Const references . . . . . . . . . . . . . . . . . . . 16
1.5 Other C++ concepts . . . . . . . . . . . . . . . . . 16
2 Matrix Tools 17
2.1 The first screen . . . . . . . . . . . . . . . . . . . 18
2.2 Linear algebra . . . . . . . . . . . . . . . . . . . . 18
2.2.1 Basic matrix operations . . . . . . . . . . 18
2.2.2 Arithmetic Matrix Operations. . . . . . . 19
2.3 Solving linear equations . . . . . . . . . . . . . . 22
2.4 Element by element operations . . . . . . . . . . 24
2.5 Function definitions . . . . . . . . . . . . . . . . 24
2.6 m files . . . . . . . . . . . . . . . . . . . . . . . . 24
2.7 Flow control . . . . . . . . . . . . . . . . . . . . . 24
2.8 Plotting . . . . . . . . . . . . . . . . . . . . . . . 24
2.9 Libraries . . . . . . . . . . . . . . . . . . . . . . . 25
2.10 References . . . . . . . . . . . . . . . . . . . . . . 25
3 The value of time 26
3.1 Present value . . . . . . . . . . . . . . . . . . . . 26
3.2 One interest rate with annual compounding . . . 27
3.2.1 Internal rate of return. . . . . . . . . . . . 30
3.3 Continously compounded interest . . . . . . . . . 34
3.3.1 Present value . . . . . . . . . . . . . . . . 35
3.4 Further readings . . . . . . . . . . . . . . . . . . 35
4 Bond Pricing with a flat term structure 36
4.1 Flat term structure with discrete, annual compounding
. . . . . . . . . . . . . . . . . . . . . . 37
4.1.1 Bond Price . . . . . . . . . . . . . . . . . 37
4.1.2 Yield to maturity . . . . . . . . . . . . . . 38
4.1.3 Duration . . . . . . . . . . . . . . . . . . . 41
4.1.4 Measuring bond sensitivity to interest
rate changes . . . . . . . . . . . . . . . . . 43
4.2 Continously compounded interest . . . . . . . . . 47
4.3 Further readings . . . . . . . . . . . . . . . . . . 50
5 The term structure of interest rates and an object lesson 51
5.1 The interchangeability of discount factors, spot
interest rates and forward interest rates . . . . . 52
5.2 The term structure as an object . . . . . . . . . . 55
5.2.1 Base class . . . . . . . . . . . . . . . . . . 55
5.2.2 Flat term structure. . . . . . . . . . . . . 57
5.3 Using the currently observed term structure. . . . 58
5.3.1 Linear Interpolation. . . . . . . . . . . . . 59
5.3.2 Interpolated term structure class. . . . . . 61
5.4 Bond calculations with a general term structure
and continous compounding . . . . . . . . . . . . 64
6 The Mean Variance Frontier 67
6.1 Setup . . . . . . . . . . . . . . . . . . . . . . . . 67
6.2 The minimum variance frontier . . . . . . . . . . 69
6.3 Calculation of frontier portfolios . . . . . . . . . 69
6.4 The global minimum variance portfolio . . . . . . 72
6.5 Efficient portfolios . . . . . . . . . . . . . . . . . 72
6.6 The zero beta portfolio . . . . . . . . . . . . . . . 73
6.7 Allowing for a riskless asset. . . . . . . . . . . . . 73
6.8 Efficient sets with risk free assets. . . . . . . . . . 74
6.9 Short-sale constraints . . . . . . . . . . . . . . . . 75
6.10 The Sharpe Ratio . . . . . . . . . . . . . . . . . . 75
6.11 Equilibrium: CAPM . . . . . . . . . . . . . . . . 76
6.11.1 Treynor . . . . . . . . . . . . . . . . . . . 76
6.11.2 Jensen . . . . . . . . . . . . . . . . . . . 76
6.12 Working with Mean Variance and CAPM . . . . . 76
6.13 Mean variance analysis using matrix libraries . . 77
7 Futures algoritms. 81
7.1 Pricing of futures contract. . . . . . . . . . . . . 81
8 Binomial option pricing 82
8.1 Options . . . . . . . . . . . . . . . . . . . . . . . 82
8.2 Pricing . . . . . . . . . . . . . . . . . . . . . . . . 82
8.3 Multiperiod binomial pricing . . . . . . . . . . . 85
9 Basic Option Pricing, the Black Scholes formula 89
9.1 The formula . . . . . . . . . . . . . . . . . . . . . 90
9.2 Understanding the why’s of the formula . . . . . 92
9.2.1 The original Black Scholes analysis . . . . 93
9.2.2 The limit of a binomial case . . . . . . . . 93
9.2.3 The representative agent framework . . . 93
9.3 Partial derivatives. . . . . . . . . . . . . . . . . . 93
9.3.1 Delta . . . . . . . . . . . . . . . . . . . . . 93
9.3.2 Other Derivatives . . . . . . . . . . . . . . 94
9.3.3 Implied Volatility. . . . . . . . . . . . . . 96
9.4 References . . . . . . . . . . . . . . . . . . . . . . 98
10 Warrants 99
10.1 Warrant value in terms of assets . . . . . . . . . . 99
10.2 Valuing warrants when observing the stock value 100
10.3 Readings . . . . . . . . . . . . . . . . . . . . . . . 101
11 Extending the Black Scholes formula 102
11.1 Adjusting for payouts of the underlying. . . . . . 102
11.1.1 Continous Payouts from underlying. . . . 102
11.1.2 Dividends. . . . . . . . . . . . . . . . . . . 103
11.2 American options . . . . . . . . . . . . . . . . . . 104
11.2.1 Exact american call formula when stock is
paying one dividend. . . . . . . . . . . . . 105
11.3 Options on futures . . . . . . . . . . . . . . . . . 108
11.3.1 Black’s model . . . . . . . . . . . . . . . . 108
11.4 Foreign Currency Options . . . . . . . . . . . . . 109
11.5 Perpetual puts and calls . . . . . . . . . . . . . . 110
11.6 Readings . . . . . . . . . . . . . . . . . . . . . . . 111
12 Option pricing with binomial approximations 112
12.1 Introduction . . . . . . . . . . . . . . . . . . . . . 112
12.2 Pricing of options in the Black Scholes setting . . 113
12.2.1 European Options . . . . . . . . . . . . . 114
12.2.2 American Options . . . . . . . . . . . . . 114
12.2.3 Matlab implementation . . . . . . . . . . . 116
12.3 How good is the binomial approximation? . . . . 119
12.3.1 Estimating partials. . . . . . . . . . . . . 120
12.4 Adjusting for payouts for the underlying . . . . 123
12.5 Pricing options on stocks paying dividends using
a binomial approximation . . . . . . . . . . . . . 124
12.5.1 Checking for early exercise in the binomial
model. . . . . . . . . . . . . . . . . . 124
12.5.2 Proportional dividends. . . . . . . . . . . 124
12.5.3 Discrete dividends . . . . . . . . . . . . . 126
12.6 Option on futures . . . . . . . . . . . . . . . . . . 128
12.7 Foreign Currency options . . . . . . . . . . . . . 130
12.8 References . . . . . . . . . . . . . . . . . . . . . . 131
13 Finite Differences 132
13.1 Explicit Finite differences . . . . . . . . . . . . . 132
13.2 European Options. . . . . . . . . . . . . . . . . . 132
13.3 American Options. . . . . . . . . . . . . . . . . . 134
13.4 Implicit finite differences . . . . . . . . . . . . . . 137
13.5 An example matrix class . . . . . . . . . . . . . . 137
13.6 Finite Differences . . . . . . . . . . . . . . . . . . 137
13.7 American Options . . . . . . . . . . . . . . . . . 137
13.8 European Options . . . . . . . . . . . . . . . . . 140
13.9 References . . . . . . . . . . . . . . . . . . . . . . 141
14 Option pricing by simulation 142
14.1 Simulating lognormally distributed random variables
. . . . . . . . . . . . . . . . . . . . . . . . . 143
14.2 Pricing of European Call options . . . . . . . . . 143
14.3 Hedge parameters . . . . . . . . . . . . . . . . . . 144
14.4 More general payoffs. Function prototypes . . . . 146
14.5 Improving the efficiency in simulation . . . . . . 147
14.5.1 Control variates. . . . . . . . . . . . . . . 147
14.5.2 Antithetic variates. . . . . . . . . . . . . . 148
14.6 More exotic options . . . . . . . . . . . . . . . . . 151
14.7 References . . . . . . . . . . . . . . . . . . . . . . 152
15 Pricing American Options – Approximations 153
15.1 The Johnson (1983) approximation . . . . . . . . 153
15.2 An approximation to the American Put due to
Geske and Johnson (1984) . . . . . . . . . . . . . 156
15.3 A quadratic approximation to American prices
due to Barone–Adesi and Whaley. . . . . . . . . . 159
15.4 An alternative approximation to american options
due to Bjerksund and Stensland (1993) . . 162
15.5 Readings . . . . . . . . . . . . . . . . . . . . . . . 165
16 Average, lookback and other exotic options 166
16.1 Bermudan options . . . . . . . . . . . . . . . . . 166
16.2 Asian options . . . . . . . . . . . . . . . . . . . . 169
16.3 Lookback options . . . . . . . . . . . . . . . . . . 170
16.4 Monte Carlo Pricing of options whose payoff depend
on the whole price path . . . . . . . . . . . 172
16.4.1 Generating a series of lognormally distributed
variables . . . . . . . . . . . . . . 172
16.5 Control variate . . . . . . . . . . . . . . . . . . . 175
16.6 References . . . . . . . . . . . . . . . . . . . . . . 176
17 Generic binomial pricing 177
17.1 Introduction . . . . . . . . . . . . . . . . . . . . . 177
17.2 Delta calculation . . . . . . . . . . . . . . . . . . 182
18 Trinomial trees 183
18.1 Intro . . . . . . . . . . . . . . . . . . . . . . . . . 183
18.2 Implementation . . . . . . . . . . . . . . . . . . . 183
18.3 Further reading . . . . . . . . . . . . . . . . . . . 186
19 Alternatives to the Black Scholes type option formula 187
19.1 Merton’s Jump diffusion model. . . . . . . . . . . 187
19.2 Hestons pricing formula for a stochastic volatility
model . . . . . . . . . . . . . . . . . . . . . . . . 189
20 Pricing of bond options, basic models 192
20.1 Black Scholes bond option pricing . . . . . . . . . 192
20.2 Binomial bond option pricing . . . . . . . . . . . 194
21 Credit risk 196
21.1 The Merton Model . . . . . . . . . . . . . . . . . 196
21.2 Issues in implementation . . . . . . . . . . . . . . 197
22 Term Structure Models 198
22.1 The Nelson Siegel term structure approximation 199
22.2 Extended Nelson Siegel models . . . . . . . . . . 201
22.3 Cubic spline. . . . . . . . . . . . . . . . . . . . . 203
22.4 Cox Ingersoll Ross. . . . . . . . . . . . . . . . . . 206
22.5 Vasicek . . . . . . . . . . . . . . . . . . . . . . . 209
22.6 Readings . . . . . . . . . . . . . . . . . . . . . . . 211
23 Binomial Term Structure models 212
23.1 The Rendleman and Bartter model . . . . . . . . 212
23.2 Readings . . . . . . . . . . . . . . . . . . . . . . . 214
24 Interest rate trees 215
24.1 The movement of interest rates . . . . . . . . . . 215
24.2 Discount factors . . . . . . . . . . . . . . . . . . . 217
24.3 Pricing bonds . . . . . . . . . . . . . . . . . . . . 217
24.4 Callable bond . . . . . . . . . . . . . . . . . . . . 219
24.5 Readings . . . . . . . . . . . . . . . . . . . . . . . 221
25 Building term structure trees using the Ho and Lee (1986) approach 222
25.1 Intro . . . . . . . . . . . . . . . . . . . . . . . . . 222
25.2 Building trees of term structures . . . . . . . . . 222
25.3 Ho Lee term structure class . . . . . . . . . . . . 222
25.4 Pricing things . . . . . . . . . . . . . . . . . . . . 225
25.5 References . . . . . . . . . . . . . . . . . . . . . . 227
26 Term Structure Derivatives 228
26.1 Vasicek bond option pricing . . . . . . . . . . . . 228
A Normal Distribution approximations. 230
A.1 The normal distribution function . . . . . . . . . 230
A.2 The cumulative normal distribution . . . . . . . . 231
A.3 Multivariate normal . . . . . . . . . . . . . . . . 231
A.4 Calculating cumulative bivariate normal probabilities
. . . . . . . . . . . . . . . . . . . . . . . . 232
A.5 Simulating random normal numbers . . . . . . . 234
A.6 Cumulative probabilities for general multivariate
distributions . . . . . . . . . . . . . . . . . . . . . 235
A.7 References . . . . . . . . . . . . . . . . . . . . . . 235
B C++ concepts 236
C Interfacing to external libraries 238
C.1 Newmat . . . . . . . . . . . . . . . . . . . . . . . 238
C.2 IT++ . . . . . . . . . . . . . . . . . . . . . . . . 238
C.3 GSL . . . . . . . . . . . . . . . . . . . . . . . . . 238
C.3.1 The evaluation of N3 . . . . . . . . . . . . 238
C.4 Internet links . . . . . . . . . . . . . . . . . . . . 239
D Summarizing routine names 240
E Installation 250
E.1 Source availability . . . . . . . . . . . . . . . . . 250
F Acknowledgements. 255
This book is a a discussion of the calculation of specific formulas in finance. The field of finance has seen a
rapid development in recent years, with increasing mathematical sophistication. The fields of derivatives and fixed income have since then been the main fields where complicated formulas are used. This book is intended to be of use for people who want to both understand and use these formulas, which explains why most of the algorithms presented later are derivatives prices. This project started when I was teaching a course in derivatives at the University of British Columbia, in the course of which I sat down and wrote code for calculating the formulas I was teaching. I have always found that implementation helps understanding these things. For teaching such complicated material it is often useful to actually look at the implementation of how the calculation is done in practice. The purpose of the book is therefore primarily pedagogical, although I believe all the routines presented are correct and reasonably efficient, and I know they are also used by people to price real options. To implement the algorithms in a computer language I choose C++. My students keep asking why anybody would want to use such a backwoods computer language, they think a spreadsheet can solve all the worlds problems. I have some experience with alternative systems for computing, and no matter what, in the end you end up being frustrated with higher end ¡°languages¡±, such as Matlab og Gauss (Not to mention the straitjacket which is is a spreadsheet.) and going back to implementation in a standard language. All example algorithms are therefore coded in C++. In doing the implementation I have tried to be as generic as possible in terms of the C++ used, but I have taken advantage of a some of the possibilities the language provides in terms of abstraction and modularization. This will also serve as a lesson in why a real computer language is useful.  亚马逊3星半评分(21人)
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-10-9 08:42:28
应该有人传过的,
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-10-9 08:42:41
谢谢分享哦
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-10-9 08:43:50
谢谢楼主 顶顶顶
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-10-10 06:17:59
thanks for sharing...
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群