yahoo.fetch - Request data from Yahoo!® data servers

Syntax

data = fetch(Connect, 'Security')
data = fetch(Connect, 'Security', 'Fields')
data = fetch(Connect, 'Security', 'Date')
data = fetch(Connect, 'Security', 'Fields', 'Date')
data = fetch(Connect, 'Security', 'FromDate', 'ToDate')
data = fetch(Connect, 'Security', 'Fields', 'FromDate', 'ToDate')
data = fetch(Connect, 'Security', 'FromDate', 'ToDate', 'Period')

Arguments

Connect

Yahoo! connection object created with the yahoo function.

Security

A MATLAB® string or cell array of strings containing the name of a security in a format recognizable by the Yahoo! server.

    Note   Retrieving historical data for multiple securities at one time is not supported for Yahoo. You can fetch historical data for only a single security at a time.

Fields

A MATLAB string or cell array of strings indicating the data fields for which to retrieve data. A partial list of supported values for current market data are:

  • 'Symbol'

  • 'Last'

  • 'Date'

  • 'Time'

  • 'Change'

  • 'Open'

  • 'High'

  • 'Low'

  • 'Volume'

A partial list of supported values for historical data are:

  • 'Close'

  • 'Date'

  • 'High'

  • 'Low'

  • 'Open'

  • 'Volume'

  • 'Adj. Close*'

For a complete list of supported values for market and historical data, see yhfields.mat.

Date

Date string or serial date number indicating date for the requested data. If you enter today's date, fetch returns yesterday's data.

FromDate

Beginning date for historical data.

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

ToDate

End date for historical data.

Period

Period within date range. Period values are:

  • 'd': daily

  • 'w': weekly

  • 'm': monthly

  • 'v': dividends

Description

data = fetch(Connect, 'Security') returns data for all fields from Yahoo!'s Web site for the indicated security.

data = fetch(Connect, 'Security', 'Fields') returns data for the specified fields.

data = fetch(Connect, 'Security', 'Date') returns all security data for the requested date.

data = fetch(Connect, 'Security', 'Fields', 'Date') returns security data for the specified fields on the requested date.

data = fetch(Connect, 'Security', 'FromDate', 'ToDate') returns security data for the date range FromDate to ToDate.

data = fetch(Connect, 'Security', 'Fields', 'FromDate', 'ToDate') returns security data for the specified fields for the date range FromDate to ToDate.

data = fetch(Connect, 'Security', 'FromDate', 'ToDate', 'Period') returns security data for the date range FromDate to ToDate with the indicated period.

Examples

Retrieving Last Prices for a Set of Equities

Connect to the Yahoo! data server to obtain the last prices for a set of equities:

y = yahoo;
FastFood = fetch(y, {'ko', 'pep', 'mcd'},'Last')
FastFood = 
    Last: [3x1 double]
FastFood.Last
ans =
         42.96
         45.71
         23.70

Retrieving a Closing Price on a Specified Date

Obtain the closing price for Coca-Cola on April 6, 2000:

c = yahoo;
ClosePrice = fetch(c,'ko','Close','Apr 6 00')
ClosePrice =
     730582.00         45.75

See Also

yahoo.close, yahoo.get, yahoo.isconnection, yahoo

  


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