realtime
Description
realtime(
processes real-time data updates using a custom event handler function
c
,symbols
,eventhandler
)eventhandler
.
Examples
Create Money.Net web socket interface connection c
using a user name
and password.
username = "user@company.com"; pwd = "999999"; c = moneynetws(username,pwd);
Retrieve Money.Net real-time data updates for the IBM® symbol.
symbol = "IBM";
realtime(c,symbol)
The default event handler mnWSRealTimeEventHandler
processes all real-time data updates. To access the code for the default
event handler, enter edit
mnWSRealTimeEventHandler.m
.
mnWSRealTimeEventHandler
creates the workspace variable
IBMRealTime
. The
mnWSRealTimeEventHandler
function populates the table
IBMRealTime
with real-time data updates. To see the
real-time data, open IBMRealTime
in the Variables
editor.
Stop the symbol subscription.
stop(c)
mnWSRealTimeEventHandler
stops processing all real-time
data updates. The last real-time data update remains in
IBMRealTime
.
Close the Money.Net web socket interface connection.
close(c)
Create Money.Net web socket interface connection c
using a user name
and password.
username = "user@company.com"; pwd = "999999"; c = moneynetws(username,pwd);
Retrieve Money.Net real-time data updates for the symbols IBM and Google®.
symbols = ["IBM" "GOOG"]; realtime(c,symbols)
The default event handler mnWSRealTimeEventHandler
processes all real-time data updates. To access the code for the default
event handler, enter edit
mnWSRealTimeEventHandler.m
.
The mnWSRealTimeEventHandler
function creates the
workspace variables IBMRealTime
and
GOOGRealTime
. The
mnWSRealTimeEventHandler
function populates the
tables IBMRealTime
and GOOGRealTime
with real-time data updates. To see the real-time data, open either variable
in the Variables editor.
Stop all symbol subscriptions.
stop(c)
mnWSRealTimeEventHandler
stops processing all real-time
data updates. The last real-time data update remains in each workspace
variable.
Close the Money.Net web socket interface connection.
close(c)
Create Money.Net web socket interface connection c
using a user name
and password.
username = "user@company.com"; pwd = "999999"; c = moneynetws(username,pwd);
Define a custom event handler function myfcn
. The
myfcn
function displays real-time Money.Net data to
the Command Window. You can write a custom function that processes real-time
data updates differently. For details, see Writing and Running Custom Event Handler Functions.
myfcn = @(x)disp(x);
Retrieve Money.Net real-time data updates for the IBM symbol using myfcn
.
symbol = "IBM";
realtime(c,symbol,myfcn)
myfcn
displays real-time data updates for IBM in the Command Window.
Stop the symbol subscription.
stop(c)
myfcn
stops displaying real-time data updates in the
Command Window.
Close the Money.Net web socket interface connection.
close(c)
Input Arguments
Money.Net web socket interface connection, specified as a moneynetws
object created using the moneynetws
function.
Money.Net symbol list, specified as a character vector, cell array of character vectors, string scalar, or a string array. To specify one symbol, use a character vector or string scalar. To specify multiple symbols, use a cell array of character vectors or a string array.
Example: "IBM"
Example: ["IBM" "GOOG"]
Data Types: char
| cell
| string
Event handler, specified as a character vector, string scalar, or a
function handle that specifies the name of the event handler function. Write
a custom event handler function to process any type of real-time Money.Net
events. This function must have at least one input argument that is a table.
The table format must be similar to the format of the output argument in
getdata
. The event handler
function returns all available fields when it executes for the first time.
The event handler function executes every time Money.Net provides a
real-time update. For details about custom event handler functions, see
Writing and Running Custom Event Handler Functions.
For example, to display real-time data updates in the Command Window, enter this code to define a custom event handler function:
symbol = "IBM";
myfcn = @(x)disp(x);
realtime(c,symbol,myfcn)
If you do not specify a custom event handler function, the default event
handler mnWSRealTimeEventHandler
runs. To access the
code for the default event handler, enter edit
mnWSRealTimeEventHandler.m
.
The mnWSRealTimeEventHandler
function creates a
workspace variable. The workspace variable name is a concatenation of the
symbol name and the word RealTime
. For example,
mnWSRealTimeEventHandler
populates real-time data
for the symbol IBM into IBMRealTime
. This workspace variable
is a table with variables for each field. The values in the table change
when Money.Net provides a real-time data update. Empty fields from Money.Net
populate as NaN
, NaT
, and so on,
depending on the data type.
First, mnWSRealTimeEventHandler
runs using a table of
current data. Then, mnWSRealTimeEventHandler
runs each
time an update occurs.
Data Types: char
| function_handle
| string
Version History
Introduced in R2021b
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.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)