bloomberg.fetch - Request data from Bloomberg® data servers

Syntax

data = fetch(Connect, 'Security')
data = fetch(Connect, 'Security', 'HEADER', 'Flag', 'Ident')
data = fetch(Connect, 'Security', 'GETDATA', 'Fields', 'Override', 'Ident', 'Values')
data = fetch(Connect, 'Security', 'TIMESERIES', 'Date', 'Minutes', 'TickField')
data = fetch(Connect, 'Security', 'HISTORY, 'Fields', 'FromDate',  'ToDate', 'Period', 'Currency', 'Ident')
ticker = fetch(Connect, 'SearchString', 'LOOKUP', 'Market')
data = fetch(Connect, 'Security', 'REALTIME', 'Fields',  MATLABProg)
data = fetch(Connect, Security, 'STOP')

Arguments

Connect

Bloomberg connection object created with the bloomberg function.

'Security'

A MATLAB® string containing the name of a security, or a cell array of strings containing a list of securities, specified in a format recognizable by the Bloomberg server. You can substitute a CUSIP number for a security name as needed.

    Note   This argument is case sensitive.

Flag

A MATLAB string indicating the dates for which to retrieve data. Possible values are:

  • DEFAULT: Data from most recent bid, ask, or trade. If you do not specify a Flag value, fetch uses the default value of 'DEFAULT'.

  • TODAY: Today's data only.

  • ENHANCED: Data from most recent date of each individual field.

Currency

(Optional) Currency in which historical returns are provided. A list of valid currencies appears in the file @bloomberg/bbfields.mat. Default = [].

Ident

(Optional) Security type identifier. A list of valid security type identifiers appears in the file @bloomberg/bbfields.mat. Default = [].

Fields

A MATLAB string or cell array of strings specifying specific fields for which you request data. A list of valid field names appears in the file @bloomberg/bbfields.mat. The variable bbfieldnames contains the list of field names. Default = [].

Override

(Optional) String or cell array of strings containing override field list. Default = [].

Values

(Optional) String or cell array of strings containing override field values.

Date

Date string or serial date number indicating date for the time series. Specify now for today's time-series data.

Minutes

(Optional) Tick interval in minutes.

TickField

(Optional) You can specify a string or numeric value for this field. For example, TickField = 'Trade' or TickField = 1 return data for ticks of type Trade. Use the command dftool('ticktypes') to return the list of intraday tick fields.

FromDate

Beginning date for historical data.

    Note   You can specify dates in any of the formats supported by datestr and datenum that display a year, month, and day.

ToDate

End date for historical data.

Period

(Optional) Period of the data. A MATLAB three-part string with the format:

'Frequency Days Data'
Frequency Values:
  • d: daily (default)

  • w: weekly

  • m: monthly

  • q: quarterly

  • y: yearly

Days Values:

  • o: omit all days for which there is no data (default)

  • i: include all trading days

  • a: include all calendar days

Data Values:

  • b: report missing data using Bloomberg (default)

  • s: show missing data as last found value

  • n: report missing data as NaN

    For example, 'dan' returns daily data for all calendar days, reporting missing values as NaN. If a value is unspecified, fetch returns a default value.

    Note   If you do not specify a value for Period, fetch uses default values.

Currency

(Optional) Currency type. The file @bloomberg/bbfields.mat lists supported currencies.

Market

A MATLAB string indicating the market in which a particular security trades. Possible values are:

  • Comdty: (Commodities)

  • Corp: (Corporate bonds)

  • Equity: (Equities)

  • Govt: (Government bonds)

  • Index: (Indexes)

  • M-Mkt: (Money Market securities)

  • Mtge: Mortgage-backed securities)

  • Muni: (Municipal bonds)

  • Pfd: (Preferred stocks)

MATLABProg

A string that is the name of any valid MATLAB program.

Description

For a given security, fetch returns header (default), current, time-series, real time, and historical data via a connection to a Bloomberg data server.

