112
金金金金

金融工程

  • Upload
    ziva

  • View
    196

  • Download
    0

Embed Size (px)

DESCRIPTION

金融工程. 实验一 现货、远期平价及远期合约定价. 【 实验目的 】 了解现货、远期平价,掌握远期合约价值计算。 【 实验内容 】 1 、利用 Excel 软件计算现货、远期平价 2 、利用 Excel 软件计算远期合约价值 3 、利用 Excel 软件计算已知现金收益资产的现货、远期平价及远期合约价值 4 、利用 Excel 软件计算已知收益率资产的现货、远期平价及远期合约价值. 【 实验步骤 】. 一、利用利用 Excel 软件计算现货、远期平价 - PowerPoint PPT Presentation

Citation preview

Page 1: 金融工程

金融工程

Page 2: 金融工程

实验一 现货、远期平价及远期合约定价

【实验目的】 了解现货、远期平价,掌握远期合约价值计算。 【实验内容】 1 、利用 Excel 软件计算现货、远期平价 2 、利用 Excel 软件计算远期合约价值 3 、利用 Excel 软件计算已知现金收益资产的现货、

远期平价及远期合约价值 4 、利用 Excel 软件计算已知收益率资产的现货、

远期平价及远期合约价值

Page 3: 金融工程

【实验步骤】 一、利用利用 Excel 软件计算现货、远期平价 Microsoft Excel 是微软公司的办公软件

Microsoft office的组件之一,是由 Microsoft为Windows和 Apple Macintosh操作系统的电脑而编写和运行的一款试算表软件。直观的界面、出色的计算功能和图表工具,再加上成功的市场营销,使 Excel成为最流行的微机数据处理软件。在 1993 年,作为Microsoft Office 的组件发布了 5.0 版之后, Excel 就开始成为所适用操作平台上的电子制表软件的霸主。

Page 4: 金融工程

1 、理论准备。 由于远期价格( F )就是使合约价值( f )为零的

交割价格( K ),即当 f=0 时, K=F 。据此可以令f=0 ,则

F=Ser ( T - t ) 这就是无收益资产的现货 - 远期平价定理( Spot-F

orward Parity Theorem ),或称现货期货平价定理(Spot-Futures Parity Theorem) 。上式表明,对于无收益资产而言,远期价格等于其标的资产现货价格的终值。

Page 5: 金融工程

2 、打开 EXCEL ,如下图,分别输入如下图所示文字,做好数据录入计算的准备工作。

Page 6: 金融工程

3 、题目:假设到期时间是 1 年,现货价格是 100 ,连续无风险利率 10% ,交割价格是110 ,求远期价格。

Page 7: 金融工程

4 、分别把上述数据按照图 1-2 所示输入相应单元。在远期价格一行输入计算公式。

Page 8: 金融工程
Page 9: 金融工程

二、利用 Excel 软件计算远期合约价值

1 、理论准备。为了给无收益资产的远期定价我们可以构建如下两种组合:组合 A :一份远期合约③多头加上一笔数额为 Ke-r ( T - t )的现金;

组合 B :一单位标的资产。 在组合 A 中, Ke-r ( T - t )的现金以无风险利率

投资,投资期为( T - t )。到 T 时刻,其金额将达到 K 。这是因为: Ke-r ( T - t ) er ( T - t ) =K

③该合约规定多头在到期日可按交割价格 K 购买一单位标的资产。

Page 10: 金融工程

在远期合约到期时,这笔现金刚好可用来交割换来一单位标的资产。这样,在 T 时刻,两种组合都等于一单位标的资产。根据无套利原则,这两种组合在 t 时刻的价值必须相等。即:

f+ Ke-r ( T - t ) =S f=S - Ke-r ( T - t ) 上式表明,无收益资产远期合约多头的价值等于标

的资产现货价格与交割价格现值的差额。或者说 ,一单位无收益资产远期合约多头可由一单位标的资产多头和 Ke-r ( T - t )单位无风险负债组成。

Page 11: 金融工程

2 、在 A11 输入远期合约价值的文字,在 B11输入定价公式。按 enter 键,即可得远期合约

价值

Page 12: 金融工程
Page 13: 金融工程

三、利用 Excel 软件计算已知现金收益资产的现货、远期平价及远期合约价值

1 、理论准备。为了给支付已知现金收益资产的远期定价,我们可以构建如下两个组合:

组合 A :一份远期合约多头加上一笔数额为 Ke-r ( T - t )的现金 ; 组合 B :一单位标的证券加上利率为无风险利率、期限为从现在到现金

收益派发日本金为 I 的负债。 组合 A 在 T 时刻的价值等于一单位标的证券。在组合 B 中,由于标的证

券的收益刚好可以用来偿还负债的本息,因此在 T 时刻,该组合的价值也等于一单位标的证券。因此,在 t 时刻,这两个组合的价值应相等,即:

