realtime
Retrieve Money.Net real-time data
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 connection c
using
a user name and password.
username = 'user@company.com'; pwd = '999999'; c = moneynet(username,pwd);
Retrieve Money.Net real-time data updates for the IBM® symbol.
symbol = 'IBM';
realtime(c,symbol)
The default event handler mnRealTimeEventHandler
processes all real-time data updates. To access the code for the default
event handler, enter edit
mnRealTimeEventHandler.m
.
mnRealTimeEventHandler
creates the workspace variable
IBMRealTime
. The
mnRealTimeEventHandler
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)
mnRealTimeEventHandler
stops processing all real-time
data updates. The last real-time data update remains in
IBMRealTime
.
Close the Money.Net connection.
close(c)
Retrieve Money.Net Real-Time Data for Multiple Symbols
Create Money.Net connection c
using
a user name and password.
username = 'user@company.com'; pwd = '999999'; c = moneynet(username,pwd);
Retrieve Money.Net real-time data updates for the symbols IBM and Yahoo!®.
symbols = {'IBM','YHOO'}; realtime(c,symbols)
The default event handler mnRealTimeEventHandler
processes all real-time data updates. To access the code for the default
event handler, enter edit
mnRealTimeEventHandler.m
.
The mnRealTimeEventHandler
function creates the
workspace variables IBMRealTime
and
YHOORealTime
. The
mnRealTimeEventHandler
function populates the tables
IBMRealTime
and YHOORealTime
with
real-time data updates. To see the real-time data, open either variable in
the Variables editor.
Stop all symbol subscriptions.
stop(c)
mnRealTimeEventHandler
stops processing all real-time
data updates. The last real-time data update remains in each workspace
variable.
Close the Money.Net connection.
close(c)
Retrieve Money.Net Real-Time Data Using a Custom Event Handler
Create Money.Net connection c
using
a user name and password.
username = 'user@company.com'; pwd = '999999'; c = moneynet(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)
Symbol Description Yesterday YesterdayDateTime Bid Ask ExchangeOfTheCurrentBidPrice ExchangeOfTheCurrentAskPrice High Low Volume YearHigh YearHighDateTime YearLow YearLowDateTime Dividend DividendYield EPS EPSDateTime EPSDiluted EPSDilutedDateTime PERatio BidSize AskSize LastTradeDate LastTradeTime Open MarketCap Exchange TimeOfLastUpdatetoBidAskOrTrade LastTradeCondition QuoteBidAskCondition AverageVolume CurrencyCode ShortInterest PricetoBookRatio SharesOutstanding Beta VWAP LastOutsideOfMarketHours LastTradeDateOutsideOfMarketHours LastTradeTimeOutsideOfMarketHours LastTradeDirection LastTradeSize LastTradeExchange Last SecurityType ______ ______________________________ _________ _________________ ______ ______ ____________________________ ____________________________ ______ ______ __________ ________ ________________ _______ _______________ ________ _____________ _____ _________________ __________ __________________ _______ _______ _______ _____________ _____________ ______ _________ ________ _______________________________ __________________ ____________________ _____________ ____________ _____________ ________________ _________________ ____ ______ ________________________ _________________________________ _________________________________ __________________ _____________ _________________ ______ ____________ 'IBM' 'INTERNATIONAL BUSINESS MACHS' 148.31 05/24/16 00:00:00 151.65 151.67 '' '' 151.67 148.50 2476783.00 173.78 07/20/15 116.90 02/11/16 5.60 3.77 13.30 02/29/16 00:00:00 13.25 02/29/16 00:00:00 11.18 6.00 3.00 05/25/16 13:44:52 148.93 142371.96 'NYSE' 13:44:52 '' '' 4141081.00 'USD' 20241776.00 9.44 959962000.00 0.70 150.72 148.79 05/25/16 09:30:00 '=' 100.00 'OMDF' 151.66 NaN
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 connection.
close(c)
Input Arguments
c
— Money.Net connection
connection object
Money.Net connection, specified as a connection object created
using moneynet
.
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
'mnRealTimeEventHandler'
(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 mnRealTimeEventHandler
runs. To access the code
for the default event handler, enter edit
mnRealTimeEventHandler.m
.
The mnRealTimeEventHandler
function creates a
workspace variable. The workspace variable name is a concatenation of the
symbol name and the word RealTime
. For example,
mnRealTimeEventHandler
populates real-time data for
the symbol IBM into IBMRealTime
. This workspace variable
is a table with columns 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, mnRealTimeEventHandler
runs using a table of
current data. Then, mnRealTimeEventHandler
runs each
time an update occurs.
Data Types: char
| function_handle
| string
Version History
Introduced in R2016b
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 (한국어)