Documentation Center

  • Trial Software
  • Product Updates

instaddfield

Add new instruments to 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

FieldList

String or number of fields (NFIELDS)-by-1 cell array of strings listing the name of each data field. FieldList cannot be named with the reserved name Type or Index.

DataList

Number of instruments (NINST)-by-M array or NFIELDS-by-1 cell array of data contents for each field. Each row in a data array corresponds to a separate instrument. Single rows are copied to apply to all instruments to be worked on. The number of columns is arbitrary, and data is padded along columns.

ClassList

(Optional) String or NFIELDS-by-1 cell array of strings listing the data class of each field. The class determines how DataList is parsed. Valid strings are 'dble', 'date', and 'char'. The 'FieldClass', ClassList pair is always optional. ClassList is inferred from existing field names or from the data if not entered.

TypeString

String specifying the type of instrument added. Instruments of different types can have different Fieldname collections.

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.

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)

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.

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

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   

See Also

| | | |

Was this topic helpful?