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.
P = instget(ExampleInst,'FieldName','Price')
P = 7×1
12.2000
9.2000
6.8000
NaN
7.4000
2.9000
99.0000
Get all the prices and the number of contracts held.
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 that have nonzero Contracts.
Ind = find(C ~= 0)
Ind = 4×1
3
4
5
7
Get the Type and Opt parameters from those instruments. (Only options have a stored 'Opt' field.)
Instrument variable containing a collection of instruments, specified as
InstSet structure. Instruments are classified by type; each
type can have different data fields. The stored data field is a row vector or
character vector for each instrument.
Data Types: struct
Name-Value Pair Arguments
Specify optional
comma-separated pairs of Name,Value arguments. Name is
the argument name and Value is the corresponding value.
Name must appear inside quotes. You can specify several name and value
pair arguments in any order as
Name1,Value1,...,NameN,ValueN.
Example: Data =
instget(ExampleInst,'FieldName','Price')
'FieldName' — Name of each data field for instrument all fields available for returned set of instruments (default) | cell array of character vectors
Name of each data field for an instrument, specified as the comma-separated
pair consisting of 'FieldName' and an
NFIELDS-by-1 cell array of character
vectors. FieldName entries can also be either
Type or Index; these return type
strings and index numbers respectively.
Data Types: char | cell
'Index' — Number of instruments all indices available in instrument variable (default) | vector
Number of instruments, specified as the comma-separated pair consisting of
'Index' and an
NINST-by-1 vector of positions of
instruments to work on. If Type is also entered,
instruments referenced must be one of the types and contained in
Index.
Data Types: double
'Type' — Number of types all types in the instrument variable (default) | character vector
Number of types, specified as the comma-separated pair consisting of
'Type' and a
NTYPES-by-1 cell array of character
vectors restricting instruments worked on to match one of
Type types.
Data content, returned as an NINST-by-M
array of data contents for the first field in FieldName. Each
row corresponds to a separate instrument in the specified
Index. Unavailable data is returned as
NaN or as spaces.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.