f+ Ke-r ( T - t ) =S-I f=S-I- Ke-r ( T - t ) 上式表明,支付已知现金收益资产的远期合约多头价值等于标的证券现货

价格扣除现金收益现值后的余额与交割价格现值之差。或者说,一单位支付已知现金收益资产的远期合约多头可由一单位标的资产和 I+Ke-r ( T- t )单位无风险负债构成。

Page 14: 金融工程

2 、题目:到期时间 1 年,现货价格 100 ,连续无风险利率 10% ,表的资产现金流三个月后支付 5 , 9 个月后支付 5 ,求远期价格和远期合约价值。

Page 15: 金融工程

3 、按照下图所示把相关文字和数据录入。

Page 16: 金融工程

4 、计算现金流现值。如下图,在 B10 输入现金流贴现公式。

Page 17: 金融工程

如下图,在 C10 输入现金流贴现公式。

Page 18: 金融工程

5 、计算远期价格和合约价值。首先如下图所示,把标的资产的现金流现值求和。

Page 19: 金融工程

其次,在 B15 输入计算公式已知现金收益远期价格计算公式,按下 enter 进行计算。

Page 20: 金融工程

再次,输入计算远期合约价值的公式,计算远期合约的价值。

Page 21: 金融工程

四、利用 Excel 软件计算已知收益率资产的现货、远期平价及远期合约价值

1 、理论准备。 为了给出支付已知收益率资产的远期定价,我们可

以构建如下两个组合: 组合 A :一份远期合约多头加上一笔数额为 Ke-r

( T - t )的现金; 组合 B : e-q ( T - t )单位证券并且所有收入都

再投资于该证券,其中 q 为该资产按连续复利计算的已知收益率。

Page 22: 金融工程

组合 A 在 T 时刻的价值等于一单位标的证券。组合B 拥有的证券数量则随着获得红利的增加而增加,在时刻 T ,正好拥有一单位标的证券。因此在 t 时刻两者的价值也应相等,即:

