Retrieve Money.Net News Stories Using Money.Net Web Socket Interface
This example shows how to retrieve news stories from Money.Net in different ways using the Money.Net web socket interface. You can search for a specific number of news stories, search for news stories using specific filter criteria, or you can stream news stories in real time.
To run this example, you need a Money.Net user name and password. To request these credentials, contact Money.Net.
Create Money.Net Connection
Create the Money.Net web socket interface connection c
using a user name and password.
username = "user@company.com"; pwd = "999999"; c = moneynetws(username,pwd);
Retrieve Specific Number of News Stories
Retrieve news data n
for 10 news stories using the
Money.Net connection c
.
n = news(c,Number=10);
Search News Stories Using Search Term
Retrieve news stories that mention the term Windows®. n
is a table with data for 50 news
stories.
term = "Windows";
n = news(c,SearchTerm=term);
Search News Stories Using Category
Retrieve news stories in the general finance category. n
is
a table with data for 50 news stories.
category = "General Finance";
n = news(c,Category=category);
Search News Stories Using Symbol
Retrieve news stories that contain the symbol for Microsoft®. n
is a table with data for 50 news
stories.
symbol = "MSFT";
n = news(c,Symbol=symbol);
Analyze News Stories for Analyst Ratings
Search the analyst ratings category for Microsoft. Return 100 news stories.
symbol = "MSFT"; category = "Analyst Ratings"; n = news(c,Number=100,Symbol=symbol,Category=category);
Perform a non-case-sensitive search of the headlines using
contains
. Here, assume that the word
"buy"
represents a buy rating for Microsoft from an investment analyst. Count the occurrences of buy ratings
in the 100 news stories.
headlines = n.headline;
sentiment = contains(headlines,"buy",IgnoreCase=true);
buys = sum(sentiment);
To compare buy ratings against sell and hold ratings, replace
"buy"
with the corresponding term and count the
occurrences. With these counts, you can see which ratings are more
common.
Stream News Stories in Real Time
Start the subscription to the Money.Net real-time news data stream using the
default event handler function mnNewsStreamEventHandler
.
The function mnNewsStreamEventHandler
processes news data
events by populating the workspace variable
mnNewsStreamLatest
with the latest news stories. News
stories populate in the mnNewsStreamLatest
variable until it
contains 10 rows. Then, the latest news stories overwrite the older ones in
mnNewsStreamLatest
. To access the code for this function,
enter edit mnNewsStreamEventHandler.m
.
news(c,Subscription="on")
The workspace variable mnNewsStreamLatest
appears in the
MATLAB® Workspace. To see the latest 10 news stories, open
mnNewsStreamLatest
in the Variables editor.
Stop the real-time news data stream.
news(c,Subscription="off")
Money.Net stops updating news stories in
mnNewsStreamLatest
.
Close Money.Net Connection
close(c)
See Also
moneynetws
| isconnection
| news
| close
| contains
Related Topics
- Retrieve Current and Historical Money.Net Data Using Money.Net Web Socket Interface
- Retrieve Real-Time Money.Net Data Using Money.Net Web Socket Interface