d = realtime(c,s,f)
returns the real-time snapshot Wind Data Feed Services (WDS) data for the specified securities and fields using the WDS
connection.
d is a timetable that contains rows for each security
with the time and these variables:
Security
Last price
Volume
Close the WDS connection.
close(c)
Using a WDS connection, subscribe to two securities and process real-time
events by using an event handler function. Then cancel the subscription.
Create a WDS connection.
c = wind;
Format output data for currency.
format bank
Using the 0002.HK and 0003.HK securities and the
WDS connection, retrieve real-time data for the last price, volume, and last volume fields.
Process real-time data events using the sample event handler function
windEventHandler. You can use the sample event handler function or
create a custom event handler function to process events.
s = {'0002.HK','0003.HK'};
f = {'rt_last','rt_vol','rt_last_vol'}};
requestid = realtime(c,s,f,@(varargin)windEventHandler(varargin))
requestid =
uint64
5
requestid is the request identifier associated with the subscription.
The event handler function windEventHandler creates a variable in the
MATLAB® workspace named winddata. This variable contains the
subscription data.
WDS connection, specified as a connection object created with the wind function.
Securities, specified as a character vector, string scalar, cell array of character vectors,
or string array. For a single security, use a character vector or string scalar. For
multiple securities, use a cell array of character vectors or string array.
Example: '0001.HK'
Data Types: char | string | cell
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
Event handler function, specified as a function handle. You can use the
example event handling function windEventHandler to
process real-time WDS events. Or, you can define a custom event handler
function to process events of your choice.
The event handler function windEventHandler creates the
variable winddata in the MATLAB workspace. The windEventHandler function
returns winddata as a timetable that contains real-time
WDS data. If an error occurs, the function returns
winddata as a table that contains an error code. For
troubleshooting, contact Wind Information Co., Ltd.
The winddata timetable contains rows for each real-time
WDS event with the time. The first variable in this timetable is the
specified securities in the s input argument. The
remaining variables are the specified fields in the f
input argument.
To access the code of the function, enter edit
windEventHandler at the command line.
To define a custom event handler function:
Choose the WDS events to process, monitor, or evaluate.
Decide how the custom event handler processes these
events.
Determine the input and output arguments for the custom event
handler function.
After defining the function, you can run it by passing the name of the
function as a function handle. For details about function handles, see Create Function Handle.
Real-time snapshot WDS data, returned as a timetable. The rows of the
timetable correspond to the real-time snapshots with the time. The first
variable in the timetable is the specified securities in the
s input argument. The remaining variables in the
timetable are the specified fields in the f input
argument.
Request identifier for the real-time data subscription, returned as a
numeric scalar. To stop the real-time data subscription, specify the
requestid output argument in the stop function.
WDS error identifier, returned as a numeric scalar. The value 0 indicates a
successful execution of the realtime function. Otherwise, for
details about the error, contact Wind Information Co., Ltd.
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.