| Financial Derivatives Toolbox | ![]() |
Add new instruments to an instrument collection
Syntax
InstSet = instaddfield('FieldName', FieldList,'Data', DataList,
'Type',TypeString)
InstSet = instaddfield('FieldName', FieldList, 'FieldClass',
ClassList, 'Data', DataList, 'Type',TypeString)
InstSetNew = instaddfield(InstSet,'FieldName', FieldList, 'Data',
DataList, 'Type',TypeString)
Arguments
Description
Use instaddfield to create your own types of instruments or to append new instruments to an existing collection. Argument value pairs can be entered in any order.
InstSet = instaddfield('FieldName', FieldList, 'Data', DataList,
'Type', TypeString) and
InstSet = instaddfield('FieldName', FieldList, 'FieldClass', ClassList, 'Data', DataList, 'Type', TypeString) create an instrument variable.
InstSetNew = instaddfield(InstSet, 'FieldName', FieldList, 'Data',
DataList,'Type',TypeString)
adds instruments to an existing instrument set, InstSet. The output InstSetNew is a new instrument set containing the input data.
Examples
Build a portfolio around July options.
Strike Call Put 95 12.2 2.9 100 9.2 4.9 105 6.8 7.4 Strike = (95:5:105)' CallP = [12.2; 9.2; 6.8]
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
FN = instfields(InstSet,'Type','Option')
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') 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
InstSet = instaddfield(InstSet, 'Type', 'TBill', 'FieldName','Price','Data',99) 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
See Also
instdisp, instget, instgetcell, instsetfield
| instadd | instbond | ![]() |