realtime
Description
realtime(
processes real-time data updates using a custom event handler function
c
,symbols
,eventhandler
)eventhandler
.
Examples
Retrieve Money.Net Real-Time Data for One Symbol
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)
Retrieve Money.Net Real-Time Data for Multiple Symbols
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)
Retrieve Money.Net Real-Time Data Using Custom Event Handler
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
c
— Money.Net web socket interface connection
moneynetws
object
Money.Net web socket interface connection, specified as a moneynetws
object created using the moneynetws
function.
symbols
— Money.Net symbol list
character vector | cell array of character vectors | string scalar | string array
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
eventhandler
— Event handler
"mnWSRealTimeEventHandler"
(default) | character vector | string scalar | function handle
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.
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 (한국어)