Main Content

realtime

Retrieve Money.Net real-time data

Description

example

realtime(c,symbols) subscribes to real-time data updates using the Money.Net connection c for the specified symbols. The default event handler function mnRealTimeEventHandler processes and retrieves real-time data updates for each specified symbol.

example

realtime(c,symbols,eventhandler) processes real-time data updates using a custom event handler function eventhandler.

Examples

collapse all

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)

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)

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

collapse all

Money.Net connection, specified as a connection object created using moneynet.

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 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