history
Retrieve Quandl historical data
Syntax
Description
Examples
Retrieve Quandl Historical Data
Use a Quandl connection to retrieve historical data for a security within the available date range for the specified security.
Create a Quandl connection using a Quandl API key.
apikey = 'abcdef12345';
c = quandl(apikey)
c = quandl with properties: TimeOut: 100
c
is the quandl
connection object with the
TimeOut
property. The TimeOut
property specifies
waiting for a maximum of 100 seconds to return historical data before canceling the
request.
Adjust the display format to display currency.
format bank
Retrieve historical data for the CHRIS/ASX_WM2
security within the
available date range for the security. This security provides historical future prices for
Eastern Australian Wheat Futures, Continuous Contract #2. The specified security indicates
the default periodicity (in this case, daily). d
is a timetable with the
time in the first variable and the previous settlement price in the second variable.
s = 'CHRIS/ASX_WM2';
d = history(c,s);
Display the first few rows of historical prices.
head(d)
ans = 8×1 timetable Time PreviousSettlement ___________ __________________ 28-Apr-2018 294.00 27-Apr-2018 294.00 26-Apr-2018 294.00 25-Apr-2018 287.00 24-Apr-2018 287.00 23-Apr-2018 289.50 21-Apr-2018 291.00 20-Apr-2018 291.00
Decide to buy or sell this contract based on the historical prices.
Retrieve Quandl Historical Data Within Date Range
Use a Quandl connection to retrieve historical data for a security within a specified date range.
Create a Quandl connection using a Quandl API key.
apikey = 'abcdef12345';
c = quandl(apikey);
Adjust the display format to display currency.
format bank
Retrieve historical data for the CHRIS/ASX_WM2
security from
March 1, 2018, through March 31, 2018. This security provides historical future prices
for Eastern Australian Wheat Futures, Continuous Contract #2. The specified security
indicates the default periodicity (in this case, daily). d
is a
timetable with the time in the first variable and the previous settlement price in the
second variable.
s = 'CHRIS/ASX_WM2'; startdate = datetime('03-01-2018','InputFormat','MM-dd-yyyy'); enddate = datetime('03-31-2018','InputFormat','MM-dd-yyyy'); d = history(c,s,startdate,enddate);
Display the first few rows of historical prices.
head(d)
ans = 8×1 timetable Time PreviousSettlement ___________ __________________ 31-Mar-2018 277.50 30-Mar-2018 277.50 29-Mar-2018 277.50 28-Mar-2018 278.50 27-Mar-2018 278.00 26-Mar-2018 278.50 24-Mar-2018 280.00 23-Mar-2018 280.00
Decide to buy or sell this contract based on the historical prices.
Input Arguments
c
— Quandl connection
quandl
object
Quandl connection, specified as a quandl
object.
s
— Security
character vector | string scalar
Security, specified as a character vector or string scalar.
Example: "CHRIS/ASX_WM2"
Data Types: char
| string
startdate
— Start date
datetime
array | numeric scalar | string scalar | character vector
Start date of the date range, specified as a datetime
array,
numeric scalar, string scalar, or character vector. By default, the start date is the
date of the first available historical data for the specified security
s
.
If you specify the enddate
input argument, then you must
specify the startdate
input argument.
Example: datetime('03-01-2018','InputFormat','MM-dd-yyyy')
Example: 737121
Data Types: double
| char
| string
| datetime
enddate
— End date
datetime
array | numeric scalar | string scalar | character vector
End date of the date range, specified as a datetime
array,
numeric scalar, string scalar, or character vector. By default, the end date is the date
of the last available historical data for the specified security
s
.
If you specify the startdate
input argument, then you must
specify the enddate
input argument.
Example: datetime('03-31-2018','InputFormat','MM-dd-yyyy')
Example: 737181
Data Types: double
| char
| string
| datetime
QueryName1,QueryValue1,...,QueryNameN,QueryValueN
— Web service query parameters
name-value pairs
Web service query parameters, specified as one or more pairs of name-value
arguments. A QueryName
argument is a character vector or string
scalar that specifies the name of a query parameter. A QueryValue
argument is a character vector or string scalar that specifies the value of the query
parameter. Specify the name using a character vector or string scalar.
Example: "TICKER","XYZ"
returns data for the
XYZ
ticker.
Data Types: char
| string
Output Arguments
d
— Quandl historical data
timetable | matlab.net.http.ResponseMessage
Quandl historical data, returned as a timetable or a matlab.net.http.ResponseMessage
object.
If the historical data request is successful, then the history
function returns data as a timetable. The timetable contains the time in the first
variable. The subsequent variables in the timetable correspond to the returned data. The
variables of the returned data depend on the specified security
s
.
If the historical data request is unsuccessful, the history
function returns the error message in the
matlab.net.http.ResponseMessage
object. To access the error
message, see Access Quandl Error Messages.
Version History
Introduced in R2018b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
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.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)