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.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)