| Financial Derivatives Toolbox | ![]() |
Retrieve data and context from instrument variable
Syntax
[DataList, FieldList, ClassList, IndexSet, TypeSet] = instgetcell(InstSet, 'FieldName', FieldList, 'Index', IndexSet, 'Type', TypeList)
Arguments
Parameter value pairs can be entered in any order. The InstSet variable must be the first argument.
Description
[DataList, FieldList, ClassList] = instgetcell(InstSet,
'FieldName', FieldList, 'Index', IndexSet, 'Type', TypeList)
retrieves data and context from an instrument variable.
DataList is an NFIELDS-by-1 cell array of data contents for each field. Each cell is an NINST-by-M array, where each row corresponds to a separate instrument in IndexSet. Any data which is not available is returned as NaN or as spaces.
FieldList is an NFIELDS-by-1 cell array of strings listing the name of each field in DataList.
ClassList is an NFIELDS-by-1 cell array of strings listing the data class of each field. The class determines how arguments are parsed. Valid strings are 'dble', 'date', and 'char'.
IndexSet is an NINST-by-1 vector of positions of instruments returned in DataList.
TypeSet is an NINST-by-1 cell array of strings listing the type of each instrument row returned in DataList.
Examples
Retrieve the instrument set ExampleInst from the data file InstSetExamples.mat. ExampleInst contains three types of instruments: Option, Futures, and TBill.
load InstSetExamples; instdisp(ExampleInst) Index Type Strike Price Opt Contracts 1 Option 95 12.2 Call 0 2 Option 100 9.2 Call 0 3 Option 105 6.8 Call 1000 Index Type Delivery F Contracts 4 Futures 01-Jul-1999 104.4 -1000 Index Type Strike Price Opt Contracts 5 Option 105 7.4 Put -1000 6 Option 95 2.9 Put 0 Index Type Price Maturity Contracts 7 TBill 99 01-Jul-1999 6
Get the prices and contracts from all instruments.
FieldList = {'Price'; 'Contracts'} DataList = instgetcell(ExampleInst, 'FieldName', FieldList ) P = DataList{1} C = DataList{2} P = 12.2000 9.2000 6.8000 NaN 7.4000 2.9000 99.0000 C = 0 0 1000 -1000 -1000 0 6
Get all the option data: Strike, Price, Opt, Contracts.
[DataList, FieldList, ClassList] = instgetcell(ExampleInst,... 'Type','Option') DataList = [5x1 double] [5x1 double] [5x4 char ] [5x1 double] FieldList = 'Strike' 'Price' 'Opt' 'Contracts' ClassList = 'dble' 'dble' 'char' 'dble'
Look at the data as a comma separated list. Type help lists for more information on cell array lists.
DataList{:} ans = 95 100 105 105 95 ans = 12.2100 9.2000 6.8000 7.3900 2.9000 ans = Call Call Call Put Put ans = 0 0 100 -100 0
See Also
instaddfield, instdisp, instget
| instget | instlength | ![]() |