Add new instruments to instrument collection
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)
| Number of fields, specified as a |
| Number of instruments, specified as a |
| (Optional) Character vector or |
| Character vector specifying the type of instrument added.
Instruments of different types can have different |
| Variable containing a collection of instruments. Instruments
are classified by type; each type can have different |
InstSet = instaddfield('FieldName',FieldList,'Data',DataList,'Type',TypeString)
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,'FieldClass',ClassList,'Data',DataList,'Type',TypeString)
creates
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.
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
Add a put option.
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
Add a cash instrument.
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
instadd
| instdisp
| instget
| instgetcell
| instsetfield