Retrieve Real-Time Money.Net Data Using Money.Net Web Socket Interface
This example shows how to retrieve real-time data from Money.Net for a symbol. It explains how to subscribe to real-time updates, stop subscription, and process real-time updates using a custom event handler function. The example uses the Money.Net web socket interface to create a Money.Net connection.
To process real-time data updates, you can use the default event handler function.
For a different approach, you can write a custom event handler function. To write
custom event handler functions with Money.Net data, see realtime
. For custom event handler functions, see Writing and Running Custom Event Handler Functions.
This example requires a Money.Net user name and password. To request these credentials, contact Money.Net.
Create Money.Net Connection
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 Real-Time Data for One Symbol
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
.
The mnWSRealTimeEventHandler
function 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 Real-Time Data Updates
Stop the symbol subscription.
stop(c)
mnWSRealTimeEventHandler
stops processing all real-time
data updates. The last real-time data update remains in
IBMRealTime
.
Retrieve Real-Time Data Using Custom Event Handler Function
Define a custom event handler function myfcn
. The
myfcn
function displays Money.Net real-time data to the
Command Window.
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,symbol)
myfcn
stops displaying real-time data updates in the
Command Window.
Close Money.Net Connection
close(c)
See Also
moneynetws
| isconnection
| getsubscriptions
| realtime
| stop
| close
Related Topics
- Writing and Running Custom Event Handler Functions
- Retrieve Current and Historical Money.Net Data Using Money.Net Web Socket Interface
- Retrieve Money.Net News Stories Using Money.Net Web Socket Interface