builduniverse

Retrieve total return price data from Yahoo!

Syntax

  • data = builduniverse(c,s,fromdate,todate,period) example

Description

example

data = builduniverse(c,s,fromdate,todate,period) retrieves total return price series data for security s using the Yahoo!® connection c. Retrieve data starting from the date fromdate through todate using the periodicity period to denote the data frequency.

Examples

expand all

Compute a Total Return Price Series

Connect to Yahoo! Finance.

c = yahoo;

Create a security list for Google®.

s = {'GOOG'};

Retrieve a daily total return price series for Google starting January 15, 2012 through today. The total is calculated from prices, splits, and dividends.

fromdate = '1/15/2012';
todate = floor(now);

data = builduniverse(c,s,fromdate,todate);

Display the data.

data
data =

     734885.00          1.00
     734886.00          1.01
     734887.00          1.02
     ...

data contains the numeric representation of the date in the first column and the total return prices for Google in the second column.

Close the connection.

close(c)

Input Arguments

expand all

c — Yahoo! connectionconnection object

Yahoo! connection, specified as a connection object created using yahoo.

s — Security liststring | cell array

Security list, specified as a string for one security or a cell array of strings for multiple securities. Security strings must be in a format recognizable by the Yahoo! server.

Data Types: char | cell

fromdate — Beginning datescalar | vector | matrix | string | cell array

Beginning date for the historical data, specified as a double scalar, double vector, double matrix, string, or cell array of strings. You can specify dates in any format supported by datestr and datenum that show a year, month, and day.

Data Types: double | char | cell

todate — End datescalar | vector | matrix | string | cell array

End date for the historical data, specified as a double scalar, double vector, double matrix, string, or cell array of strings. You can specify dates in any format supported by datestr and datenum that show a year, month, and day.

Data Types: double | char | cell

period — Period'd' (default) | 'w' | 'm'

Period within a date range, specified as one of these enumerated strings. Values are:

Enumerated String

Description

'd'

Daily

'w'

Weekly

'm'

Monthly

Data Types: char

Output Arguments

expand all

data — Total return price seriesmatrix

Total return price series, returned as an m-by-(n + 1) matrix, where m refers to the number of records of data and n refers to the number of securities. The first column of the matrix contains MATLAB® date numbers and the remaining columns are the total return prices for each security.

More About

expand all

Tips

  • Data providers report price, action, and dividend data differently. Verify that the data returned by the builduniverse function contains the expected results.

See Also

|

Was this topic helpful?