请选择 进入手机版 | 继续访问电脑版
楼主: Nicolle
5763 18

Numerical Methods in Finance with C++ [推广有奖]

巨擘

0%

还不是VIP/贵宾

-

TA的文库  其他...

Python(Must-Read Books)

SAS Programming

Must-Read Books

威望
16
论坛币
12402323 个
通用积分
1620.8615
学术水平
3305 点
热心指数
3329 点
信用等级
3095 点
经验
477211 点
帖子
23879
精华
91
在线时间
9878 小时
注册时间
2005-4-23
最后登录
2022-3-6

Nicolle 学生认证  发表于 2015-6-28 12:57:58 |显示全部楼层 |坛友微信交流群
提示: 作者被禁止或删除 内容自动屏蔽

本帖被以下文库推荐

1039264611 发表于 2015-6-28 19:46:44 |显示全部楼层 |坛友微信交流群

本帖隐藏的内容

Numerical Methods in Finance with C++.pdf (3.17 MB)

已有 2 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
accumulation + 100 + 1 + 1 + 1 精彩帖子
Nicolle + 100 + 100 + 5 + 5 精彩帖子

总评分: 经验 + 200  论坛币 + 100  学术水平 + 6  热心指数 + 6  信用等级 + 1   查看全部评分

使用道具

zli08 发表于 2015-6-28 23:48:58 |显示全部楼层 |坛友微信交流群

Multiple inheritance

Just as for European options, we can distinguish subclasses of American options according to the payoff, such as puts, calls, digital calls, bull spreads and many others. For now we restrict ourselves to puts and calls.

In Section 2.2 we saw how to use inheritance in C++ to set up subclasses. A new feature here is that an option with a particular payoff such as a put can be either of European or American type. This can be modelled in C++ by means of multiple inheritance. In addition to the EurOption class, we define a new AmOption class, and make Put a subclass of both the EurOption and AmOption classes. Similarly, Call (and possibly more classes for other payoffs) will also be inheriting from both the EurOption and AmOption classes, as in Figure 3.1. The code to capture this structure follows below.

Listing 3.1  Options07.h

  1. #ifndef Options07_h
  2. #define Options07_h

  3. #include “BinModel02.h”

  4. class EurOption
  5. {
  6.    private:
  7.       int N; //steps to expiry
  8.    public:
  9.       void SetN(int N_){N=N_;}
  10.       virtual double Payoff(double z)=0;
  11.       //pricing European option
  12.       double PriceByCRR(BinModel Model);
  13. };

  14. class AmOption                                          images
  15. {
  16.    private:
  17.       int N; //steps to expiry
  18.    public:
  19.       void SetN(int N_){N=N_;}
  20.       virtual double Payoff(double z)=0;
  21.       //pricing American option
  22.       double PriceBySnell(BinModel Model);              images
  23. };

  24. class Call: public EurOption, public AmOption           images
  25. {
  26.    private:
  27.       double K; //strike price
  28.    public:
  29.       void SetK(double K_){K=K_;}
  30.       int GetInputData( );
  31.       double Payoff(double z);
  32. };

  33. class Put: public EurOption, public AmOption            images
  34. {
  35.    private:
  36.       double K; //strike price
  37.    public:
  38.       void SetK(double K_){K=K_;}
  39.       int GetInputData( );
  40.       double Payoff(double z);
  41. };

  42. #endif
复制代码


使用道具

fengyg 企业认证  发表于 2015-6-29 08:02:32 |显示全部楼层 |坛友微信交流群
kankan

使用道具

小陆家嘴 发表于 2015-6-29 08:03:15 |显示全部楼层 |坛友微信交流群

kankan

使用道具

accumulation 学生认证  发表于 2015-7-15 00:06:24 |显示全部楼层 |坛友微信交流群
1039264611 发表于 2015-6-28 19:46
**** 本内容被作者隐藏 ****
谢谢分享!

使用道具

cck1 发表于 2015-7-15 10:39:27 |显示全部楼层 |坛友微信交流群
great book

使用道具

cck1 发表于 2015-7-15 10:39:30 |显示全部楼层 |坛友微信交流群
great book

使用道具

cck1 发表于 2015-7-15 10:40:10 |显示全部楼层 |坛友微信交流群
great book

使用道具

mengyong 发表于 2015-7-24 16:22:01 |显示全部楼层 |坛友微信交流群
Numerical Methods in Finance with C++

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加JingGuanBbs
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-19 04:59