上式表明,支付已知红利率资产的远期合约多头价值等于 e-q(T-t) 单位证券的现值与交割价现值之差。或者说,一单位支付已知红利率资产的远期合约多头可由 e-q ( T - t )单位标的资产和 Ke-r( T - t )单位无风险负债构成。

)()( tTqtTr SeKef )()( tTrtTq KeSef

Page 23: 金融工程

上式表明,支付已知红利率资产的远期合约多头价值等于 e-q(T-t) 单位证券的现值与交割价现值之差。或者说,一单位支付已知红利率资产的远期合约多头可由 e-q ( T - t )单位标的资产和 Ke-r ( T -t )单位无风险负债构成。

根据远期价格的定义,我们可根据上述公式算出支付已知收益率资产的远期价格:

这就是支付已知红利率资产的现货 - 远期平价公式。

上式表明,支付已知收益率资产的远期价格等于按无风险利率与已知收益率之差计算的现货价格在 T时刻的终值。

))(( tTqrSeF

Page 24: 金融工程

2 、题目:到期时间为 2 年,现货价格为 100 ,连续无风险利率为 9% ,标的资产连续复利收益率为 5% ,价格为 104 ,求远期价格和合约价值。

Page 25: 金融工程

3 、首先,按照下图所示录入相关文字和数据,做好计算前的准备工作。

Page 26: 金融工程

4 、在 B11 输入已知收益率的远期价格计算公式,按enter 键,得出结果。

Page 27: 金融工程

5 、在 B11 输入已知收益率的远期合约价值公式。

Page 28: 金融工程

实验二 布莱克 - 舒尔斯期权定价模型

【实验目的】 掌握 BS 期权定价的计算方法。 【实验内容】 建立 BS基本期权定价计算公式,已知收益

的 BS 定价公式,建立 BS 定价的动态图。 【实验步骤】

Page 29: 金融工程

一、布莱克 - 舒尔斯期权定价模型 – 基础   1 、理论准备。 1973 年,布莱克和舒尔斯成功地求解了他们的

微分方程,从而获得了欧式看涨期权和看跌期权的精确公式

在风险中性的条件下,欧式看涨期权到期时( T 时刻)的期望值为:

其中,表示风险中性条件下的期望值。根据风险中性定价原理,欧式看涨期权的价格 c 等于将此期望值按无风险利率进行贴现后的现值,即:

)]0,[max( XSE T

)]0,[max()( XSEec TtTr

Page 30: 金融工程

在风险中性条件下,即:

结果为:

]),)(2

([ln~ln2

tTtTrSST

)()( 2)(

1 dNXedSNc tTr

Page 31: 金融工程

其中,

tTdtT

tTrXSd

tT

tTrXSd

1

2

2

2

1

))(2/()/ln(

))(2/()/ln(

Page 32: 金融工程

根据欧式看涨期权和看跌期权之间存在平价关系,可以得到无收益资产欧式看跌期权的定价公式 :

)()( 12)( dSNdNXep tTr

)()( 12)( dSNdNXep tTr

Page 33: 金融工程

2 、问题: 1999 年 12 月 13 日,亚马逊股票价格为 $102.50, 连续复利收益率的年波动率为 86.07%, 2000 年 4 月 20 日到期的无风险国库券收益率为 5.47%, 亚马逊股票 4 月份( 4 月 21 日)到期的欧式看涨期权和看跌期权的价格都是 $100.00, 这两个期权的到期期限为 0.3556 年。请计算这两种期权的价格?

Page 34: 金融工程

3 、创建这个 Excel 表单模型的步骤:

A 、输入 . 将上面问题中的输入键入区域 B4:B8.

B 、 d1 和 d2 的计算公式 . 在单元格 B11 中键入 =(LN(B4/B7)+(B6+B5^2/2)*B8)/(B5*SQRT(B8)) 。在单元格 B12 中键入 =B11-B5*SQRT(B8) 。

Page 35: 金融工程

C 、标准正态分布变量的累积概率分布函数计算公式。在 B13 单元格中键入 =NORMSDIST(B11) ,再将单元格 B13 的内容复制到 B14 。

D 、欧式看涨期权定价公式。在单元格 B15中键入 =B4*B13-B7*EXP(-B6*B8)*B14 。

Page 36: 金融工程

E 、 -d1 和 -d2 的计算公式。在单元格 A17 中键入 '-d1 ,在单元格 A18 中键入 '-d2 。 “ '” 告诉 Excel 这不是公式,而是标题。在单元格 B17 中键入 =-B11 ,在单元格 B18 中键入 =-B12 。

F 、标准正态分布变量的累积概率分布函数计算公式。在单元格 B19 中键入 =NORMSDIST(B17) ,再将单元格 B19 的内容复制到 B20 。

G 、欧式看跌期权定价公式。在单元格 B21 中键入 =-B4*B19+B7*EXP(-B6*B8)*B20

Page 37: 金融工程
Page 38: 金融工程

二、有收益资产的期权定价 1 、理论准备。 到现在为止,我们一直假设期权的标的资产没有现金收益。那么,对于有收益资产,其期权定价公式是什么呢?实际上,如果收益可以准确地预测到,或者说是已知的,那么有收益资产的期权定价并不复杂。

在收益已知情况下,我们可以把标的证券价格分解成两部分:期权有效期内已知现金收益的现值部分和一个有风险部分。当期权到期时,这部分现值将由于标的资产支付现金收益而消失。因此,我们只要用 S 表示有风险部分的证券价格。表示风险部分遵循随机过程的波动率,就可直接套用上面的公式分别计算出有收益资产的欧式看涨期权和看跌期权的价值。

Page 39: 金融工程

当标的证券已知收益的现值为 I 时,我们只要用( S - I )代替上式中的 S 即可求出固定收益证券欧式看涨和看跌期权的价格。

当标的证券的收益为按连续复利计算的固定收益率 q (单位为年)时,我们只要将代替式中的 S 就可求出支付连续复利收益率证券的欧式看涨和看跌期权的价格,从而使布莱克——舒尔斯的欧式期权定价公式适用欧式货币期权和股价指数期权的定价。

Page 40: 金融工程

2 、题目:当前股价为 100 ,年波动率为 25% ,无风险利率为 5.47% ,协议价格为

100 到期时间为 0.3556 年 , 红利收益 3.00% ,求看涨期权价格和看跌期权价格。

Page 41: 金融工程

3 、按照下图,把上述文字、数据输入。在 B16 输入已知红利收益率的看涨期权计算公式,然后按 enter

键。

Page 42: 金融工程

在 B22 输入已知红利收益的看跌期权定价公式,得看跌期权的价格为 5.43 。

Page 43: 金融工程

三、布莱克 - 舒尔斯期权定价模型 – 动态图

如果股票的波动率增大,看涨期权价格将会怎样?如果到期时间延长,看跌期权价格将会怎样?你可以通过使用“微调项”创建动态图来回答类似的问题。微调项 是由上下箭头组成的按纽,它可以让你很容易通过点击鼠标来改变模型的输入。输入一旦改变,表单会重新计算模型并立即把结果重新画在图上。

Page 44: 金融工程

创建这个 Excel 表单模型的步骤: 从基础表单开始,插入几行,并加一个转换开关。打开名为“布莱克舒尔斯期权定价模型基础”的表单,把它另存为“布莱克舒尔斯期权定价模型动态图”。选定区域 A11:A16 ,点击“插入”“行”,加入六行。选定区域 A4:B4 ,将它拖至区域 A13:B13 (将鼠标移到选定区域的下边,此时鼠标会变为四向的箭头,按住鼠标左键并移到 A4:B4放开)。在单元格 B4 中键入 1 ,把它作为看涨期权和看跌期权之间的转换开关。为了指明当前画的是哪种期权,在单元格 I1中键入 =IF($B$4=1,"Call","Put") 。

增加行高。选择区域 A4:A8 ,单击主菜单的“格式”“行”“行高”,键入 30 后按“确定”。

显示窗体工具栏。 从主菜单选择“视图”“工具栏”“窗体”。

Page 45: 金融工程

创建微调项。 在“窗体”工具栏中找到上下箭头的按钮(如果你让鼠标停留在它上面,它将显示“微调项”字样)并单击。然后在单元格 C4 中从左上角拖向右下角。这时一个微调项就出现在单元格 C4 中。用鼠标右键单击微调项,单击复制。然后选定 C5 并按粘贴。这就在 C5 中也创建了同样的微调项。在 C6, C7 和 C8 中重复上述步骤。这样你就在 C列中创建了 5 个微调项。

Page 46: 金融工程

创建单元格链接。 右击单元格 C4 中的微调栏,出现小的菜单后单击“设置控件格式”,出现对话框后选择“控制”标签,在“单元格链接”编辑框中键入 D4 ,然后按“确定”。为其他四个微调项重复上述步骤。这样就把单元格 C5 的微调项链接到 D5 ,把单元格 C6 的微调项链接到 D6 ,把单元格 C7 的微调项链接到 D7 ,把单元格 C8 的微调项链接到 D8 。点击微调栏中向上的箭头和向下的箭头,看看在链接的单元格的值会怎么变。你也可以在 D4至 D6 中直接键入你想要的输入值。

Page 47: 金融工程

创建调整后的输入。在链接单元格中的值总是整数,但我们可以对之进行调整使之与我们的问题相吻合。 在单元格 B4 中键入 =IF(D4>1,1,D4) ,使之要么是 1要么是 0 。在单元格 B5 中输入 =D5/10+0.00001 ,在单元格 B6 中键 =D6/1000 ,在单元格 B7 中键入 =D7/100 ,在单元格 B8 中键入 =D8/1000+0.00001 。单元格 B5 和 B8 中的+0.00001 是为了防止链接的单元格等于 0 时它也等于 0 。因为但波动率和到期时间等于 0 时, BS看涨和看跌期权的定价公式就没意义。

Page 48: 金融工程

创建股价输入。 在区域 B13:L13 分别键入 0.01, 20, 40, 60, ..., 200 。在单元格 M13, 中键入 0.01 。在单元格 N13 中键入 =B7 。在单元格中键入 =L13 。

将输入单元格引用转换成绝对引用。将单元格 B17, B18, B21, and B27 公式中输入单元格引用转换成绝对引用,即在任何引用 B4:B8 单元格前加上 $ 。完成上述步骤后,B17 单元格中的公式将变为 =(LN(B13/$B$7)+($B$6+$B$5^2/2)*$B$8)/($B$5*SQRT($B$8)) 。 B18 单元格中的公式将变为 =B17-$B$5*SQRT($B$8) 。 B21 单元格中的公式将变为 =B13*B19-$B$7*EXP(-$B$6*$B$8)*B20 。 B27 单元格中的公式将变为 =-B13*B25+$B$7*EXP(-$B$6*$B$8)*B26 。

Page 49: 金融工程

复制公式。 选定区域 B17:B27 ,并将它们拷贝到区域 C17:O27 。

期权价格。 根据单元格 B4 中的期权类型来引用看涨期权或看跌期权价格。在单元格 B14 中键入=IF($B$4=1,B21,B27) ,并将之复制到区域 C14:L14 。

加上内在价值。 如果期权现在到期,则其结果将是:

看涨期权 Max ( 当前股价 – 协议价格 , 0) ; 看跌期权 Max ( 协议价格 – 当前股价 , 0) ; 这就是期权的内在价值。在单元格 M15, 中键入 =I

F($B$4=1,MAX(M13-$B$7,0),MAX($B$7-M13,0)) ,然后将它复制到 N15:O15 。

Page 50: 金融工程

画出期权价格和内在价值的图形。 选定区域 B13:O15 ,从主菜单中选择“插入”“图表”。 在弹出的对话框中选择“ XY散点图”中的最后一个子图(折线图),按“下一步”,使用默认值,再按“下一步”,在“图形标题”下写入“ BS 期权定价动态图”,在“ X轴”下写入“当前股价”,在“ Y轴”下写入“期权价格”。再按“下一步”,最后按“完成”。这时图形就出现了。把图形移到E2:J11区域。

这个动态图可以让你改变输入(包括波动率、协议价格、到期时间、无风险利率等)并立即看到它对期权价格和内在价值图形的影响。

Page 51: 金融工程
Page 52: 金融工程

实验三 基于 DerivaGem 的二叉树模型

【实验目的】 掌握利用《期货与期权市场导论》一书所附

软件 DerivaGem 来计算二叉树模型的方法。 【实验内容】 基于 DerivaGem 的二叉树模型 【实验步骤】

Page 53: 金融工程

一、 DerivaGem 的按装。从 Hull 的网站上下载解压即可下图是打开时的界面:

Page 54: 金融工程

二、下图是打开期权计算的页面:

Page 55: 金融工程

下图是添标的资产数据的地方,标的资产的类型有 Equity , Currency , Index , Futures四种可选项,股票价格,波动率,无风险利率按照题目要求输入,如果有发放红利,则要把时间和金额输入:

Page 56: 金融工程
Page 57: 金融工程

下图是输入图形结果参数的窗口:

Page 58: 金融工程

下图是纵坐标的可选项,有 Theta , Option price ,Delta , Gamma , Vega , Rho , Theta六种:

Page 59: 金融工程

下图是横轴的可选项,有 Asset , Strike price , Risk-free rate , Time to Exercise , Volatility五种选项:

Page 60: 金融工程

作完上述步骤后,再输入横轴的最小值和最大值:

Page 61: 金融工程

下图是期权参数输入界面:

Page 62: 金融工程

下图是期权类型的选择框,可以根据需要选择相应类型:

Page 63: 金融工程

下图是计算结果输出界面:

Page 64: 金融工程
Page 65: 金融工程

三、题目计算:一种股票指数,当前值为 810 ,波动率为 20% ,股利收益率为 2% 。无风险利率为 5% ,下图显示了利用 DerivaGem 、使用两步二差树模型为执行价格为 800 、6 个月期的欧式看涨期权估值的结果。在本例中:

9048.01,1025.1,25.0 25.020.0 udeut

Page 66: 金融工程
Page 67: 金融工程

实验四 基于 MATLAB 的衍生品计算 【实验目的】 掌握 MATLAB 金融衍生品工具箱中的常见期权的定价方法。 【实验内容】 1. 欧式期权价格函数 2. 欧式期权的 Delta 值 3. 欧式期权 Gamma 值。 4. 欧式看涨期权 Theta 值。 5. 欧式期权 Rho 值。 6. 欧式期权 Vega 7. 欧式期权隐含波动率 8. 期货期权定价函数

Page 68: 金融工程

理论准备。 基本期权。基本期权是最常见的期权,如欧式期权,美

式期权等。 奇异期权( Exotic Option )。 奇异期权也叫做“第二代期权”,包括亚式期权、障碍

期权、复合期权、回望期权、百慕大期权等。 ( 1 )亚式期权:亚式期权是一种路径依赖型期权,由

于执行价格是平均价格,不容易收到操纵,因而收到投资者青睐。

( 2 )障碍期权:障碍期权是指期权回报依赖于标的资产价格在一段特定时间内是否达到了某个特定水平,这个特定水平就叫障碍水平。障碍期权分为下面四种类型:

Page 69: 金融工程

A 、 Up Knock-in :当标的资产价格超过事先规定的某个特定价格 B ,该项期权就会被激活,而且 B高于合同签订时标的资产的价格。

B 、 Up Knock-out :当标的资产价格超过事先规定的某个特定价格 B ,该项期权就会被终止,而且 B高于合同签订时标的资产的价格。

C 、 Down Knock-in :标的资产价格低于事先约定的水平(称其为障碍价格)时,期权被激活。

D 、 Down Knock-out :标的资产价格低于事先约定的水平(称其为障碍价格)时,期权被失效。

当障碍期权没有被执行时,期权卖方有时需支付给买方一笔费用,这笔费用叫做返还费( Rebates )。

Page 70: 金融工程

( 3 )复合期权:复合期权是以期权为标的的期权 , 标的可以是欧式期权,也可以是美式期权,复合期权有下列四种类型:

Call on a call , Put on a call , Call on a put , Put on a put

( 4 )回望期权:回望期权是一种路径依赖型期权 , 该期权的到期现金流根据标的资产价格最大值或者最小值是否高于或低于执行价格来确定。 MATLAB金融工具箱中回望期权包括固定式与浮动式两种,固定式期权执行价格在合约签订时已经确定,回望期期权根据到期现金流不同,可以分成四种。

( 5 )百慕大期权。百慕大期权是欧式期权与美式期权的混合体。

Page 71: 金融工程

MATLAB 中衍生产品的定价主要通过衍生产品工具箱完成,定价函数分为股票类衍生产品与利率类衍生产品两大类。

Page 72: 金融工程

1 、欧式期权价格函数

MATLAB 中计算欧式期权价格的函数是 Blsprice BLSPRICE Black-Scholes put and call option pricing. Compute European put and call option prices using a Bl

ack-Scholes model. [Call, Put] = blsprice(Price, Strike, Rate, Time, Volatility) [Call, Put] = blsprice(Price, Strike, Rate, Time, Volatility,

Yield)

Page 73: 金融工程

Optional Input: Yield Inputs: Price - Current price of the underlying asset. Strike - Strike (i.e., exercise) price of the option. Rate - Annualized continuously compounded risk-free rate of return

over the life of the option, expressed as a positive decimal number. Time - Time to expiration of the option, expressed in years. Volatility - Annualized asset price volatility (i.e., annualized standard deviation of the continuously compounded asset return), expressed

as a positive decimal number.

Page 74: 金融工程

Optional Input: Yield - Annualized continuously compounded yield of the

underlying asset over the life of the option, expressed as a decimal number. For example, this could represent the dividend yield or foreign risk-free interest rate for options written on stock indices and currencies, respectively. If empty or missing, the default is zero.

Outputs: Call - Price (i.e., value) of a European call option.

Put - Price (i.e., value) of a European put option.

Page 75: 金融工程

Example: Consider European stock options with an exerc

ise price of $95 that expire in 3 months. Assume the underlying stock pays no dividends, is trading at $100, and has a volatility of 50% per annum, and that the risk-free rate is 10% per annum. Using this data,

[Call,Put] = blsprice(100, 95, 0.1, 0.25, 0.5)

returns call and put prices of $13.70 and $6.35, respectively.

Page 76: 金融工程

Notes: (1) Any input argument may be a scalar,

vector, or matrix. If a scalar, then that value is used to price all options. If more than one input is a vector or matrix, then the dimensions of those non-scalar inputs must be the same.

(2) Ensure that Rate, Time, Volatility, and Yield are expressed in consistent units of time.

Page 77: 金融工程

2 、欧式期权的 Delta 值 [CD,PD] = BLSDELTA(SO,X,R,T,SIG,Q) returns sensitivity

in option value to change in the underlying security price. Delta is also known as the hedge ratio. SO is the current stock price, X is the exercise price, R is the risk-free interest rate, T is the time to maturity of the option in years, SIG is the standard deviation of the annualized continuously compounded rate of return of the stock (also known as the volatility), and Q is the dividend rate or the foreign interest rate where applicable. The default Q is 0. CD is the delta of a call option, and PD is the delta of a put option.

Note: This function uses normcdf, the normal cumulative distr

ibution function in the Statistics Toolbox.

Page 78: 金融工程

For example, [c,p] = blsdelta(50,50,.1,.25,.3,0) returns

c = 0.5955 and p = -0.4045.

Page 79: 金融工程

3 、欧式期权 Gamma 值。 BLSGAMMA Black-Scholes sensitivity to underlyin

g delta change. G = BLSGAMMA(SO,X,R,T,SIG) returns sensitivity

of delta to change in the underlying security price. SO is the current stock price, X is the exercise price, R is the risk-free interest rate, T is the time to maturity of the option in years, SIG is the standard deviation of the annualized continuously compounded rate of return of the stock (also known as the volatility), and Q is the dividend rate. The default Q is 0.

Page 80: 金融工程

Note: This function uses normpdf, the normal pr

obability density function in the Statistics Toolbox. For example, g = blsgamma(50,50,.12,.25,.

3,0) returns g = 0.0512.

Page 81: 金融工程

4 、欧式看涨期权 Theta 值。

BLSTHETA Black-Scholes sensitivity to time until maturity change.

[CT,PT] = BLSTHETA(SO,X,R,T,SIG,Q) returns sensitivity in option value with respect to time. SO is the current stock price, X is the exercise price, R is the risk-free interest rate, T is the time to maturity of the option in years, SIG is the standard deviation of the annualized continuously compounded rate of return of the stock (also known as volatility), and Q is the dividend rate. The default Q is 0. CT is the theta of a call option, and PT is the theta of a put option.

Page 82: 金融工程

Note: This function uses normpdf, the normal

probability density function and normcdf, the normal cumulative distribution function in the Statistics Toolbox.

For example, [c,p] = blstheta(50,50,.12,.2

5,.3,0) returns c = -8.9630 and p = -3.1404.

Page 83: 金融工程

5 、欧式期权 Rho 值。

BLSRHO Black-Scholes sensitivity to interest rate change.

[CR,PR]= BLSRHO(SO,X,R,T,SIG,Q) returns the rate of change in value of securities with respect to interest rates. SO is the current security price, X is the exercise or strike price, R is the interest rate, T is the time until maturity expressed in years, SIG is the volatility (standard deviation), and Q is the dividend rate. The default Q is 0. CR is the call option rho and PR is the put option rho.

Page 84: 金融工程

Note: This function uses normcdf, the normal cumulative distribution function in the Statistics Toolbox.

For example, [c,p] = blsrho(50,50,.12,.25,.

3,0) returns c = 6.6686 and p = -5.4619.

Page 85: 金融工程

6 、欧式期权 Vega

BLSVEGA Black-Scholes sensitivity to underlying price volatility.

V = BLSVEGA(SO,X,R,T,SIG,Q) returns the rate of change of the option value with respect to the volatility of the underlying asset. SO is the current stock price, X is the exercise price, R is the risk-free interest rate, T is the time to maturity of the option in years, SIG is the standard deviation of the annualized continuously compounded rate of return of the stock (also known as volatility), and q is the dividend rate. The default Q is 0.

Page 86: 金融工程

Note: This function uses normpdf, the normal probability density function in the Statistics Toolbox.

For example, v = blsvega(50,50,.12,.15,.3,0) returns v = 7.5522.

Page 87: 金融工程

7 、欧式期权隐含波动率

BLSIMPV Black-Scholes implied volatility. Compute the implied volatility of an underlying asset fro

m the market value of European call and put options using a Black-Scholes model.

Volatility = blsimpv(Price, Strike, Rate, Time, Value) Volatility = blsimpv(Price, Strike, Rate, Time, Value, Li

mit, ... Yield, Tolerance, Class)

Page 88: 金融工程

Optional Inputs: Limit, Yield, Tolerance, Class. Inputs: Price - Current price of the underlying asset. Strike - Strike (i.e., exercise) price of the option. Rate - Annualized continuously compounded risk-free rate of return

over the life of the option, expressed as a positive decimal number. Time - Time to expiration of the option, expressed in years. Value - Price (i.e., value) of a European option from which the

implied volatility of the underlying asset is derived.

Page 89: 金融工程

Optional Inputs: Limit - Positive scalar representing the upper bound of

the implied volatility search interval. If empty or missing, the default is 10, or 1000% per annum.

Yield - Annualized continuously compounded yield of the underlying asset over the life of the option, expressed as a decimal number. For example, this could represent the dividend yield and foreign risk-free interest rate for options written on stock indices and currencies, respectively. If empty or missing, the default is zero.

Page 90: 金融工程

Tolerance - Positive scalar implied volatility termination tolerance. If empty or missing, the default is 1e-6.

Class - Option class (i.e., whether a call or put) indicating the option type from which the implied volatility is derived. This may be either a logical indicator or a cell array of characters. To specify call options, set Class = true or Class = {'call'}; to specify put options, set Class = false or Class = {'put'}. If empty or missing, the default is a call option.

Page 91: 金融工程

Output: Volatility - Implied volatility of the underlyi

ng asset derived from European option prices, expressed as a decimal number. If no solution can be found, a NaN (i.e., Not-a-Number) is returned.

Page 92: 金融工程

Example:

Consider a European call option trading at $10 with an exercise price of $95 and 3 months until expiration. Assume the underlying stock pays no dividends, is trading at $100, and the risk-free rate is 7.5% per annum. Furthermore, assume we are interested in implied volatilities no greater than 0.5 (i.e., 50% per annum). Under these conditions, any of the following commands

Volatility = blsimpv(100, 95, 0.075, 0.25, 10, 0.5) Volatility = blsimpv(100, 95, 0.075, 0.25, 10, 0.5, 0, [], {'Call'}) Volatility = blsimpv(100, 95, 0.075, 0.25, 10, 0.5, 0, [], true)

return an implied volatility of 0.3130, or 31.30%, per annum.

Page 93: 金融工程

Notes:

(1) The input arguments Price, Strike, Rate, Time, Value, Yield, and Class may be scalars, vectors, or matrices. If scalars, then that value is used to compute the implied volatility from all options. If more than one of these inputs is a vector or matrix, then the dimensions of all non-scalar inputs must be the same.

(2) Ensure that Rate, Time, and Yield are expressed in consistent units of time.

Page 94: 金融工程

期货期权定价函数 BLKPRICE Black's model for pricing futures options. Compute European put and call futures option prices using Black's model.

[Call,Put] = blkprice(Price, Strike, Rate, Time, Volatility)

Inputs: Price - Current price of the underlying asset (i.e., a futures contract).

Strike - Strike (i.e., exercise) price of the futures option.

Rate - Annualized continuously compounded risk-free rate of return over the life of the option, expressed as a positive decimal number.

Time - Time to expiration of the option, expressed in years.

Volatility - Annualized futures price volatility, expressed as a positive decimal number.

Page 95: 金融工程

Outputs: Call - Price (i.e., value) of a European call futures option.

Put - Price (i.e., value) of a European put futures option.

Example: Consider European futures options with exercise prices of $20 that

expire in 4 months. Assume the current underlying futures price is also $20 and has a volatility of 25% per annum, and that the risk-free rate is 9% per annum. Using this data,

[Call, Put] = blkprice(20, 20, 0.09, 4/12, 0.25)

returns equal call and put prices of $1.1166.

Page 96: 金融工程

Notes:

(1) Any input argument may be a scalar, vector, or matrix. If a scalar, then that value is used to price all options. If more than one input is a vector or matrix, then the dimensions of those non-scalar inputs must be the same.

(2) Ensure that Rate, Time, and Volatility are expressed in consistent units of time.

Page 97: 金融工程

实验五 基于 EViews 的期货最优套期保值比率的估计

【实验目的】 利用理论模型估计中国期货交易所交易的期货合约

的最优套期保值比率,并对保值效果进行绩效评估,说明期货套期保值在经济生活中的重要性。同时,让学生熟悉 Eviews 软件的操作,使读者能用互联网上的数据分析解决实际的金融问题。

【实验内容】 利用 EViews ,用期货市场的实际数据估计最优套

期保值比率。

Page 98: 金融工程

( 1 )数据的搜集

由于期货合约在交割前两个月最活跃,使得其价格信息释放较为充分,更能反映期货合约的真实价值,所以中国企业多用距离交割月份较近的期货合约进行保值。我们选择了在任何一个时点的后二个月进入交割月的期货合约的中间价格作为分析对象,所以每次取期货合约时都只用它到期前倒数第二个月的数据,现货数据与期货数据按时间对应。如我们取 AL0608 合约数据与现货 2006 年 6 月数据对应, AL0609 合约 7 月数据与现货 2006 年 7 月数据对应,依次类推。若那一天现货或期货中一数据缺失,则去掉该数据以达到一一对应。从上海金属网上把 AL 的 2006 年 4 月 3 日到 2007 年 4 月 13 日的现货数据截取下来,按上段的方法在同化顺平台上得到相应的期货数据并在 Excel 中进行整理,整理后我们得到含有 234 对期货现货数据的 EXCEL 文件,并命名为 FS 数据,见附表。

Page 99: 金融工程

( 2 ) EViews 工作文件的建立 打开 Eviews ,选择 File 下拉菜单中 New项,在 N

ew项下的下拉菜单中选择Workfile项,弹出如下图所示 Workfile Create菜单窗口。

在 Date specification 中的 Frequency 的下拉复选框中选择 integer date 。

在 Start 和 End 中分别输入“ 1” 和“ 234” 。 在 WF项后面的框中输入工作文件名称“ HR” ,点击“ OK”项,弹出如下图所示的工作文件窗口,这样就建立了样本期从 1 到 234 的整数频率工作文件HR 。

Page 100: 金融工程
Page 101: 金融工程
Page 102: 金融工程

( 3 )数据的导入 在 HR 工作文件的菜单项中选择 Proc ,在弹出的下拉菜单中选择 Import ,然后在二级下拉菜单中选择 Read Text-lotus-Excel ,找到刚刚保存的名为 FS 的 Excel 文件的存储路径后双击文件名 FS ,弹出如下图所示对话框。

Page 103: 金融工程
Page 104: 金融工程

在上图中,必须选定数据的排列顺序: By Observations (数据序列位于列中)或 By Series (数据序列在行中)。选项右边 Upper-left data cell 下的空格填写 Excel 工作文件左上方第一个有效数据单元格地址,系统默认为“ B2” ,在 Names for series or Number if named in files 中输入序列的名称,若导入的数据 Excel 文件中包含序列的名称,则只要导入序列的个数即可(这里命名为 f 及 s ,分别为期货和现货价格序列)。同时开可以输入数据截取范围,一般不需改变 EViews 的默认值。点击“ OK” 按钮,数据序列即被导入,在工作文件中以图标形式显示。

Page 105: 金融工程
Page 106: 金融工程

( 4 )数据的验证和保存 点击导入的序列 f ,出现如下图所示对话框,察看导入的序列是否正确合理。接着保存工作文件,选 File\Save 打开保存对话框,输入工作文件名和保存的位置。这里将保存的工作文件命名为 FS ,点击“ OK” 按钮即可,EViews 将在指定的目录位置,以 FS.WF1的名称保存工作文件。选择 File\Open\Workfile菜单,可打开已保存的工作文件。

Page 107: 金融工程
Page 108: 金融工程

( 5 )用 OLS模型估计最优套期保值比率 A 、调整样本期 在 EViews命令窗口输入 smpl 2 234 并按回车键执行命令,将样本期调整到 2 到 234 。这里调整样本期的目的是为了对价格序列进行差分,差分要求后一个值减去前一个值,故原序列的第一个值只能作为差分的初值。

Page 109: 金融工程

B 、建立 f 和 s 的差分序列 在 EViews命令窗口输入 series if=f-f(-1)

并按回车键执行命令,得到期货价格的差分序列 if ;在 EViews命令窗口输入 series is=s-s(-1) 并按回车键执行命令,得到现货价格的差分序列 is ; if 和 is 以图标形式出现,如图 5-6 所示。这里的 if 和 is 即我们上面所说的价格差分化序列。

Page 110: 金融工程
Page 111: 金融工程

C 、建立和的 OLS简单回归模型 在 EViews命令窗口中输入 ls is c if 并按回车键执行命令,得到期货价格的差分序列 if对现货价格的差分序列 is 的回归方程,结果如下图所示。

Page 112: 金融工程