Skip to Main Content Skip to Search
Product Documentation

instgetcell - Data and context from instrument variable

Syntax

[DataList, FieldList, ClassList] =
instgetcell(InstSet, 'FieldName', FieldList, 'Index',
IndexSet, 'Type', TypeList)

Arguments

InstSet

Variable containing a collection of instruments. Instruments are classified by type; each type can have different data fields. The stored data field is a row vector or string for each instrument.

FieldList

(Optional) String or number of fields (NFIELDS)-by-1 cell array of strings listing the name of each data field to match with data values. FieldList should not be either Type or Index; these field names are reserved. The default is all fields available for the returned set of instruments.

IndexSet

(Optional) Number of instruments (NINST)-by-1 vector of positions of instruments to work on. If TypeList is also entered, instruments referenced must be one of TypeList types and contained in IndexSet. The default is all indices available in the instrument variable.

TypeList

(Optional) String or number of types (NTYPES)-by-1 cell array of strings restricting instruments to match one of TypeList types. The default is all types in the instrument variable.

Argument 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

  


Free Interactive Computational Finance CD

View demos and recorded presentations led by industry experts.

Now On Demand
Network with industry peers and learn the latest applications of the leading software product for computational finance.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS