Retrieve Money.Net News Stories
This example shows how to retrieve news stories from Money.Net in different ways. You can search for a specific number of news stories. You can 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.
To access the code for this example, enter edit
MoneyNetNewsWorkflowExample.m
.
Create Money.Net Connection
Create the Money.Net connection c
using the user name
username
and password pwd
.
username = 'user@company.com'; pwd = '999999'; c = moneynet(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);
Display the news story title, identifier, and published time for the first
news story in the table n
.
n(1,1:3)
ans = ArticleTitle ArticleID PublishedTime ___________________________________________________________________ __________ _________________ 'Stop talking about replacements. Give PC owners something new al…' 3.8917e+09 05/13/16 10:00:02
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);
Display the news story title, identifier, and published time for the first news story.
n(1,1:3)
ans = ArticleTitle ArticleID PublishedTime ___________________________________________________________________ __________ _________________ 'LogMein Shares Edge Lower; LastPass Says Browser Extension Now A…' 4.0005e+09 06/08/16 13:22:04
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);
Display the news story title, identifier, and published time for the first news story.
n(1,1:3)
ans = ArticleTitle ArticleID PublishedTime ___________________________________________________________________ __________ _________________ 'Keep calm and ooze compassion: Leave must seize the moral high g…' 4.0007e+09 06/08/16 12:48:42
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);
Display the news story title, identifier, and published time for the first news story.
n(1,1:3)
ans = ArticleTitle ArticleID PublishedTime _________________________________________________ __________ _________________ 'Microsoft announces after party to Apple's WWDC' 4.0005e+09 06/08/16 12:51:49
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);
Convert news story titles to the string array
titles
.
titles = string(n.ArticleTitle);
Perform a non-case-sensitive search of the titles 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.
sentiment = contains(titles,'buy','IgnoreCase',true); sum(sentiment)
ans = 33
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.
Display the news story title, identifier, and published time for the first news story.
mnNewsStreamLatest(1,1:3)
ans = ArticleTitle ArticleID PublishedTime ___________________________________________________________________ __________ _________________ 'Stop talking about replacements. Give PC owners something new al…' 3.8917e+09 05/13/16 10:00:02
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
moneynet
| close
| news
| contains
Related Topics
- Retrieve Current and Historical Money.Net Data
- Retrieve Real-Time Money.Net Data
- Money.Net Error and Warning Messages