乐器Construction and Portfolio Management Using Functions
乐器Constructors
The toolbox provides constructors for the most common financial instruments. A构造函数是构建专用于某种类型对象的结构的函数;在此工具箱中,object是一种市场工具。
The instruments and their constructor functions are listed below.
乐器 |
构造函数函数 |
---|---|
亚洲选项 |
|
Barrier option |
|
纽带 |
|
纽带option |
|
Arbitrary cash flow |
|
复合选项 |
|
可换股债券 |
|
Fixed-rate note |
|
Floating-rate note |
|
Cap |
|
Floor |
|
回顾选项 |
|
Stock option |
|
交换 |
|
交换tion |
Each instrument has parameters (fields) that describe the instrument. The toolbox functions let you do the following:
创建乐器或仪器组合。
列举存储的仪器类型和信息字段。
Enumerate instrument field data.
搜索并选择仪器。
The instrument structure consists of various fields according to instrument type. Afieldis an element of data associated with the instrument. For example, a bond instrument contains the fields:优惠券比例
,定居
,Maturity
。Also, each instrument has a field that identifies the investment type (bond, cap, floor, and so on).
In reality, the set of parameters for each instrument is not fixed. You have the ability to add additional parameters. These additional fields are ignored by the toolbox functions. They may be used to attach additional information to each instrument, such as an internal code describing the bond.
Parameters not specified when创建an instrument default toNaN
,通常,这意味着使用仪器集的功能(例如intenvprice
或者hjmprice
) will use default values. At the time of价钱,如果缺少任何必需字段,则会发生错误Strike
in a cap or优惠券比例
在债券中。
Creating Instruments or Properties
Use theInstaddfield
function to create a kind of instrument or to add new properties to the instruments in an existing instrument collection.
To create a kind of instrument withInstaddfield
,您必须指定三个参数:
Type
FieldName
Data
Type
defines the type of the new instrument, for example,Future
。FieldName
相关的领域独特的新名字type of instrument.Data
contains the data for the fields of the new instrument.
An optional fourth argument isClassList
。ClassList
specifies the data types of the contents of each unique field for the new instrument.
Use either syntax to create a kind of instrument usingInstaddfield
:
instset = instaddfield('fieldName',fieldList,'data',datalist,...'type',typestring)instset = instaDdfield('fieldName',fieldList,'fieldClass','fieldclass',... classlist,... classList,'data',dataList,datalist,datalist,datalist,数据“类型”,打字)
To add new instruments to an existing set, use:
InstsetNew = Instaddfield(Instsetold,'fieldName',fieldlist,...'data',datalist,'type',typestring)
As an example, consider a futures contract with a delivery date of July 15, 2000, and a quoted price of $104.40. Since Financial Instruments Toolbox™ software does not directly support this instrument, you must create it using the functionInstaddfield
。Use these parameters to create instruments:
Type:
Future
Field names:
Delivery
和价格
Data: Delivery is July 15, 2000, and price is $104.40.
将数据输入MATLAB®软件:
type ='Future';FieldName = {'送货','Price'}; Data = {'Jul-15-2000', 104.4};
最后,用单个仪器创建投资组合:
Port = instaddfield('Type', Type,'fieldname',fieldname,...'Data', 数据);
Now use the functionInstdisp
to examine the resulting single-instrument portfolio:
Instdisp(端口)索引类型交付价格1 Future 15-2000 104.4
Because your portfolioPort
与使用该功能创建的结构相同instadd
,您可以使用使用的投资组合来使用instadd
使用使用的投资组合Instaddfield
。例如,您现在可以添加两个帽仪器Port
withinstadd
。
Strike = [0.06; 0.07]; Settle ='08-Feb-2000';成熟度='15-Jan-2003';Port = instadd(Port,'Cap', Strike, Settle, Maturity);
View the resulting portfolio usingInstdisp
。
Instdisp(Port) Index Type Delivery Price 1 Future 15-Jul-2000 104.4 Index Type Strike Settle Maturity CapReset Basis Principal 2 Cap 0.06 08-Feb-2000 15-Jan-2003 1 0 100 3 Cap 0.07 08-Feb-2000 15-Jan-2003 1 0 100
Searching or Subsetting a Portfolio
金融仪器工具箱提供了使您能够:
Find specific instruments within a portfolio.
创建一个子集投资组合,该产品组合由从较大投资组合中选择的仪器组成。
TheInstfind
function finds instruments with a specific parameter value; it returns an instrument index (position) in a large instrument set. TheInstselect
另一方面,功能将大型仪器集中在具有指定参数值的仪器组合中;它返回仪器集(投资组合),而不是索引。
Instfind
一般语法Instfind
is
索引= instfind(InstSet, 'FieldName', FieldList, 'Data',... DataList, 'Index', IndexSet, 'Type', TypeList)
InstSet
is the instrument set to search. WithinInstSet
按类型分类的仪器可以具有不同的数据字段。存储的数据字段是每个仪器的行矢量或字符向量。
Thefieldlist
,数据师
, 和TypeList
参数指示要在FieldName
,Data
, 和Type
仪器集的数据字段。fieldlist
is a cell array of field names specific to the instruments.数据师
is a cell array or matrix of acceptable values for one or more parameters specified infieldlist
。FieldName
和Data
(therefore,fieldlist
和数据师
)参数必须出现或根本不出现。
IndexSet
is a vector of integer indexes designating positions of instruments in the instrument set to check for matches; the default is all indices available in the instrument set.TypeList
is a character vector or cell array of character vectors restricting instruments to match one of theTypeList
types; the default is all types in the instrument set.
索引
是符合输入标准的仪器位置的向量。乐器被返回索引
如果有的话FieldName
,Data
,Index
, 和Type
满足条件。如果存储FieldName
数据与该行中列出的任何行匹配数据师
为了那个原因FieldName
。
Instfind
Examples.The examples use the provided MAT-filederiv.mat
。
The MAT-file contains an instrument set,HJMInstSet
, that contains eight instruments of seven types.
loadderiv.matInstdisp(HJMINSTSET)
Index Type CouponRate Settle Maturity Period Basis ... Name Quantity 1 Bond 0.04 01-Jan-2000 01-Jan-2003 1 NaN ... 4% bond 100 2 Bond 0.04 01-Jan-2000 01-Jan-2004 2 NaN ... 4% bond 50 Index Type UnderInd OptSpec Strike ExerciseDates AmericanOpt Name Quantity 3 OptBond 2 call 101 01-Jan-2003 NaN Option 101 -50 Index Type CouponRate Settle Maturity FixedReset Basis Principal Name Quantity 4 Fixed 0.04 01-Jan-2000 01-Jan-2003 1 NaN NaN 4% Fixed 80 Index Type Spread Settle Maturity FloatReset Basis Principal Name Quantity 5 Float 20 01-Jan-2000 01-Jan-2003 1 NaN NaN 20BP Float 8 Index Type Strike Settle Maturity CapReset Basis Principal Name Quantity 6 Cap 0.03 01-Jan-2000 01-Jan-2004 1 NaN NaN 3% Cap 30 Index Type Strike Settle Maturity FloorReset Basis Principal Name Quantity 7 Floor 0.03 01-Jan-2000 01-Jan-2004 1 NaN NaN 3% Floor 40 Index Type LegRate Settle Maturity LegReset Basis Principal LegType Name Quantity 8 Swap [0.06 20] 01-Jan-2000 01-Jan-2003 [1 1] NaN NaN [NaN] 6%/20BP Swap 10 |
Find all instruments with a maturity date of January 01, 2003.
Mat2003 =...instfind (HJMInstSet'fieldname','Maturity','Data','01-Jan-2003')
MAT2003 = 1 4 5 8
Find all cap and floor instruments with a maturity date of January 01, 2004.
CapFloor = instfind(HJMInstSet,...'fieldname','Maturity','Data','01-Jan-2004','Type',...{'Cap';“地板”})
CapFloor = 6 7
查找所有仪器,其中投资组合长或短时间为50。
Pos50 = instfind(HJMInstSet,'fieldname',...'Quantity','Data',{'50';'-50'})
Pos50 = 2 3
Instselect
语法Instselect
is the same syntax as forInstfind
。Instselect
returns a full portfolio instead of indexes into the original portfolio. Compare the values returned by both functions by calling them equivalently.
Previously you usedInstfind
to find all instruments inHJMInstSet
2003年1月1日的到期日期。
mat2003 = ... instfind(hjminstset,'fieldname','raturity','data','01-Jan-003')
MAT2003 = 1 4 5 8
现在使用相同的仪器集作为起点,但执行Instselect
功能相反,要生成与相同搜索标准匹配的新仪器集。
Select2003 =...Instselect(HJMInstSet,'fieldname','Maturity','Data',...'01-Jan-2003')Instdisp(Select2003)
Index Type CouponRate Settle Maturity Period Basis EndMonthRule IssueDate FirstCouponDate LastCouponDate StartDate Face Name Quantity 1 Bond 0.04 01-Jan-2000 01-Jan-2003 1 NaN NaN NaN NaN NaN NaN NaN 4% bond 100 Index Type CouponRate Settle Maturity FixedReset Basis Principal Name Quantity 2 Fixed 0.04 01-Jan-2000 01-Jan-2003 1 NaN NaN 4% Fixed 80 Index Type Spread Settle Maturity FloatReset Basis Principal Name Quantity 3 Float 20 01-Jan-2000 01-Jan-2003 1 NaN NaN 20BP Float 8 Index Type LegRate Settle Maturity LegReset Basis Principal LegType Name Quantity 4 Swap [0.06 20] 01-Jan-2000 01-Jan-2003 [1 1] NaN NaN [NaN] 6%/20BP Swap 10
Instselect
Examples.These examples use the portfolioExampleInst
provided with the MAT-fileinstsetexamples.mat
。
loadinstsetexamples.matInstdisp(exampleinst)
索引类型打击价格选择合同1选项95 12.2呼叫0 2选项100 9.2呼叫0 3选项105 6.8呼叫1000索引类型交货F合同4期货1999年7月1日104.4 -1000索引价格打击价格选择合同5-1000 6选项95 2.9 PUT 0指数类型价格成熟合同7 TBILL 99 01-1999 6 6
The instrument set contains three instrument types:选项
,Futures
, 和tbill
。UseInstselect
制作一个新的乐器集,其中包含一个选项95
。In other words, select all instruments containing the fieldStrike
和with the data value for that field equal to95
。
InstSet = instselect(ExampleInst,'fieldname','罢工','Data',95); instdisp(InstSet)
Index Type Strike Price Opt Contracts 1 Option 95 12.2 Call 0 2 Option 95 2.9 Put 0
您可以使用所有各种形式的Instselect
和Instfind
to locate specific instruments within this instrument set.
See Also
instadd
|Instaddfield
|instdelete
|Instdisp
|Instfields
|Instfind
|instget
|instgetcell
|instlength
|Instselect
|instsetfield
|insttypes
|intenvset
|hedgeopt
|Hedgeslf
相关的Examples
- 使用功能创建投资组合
- Hedging Functions
- 与Hedgeopt进行对冲
- 与Hedgeslf的自助力对冲
- Pricing a Portfolio Using the Black-Derman-Toy Model
- Pricing and Hedging a Portfolio Using the Black-Karasinski Model
- 用套顶指定约束
- Portfolio Rebalancing
- 对冲有限的投资组合