Datafeed Toolbox    

Retrieving Data

The fetch command controls data retrieval from a data server connection. fetch returns different information depending upon which data server is being accessed. See the version of fetch appropriate for your data server for further information.

Example: Retrieving Bloomberg Data

This section illustrates the use of the fetch command to retrieve data from a Bloomberg data server. Versions of the fetch command that retrieve data from other data servers work similiarly.

Retrieving Header (Bloomberg Default) Data

A header (default) data request to Bloomberg returns a fixed set of field data. Not all fields in the header data are relevant for a specific security.

Determining Header Fields.   The list of valid header fields is stored in the file @bloomberg/bbfields.mat. Use the command

to load this file. The variable headerfieldnames contains the list of header field names.

Obtaining Data.   To retrieve header data from the Bloomberg connection, use fetch with the syntax

where

Commands of the form

are equivalent.

The returned data has a fixed set of fields. For example, a header inquiry for the security IBM US Equity returns data of the form:

Not all fields are applicable to IBM US Equity, the security about which we inquired.

Retrieving Field Data

The fetch command with the GETDATA argument obtains Bloomberg field data. The entire set of field data provides statistics for all possible securities but does not apply universally to any one security.

Determining Field Names.   The complete list of valid field names is stored in the file @bloomberg/bbfields.mat. Use the command

to load this file. The variable bbfieldnames contains the list of field names. This list includes the header field names plus numerous others.

Obtaining Data.   To obtain data for specific fields of a given security, use the fetch command with the syntax

For example, use the bloomberg command to establish a connection c1 to a Bloomberg data server.

Then

returns

Retrieving Time Series Data

The fetch command with the TIMESERIES argument returns price and volume data for a particular security on a specified date. Time series data for a given security and a specific date are returned using the syntax

Date may be a MATLAB date string or serial date number.

To obtain time series data for the current day, you can use the alternate forms of the command

or

To obtain time series data for IBM using an existing connection c1, enter the command

The result will look like this:

Column 1 contains the tick type flag, column 2 contains the time stamp in MATLAB serial date number format, column 3 contains the tick value, and column 4 contains the number of shares in the transaction.

Retrieving Historical Data

Use the fetch command with the HISTORY argument to obtain historical data for a specific security.

For a specified field of a particular security use the syntax

to obtain historical data. Data for the field is returned for the date range from FromDate to ToDate. See Determining Field Names for instructions on determining valid field names.

For example, to obtain the closing price for IBM for the dates July 15, 1999 to August 2, 1999 using the connection c1, enter

Column 1 is the date represented as a MATLAB date number, and column 2 is the last price.

Finding Ticker Symbols

You can use the fetch command with the LOOKUP argument to find a ticker symbol when you are uncertain what the symbol might be. Use the syntax

to locate a specific ticker symbol.

The SearchString argument is the comparison string used in the lookup operation, and Market indicates the type of security (the market in which the security trades). The allowable values for Market are

For example, using fetch with the connection c1 to look up the ticker symbol for New Zealand government bonds returns

returns a list of possible values:


  Disconnecting from a Data Server Datafeed Toolbox Graphical User Interface