timeseries
Intraday tick WDS data
Syntax
Description
specifies additional options using one or more name-value pair arguments. These
options specify a time range for each day in the specified date range. For example,
d
= timeseries(c
,s
,f
,{startdate
,enddate
},interval
,Name,Value
)'PeriodStart',datetime('10:30:00')
sets a time range that
starts at 10:30 AM and ends at the end of the trading day.
Examples
Retrieve Intraday Tick WDS Data
Using a WDS connection, retrieve intraday tick data for a single security and display the data.
Create a WDS connection.
c = wind;
Format output data for currency.
format bank
For the 600000.SH
security, retrieve the intraday tick data for high and low prices. Retrieve ticks for the current day using the WDS connection.
s = {'600000.SH'}; f = ["high","low"]; t = datetime('now'); d = timeseries(c,s,f,t);
d
is a timetable that contains a row for each tick with the time and a variable for each specified field.
Display the first three rows of intraday tick data.
head(d,3)
ans=3×2 timetable
Time high low
____________________ _____ _____
28-Nov-2017 13:17:42 13.07 12.92
28-Nov-2017 13:17:45 13.07 12.92
28-Nov-2017 13:17:48 13.07 12.92
Close the WDS connection.
close(c)
Retrieve Intraday Tick WDS Data Using Date Range
Using a WDS connection, retrieve intraday tick data for a single security and display the data. Specify a date range for the intraday tick data to return.
Create a WDS connection.
c = wind;
Format output data for currency.
format bank
For the 600000.SH
security, retrieve the intraday tick data for high and low prices. Retrieve ticks from November 20, 2017 through November 23, 2017 using the WDS connection.
s = {'600000.SH'}; f = ["high","low"]; startdate = datetime('2017-11-20'); enddate = datetime('2017-11-23'); d = timeseries(c,s,f,{startdate,enddate});
d
is a timetable that contains a row for each tick with the time and a variable for each specified field.
Display the last eight rows of intraday tick data.
tail(d)
ans=8×2 timetable
Time high low
____________________ _____ _____
22-Nov-2017 14:59:46 13.44 13.00
22-Nov-2017 14:59:49 13.44 13.00
22-Nov-2017 14:59:52 13.44 13.00
22-Nov-2017 14:59:55 13.44 13.00
22-Nov-2017 14:59:58 13.44 13.00
22-Nov-2017 15:00:01 13.44 13.00
22-Nov-2017 15:00:02 13.44 13.00
22-Nov-2017 15:00:02 13.44 13.00
Close the WDS connection.
close(c)
Retrieve Intraday Tick WDS Data Using Interval
Using a WDS connection, retrieve intraday tick data for a single security and display the data. Specify a date range for the intraday tick data to return. Also, specify the interval to aggregate the tick data.
Create a WDS connection.
c = wind;
Format output data for currency.
format bank
For the 600000.SH
security, retrieve the intraday tick data for high and low prices. Retrieve ticks from November 20, 2017 through November 23, 2017 using the WDS connection. Specify 1-minute bars to aggregate the data.
s = {'600000.SH'}; f = ["high","low"]; startdate = datetime('2017-11-20'); enddate = datetime('2017-11-23'); interval = 1; d = timeseries(c,s,f,{startdate,enddate},interval);
d
is a timetable that contains a row for each aggregated tick with the time and a variable for each specified field.
Display the last eight rows of the aggregated intraday tick data.
tail(d)
ans=8×2 timetable
Time high low
____________________ _____ _____
22-Nov-2017 14:53:00 13.22 13.21
22-Nov-2017 14:54:00 13.23 13.21
22-Nov-2017 14:55:00 13.23 13.22
22-Nov-2017 14:56:00 13.23 13.22
22-Nov-2017 14:57:00 13.23 13.22
22-Nov-2017 14:58:00 13.23 13.22
22-Nov-2017 14:59:00 13.24 13.21
22-Nov-2017 15:00:00 13.23 13.23
Close the WDS connection.
close(c)
Retrieve Intraday Tick WDS Data Using Time Range
Using a WDS connection, retrieve intraday tick data for a single security and display the data. Specify a date range for the intraday tick data to return. Also, specify the interval to aggregate the tick data. Then, specify the time range for each day in the date range.
Create a WDS connection.
c = wind;
Format output data for currency.
format bank
For the 600000.SH
security, retrieve the intraday tick data for high and low prices. Retrieve ticks from November 20, 2017 through November 23, 2017 using the WDS connection. Specify 1-minute bars to aggregate the data. Also, specify the time range from 9:30 AM through 10:30 AM using the 'PeriodStart'
and 'PeriodEnd'
name-value pair arguments.
s = {'600000.SH'}; f = ["high","low"]; startdate = datetime('2017-11-20'); enddate = datetime('2017-11-23'); interval = 1; starttime = datetime('09:30:00'); endtime = datetime('10:30:00'); d = timeseries(c,s,f,{startdate,enddate},interval,'PeriodStart',starttime,'PeriodEnd',endtime);
d
is a timetable that contains a row for each aggregated tick with the time and a variable for each specified field.
Display the first three rows of the aggregated intraday tick data.
head(d,3)
ans=3×2 timetable
Time high low
____________________ _____ _____
20-Nov-2017 09:30:00 12.72 12.68
20-Nov-2017 09:31:00 12.75 12.71
20-Nov-2017 09:32:00 12.77 12.73
Close the WDS connection.
close(c)
Input Arguments
c
— WDS connection
connection object
WDS connection, specified as a connection object created with the wind
function.
s
— Security
character vector | string scalar
Security, specified as a character vector or string scalar.
Example: '0001.HK'
Data Types: char
| string
f
— Fields
character vector | string scalar | cell array of character vectors | string array
Fields, specified as a character vector, string scalar, cell array of character vectors, or string array. For a single field, use a character vector or string scalar. For multiple fields, use a cell array of character vectors or string array.
For details about valid fields, contact Wind Information Co., Ltd.
Example: {"high","low"}
Data Types: char
| string
| cell
t
— Date
datetime
scalar | numeric scalar | character vector | string scalar
Date, specified as a datetime
scalar, numeric scalar,
character vector, or string scalar.
Example: datetime('today')
Data Types: datetime
| double
| char
| string
startdate
— Start date
datetime
scalar | numeric scalar | character vector | string scalar
Start date, specified as a datetime
scalar, numeric
scalar, character vector, or string scalar.
Example: datetime('2017-08-10')
Data Types: datetime
| double
| char
| string
enddate
— End date
datetime
scalar | numeric scalar | character vector | string scalar
End date, specified as a datetime
scalar, numeric
scalar, character vector, or string scalar.
Example: datetime('2017-08-19')
Data Types: datetime
| double
| char
| string
interval
— Interval
numeric scalar
Interval for aggregating interval tick data into minute bars, specified as a numeric scalar.
Example: 1
Data Types: double
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: d =
timeseries(c,'0001.HK','open',{'2017-08-10','2017-08-19'},1,'PeriodStart',datetime('now')-.25,'PeriodEnd',datetime('now'))
returns aggregated ticks for the open price in 1-minute bars for the
0001.HK
security from August 10, 2017, through August 19,
2017. This syntax returns data for ticks that occur within 6 hours of the current
time in each day.
PeriodStart
— Start time
datetime
scalar | numeric scalar | character vector | string scalar
Start time, specified as the comma-separated pair consisting of
'PeriodStart'
and a datetime
scalar, numeric scalar, character vector, or string scalar.
Use the 'PeriodStart'
name-value pair argument with
the PeriodEnd
name-value pair argument to specify
the time range for each day in the date range from
startdate
through
enddate
.
If you do not specify the 'PeriodEnd'
name-value
pair argument, the timeseries
function uses the end
of the trading day as the end of the time range.
Example: datetime('now')-.5
Data Types: datetime
| double
| char
| string
PeriodEnd
— End time
datetime
scalar | numeric scalar | character vector | string scalar
End time, specified as the comma-separated pair consisting of
'PeriodEnd'
and a datetime
scalar, numeric scalar, character vector, or string scalar.
Use the 'PeriodEnd'
name-value pair argument with
the PeriodStart
name-value pair argument to specify
the time range for each day in the date range from
startdate
through
enddate
.
If you do not specify the 'PeriodStart'
name-value
pair argument, the timeseries
function uses the
start of the trading day as the start of the time range.
Example: datetime('now')
Data Types: datetime
| double
| char
| string
Output Arguments
d
— Intraday tick WDS data
timetable
Intraday tick WDS data, returned as a timetable. The rows of the timetable
correspond to the date range specified by startdate
and
enddate
and, optionally, the time range specified
by the PeriodStart
and PeriodEnd
name-value pair arguments. The variables of the timetable correspond to the
fields specified in the f
input argument.
e
— WDS error identifier
numeric scalar
WDS error identifier, returned as a numeric scalar. The value 0
indicates a
successful execution of the timeseries
function. Otherwise, for
details about the error, contact Wind Information Co., Ltd.
Version History
Introduced in R2018a
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)