Financial Derivatives Toolbox | ![]() ![]() |
Retrieve data from instrument variable
Syntax
[Data_1, Data_2,...,Data_n] = instget(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
[Data_1, Data_2,...,Data_n] = instget(InstSet, 'FieldName',
FieldList, 'Index', IndexSet, 'Type', TypeList)
retrieve data arrays from an instrument variable.
Data_1
is an NINST
-by-M
array of data contents for the first field in FieldList
. Each row corresponds to a separate instrument in IndexSet
. Unavailable data is returned as NaN
or as spaces.
Data_n
is an NINST
-by-M
array of data contents for the last field in FieldList
.
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
Extract the price from all instruments.
Get all the prices and the number of contracts held.
[P,C] = instget(ExampleInst, 'FieldName', {'Price', 'Contracts'}) P = 12.2000 9.2000 6.8000 Nan 7.4000 2.9000 99.0000 C = 0 0 1000 -1000 -1000 0 6
Compute a value V
. Create a new variable ISet
that appends V
to ExampleInst
.
V = P.*C ISet = instsetfield(ExampleInst, 'FieldName', 'Value', 'Data',... V); instdisp(ISet) Index Type Strike Price Opt Contracts Value 1 Option 95 12.2 Call 0 0 2 Option 100 9.2 Call 0 0 3 Option 105 6.8 Call 1000 6800 Index Type Delivery F Contracts Value 4 Futures 01-Jul-1999 104.4 -1000 NaN Index Type Strike Price Opt Contracts Value 5 Option 105 7.4 Put -1000 -7400 6 Option 95 2.9 Put 0 0 Index Type Price Maturity Contracts Value 7 TBill 99 01-Jul-1999 6 594
Look at only the instruments which have nonzero Contracts
.
Get the Type
and Opt
parameters from those instruments.(Only options have a stored 'Opt'
field.)
[T,O] = instget(ExampleInst, 'Index', Ind, 'FieldName',... {'Type', 'Opt'}) T = Option Futures Option TBill O = Call Put
Create a string report of holdings Type
, Opt
, and Value
.
See Also
instaddfield
, instdisp
, instgetcell
![]() | instfloor | instgetcell | ![]() |