data = fetch(Connect, 'Security') fills the header fields with data from the most recent date with a bid, ask, or trade.

data = fetch(Connect, 'Security', 'HEADER', 'Flag','Ident') returns data for the most recent date of each individual field for the specified security type identifiers, based upon the value of Flag.

data = fetch(Connect, 'Security', 'GETDATA', 'Fields', 'Override', 'Ident', 'Values') returns the current market data for the specified fields of the indicated security. You can further specify the data with the optional Override, Values and Ident arguments.

data = fetch(Connect, 'Security', 'TIMESERIES', 'Date', 'Minutes', 'TickField') returns the tick data for a security for the specified date. You can further specify data with the optional Minutes and TickField arguments. If there is no data found in the specified range, fetch returns an empty matrix.

You can specify TickField as a string or numeric value. For example, TickField = 'Trade' or TickField = 1 returns data for ticks of type Trade. The function dftool('ticktypes') returns the list of intraday tick fields. fetch returns intraday tick data requested with an interval with the following columns:

Columns 7 and 8 are returned only if they make sense for the requested field.

For today's tick data, enter the command:

data = fetch(Connect,'Security', 'TIMESERIES', now) 

For today's trade time series aggregated into five-minute intervals, enter:

data = fetch(Connect,'Security','TIMESERIES', ... 
now, 5, 'Trade') 

data = fetch(Connect, 'Security', 'HISTORY, 'Fields', 'FromDate', 'ToDate', 'Period', 'Currency', 'Ident') returns historical data for the specified field for the date range FromDate to ToDate. You can set the time period with the optional Period argument to return a more specific data set. You can further specify returned data by appending the Currency or Ident argument.

ticker = fetch(Connect, 'SearchString', 'LOOKUP', 'Market') uses SearchString to find the ticker symbol for a security trading in a designated market. The output ticker is a column vector of possible ticker values.

data = fetch(Connect, 'Security', 'REALTIME', 'Fields', MATLABProg) subscribes to a given security or list of securities, requesting the indicated fields, and runs any specified MATLAB function. See pricevol, showtrades, or stockticker for information on the data returned by asynchronous Bloomberg events.

data = fetch(Connect, Security, 'STOP') unsubscribes the list of securities from processing Bloomberg real-time events.

Examples

Retrieving Header Data

Retrieve header data for a United States equity with ticker ABC:

D = fetch(C,'ABC US Equity') 

Retrieving Opening and Closing Prices

Retrieve the opening and closing prices:

D = fetch(C,'ABC US Equity','GETDATA',...
{'Last_Price';'Open'}) 

Retrieving Override Fields

Retrieve the requested fields, given override fields and values:

D = fetch(C,'3358ABCD4 Corp', 'GETDATA',... 
{'YLD_YTM_ASK','ASK','OAS_SPREAD_ASK','OAS_VOL_ASK'},... 
{'PX_ASK','OAS_VOL_ASK'}, {'99.125000','14.000000'})

Retrieving Time Series Data

Retrieve today's time series:

D = fetch(C,'ABC US Equity','TIMESERIES', now) 

Retrieving Time Series Data, Aggregated into Time Intervals

Retrieve today's trade time series for the given security, aggregated into five-minute intervals:

D = fetch(C,'ABC US Equity','TIMESERIES', now, 5,'Trade') 

Retrieving Time Series Default Closing Price

Retrieve the closing price for the given dates, using the default period of the data:

D = fetch(C,'ABC US Equity','HISTORY','Last_Price',...
'8/01/99', '8/10/99')

Retrieving Monthly Closing Price

Retrieve the monthly closing price for the specified dates:

D = fetch(C,'ABC US Equity','HISTORY','Last_Price',...
'8/01/99', '9/30/00','m')

See Also

bloomberg, bloomberg.close, bloomberg.get, bloomberg.isconnection

  


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