instaddfield
Add new instruments to instrument collection
Description
adds instruments to an existing instrument set InstSetNew
= instaddfield(InstSet
,Name,Value
)InstSet
. The output
InstSetNew
is a new instrument set containing the input data.
creates an instrument variable InstSet
= instaddfield(Name,Value
)InstSet
.
Examples
Build a portfolio around the following July options.
Strike = (95:5:105)'
Strike = 3×1
95
100
105
CallP = [12.2; 9.2; 6.8]
CallP = 3×1
12.2000
9.2000
6.8000
Enter three call options with data fields Strike
, Price
, and Opt
.
InstSet = instaddfield('Type','Option','FieldName',... {'Strike','Price','Opt'}, 'Data',{ Strike, CallP, 'Call'}); instdisp(InstSet)
Index Type Strike Price Opt 1 Option 95 12.2 Call 2 Option 100 9.2 Call 3 Option 105 6.8 Call
Add a futures contract and set the input parsing class.
InstSet = instaddfield(InstSet,'Type','Futures',... 'FieldName',{'Delivery','F'},'FieldClass',{'date','dble'},... 'Data' ,{'01-Jul-99',104.4 }); instdisp(InstSet)
Index Type Strike Price Opt 1 Option 95 12.2 Call 2 Option 100 9.2 Call 3 Option 105 6.8 Call Index Type Delivery F 4 Futures 01-Jul-1999 104.4
Add a put option.
FN = instfields(InstSet,'Type','Option')
FN = 3×1 cell
{'Strike'}
{'Price' }
{'Opt' }
InstSet = instaddfield(InstSet,'Type','Option',... 'FieldName',FN, 'Data',{105, 7.4, 'Put'}); instdisp(InstSet)
Index Type Strike Price Opt 1 Option 95 12.2 Call 2 Option 100 9.2 Call 3 Option 105 6.8 Call Index Type Delivery F 4 Futures 01-Jul-1999 104.4 Index Type Strike Price Opt 5 Option 105 7.4 Put
Make a placeholder for another put.
InstSet = instaddfield(InstSet,'Type','Option',... 'FieldName','Opt','Data','Put')
InstSet = struct with fields:
FinObj: 'Instruments'
IndexTable: [1×1 struct]
Type: {2×1 cell}
FieldName: {2×1 cell}
FieldClass: {2×1 cell}
FieldData: {2×1 cell}
instdisp(InstSet)
Index Type Strike Price Opt 1 Option 95 12.2 Call 2 Option 100 9.2 Call 3 Option 105 6.8 Call Index Type Delivery F 4 Futures 01-Jul-1999 104.4 Index Type Strike Price Opt 5 Option 105 7.4 Put 6 Option NaN NaN Put
Add a cash instrument.
InstSet = instaddfield(InstSet, 'Type', 'TBill',... 'FieldName','Price','Data',99)
InstSet = struct with fields:
FinObj: 'Instruments'
IndexTable: [1×1 struct]
Type: {3×1 cell}
FieldName: {3×1 cell}
FieldClass: {3×1 cell}
FieldData: {3×1 cell}
instdisp(InstSet)
Index Type Strike Price Opt 1 Option 95 12.2 Call 2 Option 100 9.2 Call 3 Option 105 6.8 Call Index Type Delivery F 4 Futures 01-Jul-1999 104.4 Index Type Strike Price Opt 5 Option 105 7.4 Put 6 Option NaN NaN Put Index Type Price 7 TBill 99
Input Arguments
Instrument variable containing a collection of instruments, specified as
InstSet
structure. Instruments are classified by type; each type
can have different data fields. The stored data field is a row vector or character
vector for each instrument.
Data Types: struct
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: InstSet =
instaddfield('Type','Option','FieldName',{'Strike','Price','Opt'},'Data',{Strike,CallP,'Call'})
Name of each data field for an instrument, specified as the comma-separated pair
consisting of 'FieldName'
and an
NFIELDS
-by-1
cell array of character vectors.
Data Types: char
| cell
Data contents for each field, specified as the comma-separated pair consisting of
'Data'
and an NINST
-by-M
array or NFIELDS
-by-1
cell array.
Data Types: double
| cell
Data class of each field, specified as the comma-separated pair consisting of
'FieldClass'
and an
NFIELDS
-by-1
cell array of character vectors.
Data Types: char
| cell
Type of instrument added, specified as the comma-separated pair consisting of
'Type'
and a character vector. Instruments of different types can
have different FieldName
collections.
Data Types: char
Output Arguments
Instrument set variable containing the new input data added to an existing
InstSet
, returned as a structure.
New Instrument set variable containing input data, returned as a structure.
Version History
Introduced before R2006a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)