Main Content

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, contactMoney.Net.

To access the code for this example, enteredit MoneyNetNewsWorkflowExample.m.

Create Money.Net Connection

Create the Money.Net connectioncusing the user nameusernameand passwordpwd.

username ='user@company.com'; pwd ='999999'; c = moneynet(username,pwd);

Retrieve Specific Number of News Stories

Retrieve news datanfor 10 news stories using the Money.Net connectionc.

n = news(c,'Number',10);

Display the news story title, identifier, and published time for the first news story in the tablen.

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®.nis 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.nis 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®.nis 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 arraytitles.

titles = string(n.ArticleTitle);

Perform a non-case-sensitive search of the titles usingcontains. 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 functionmnNewsStreamEventHandler. The functionmnNewsStreamEventHandlerprocesses news data events by populating the workspace variablemnNewsStreamLatestwith the latest news stories. News stories populate in themnNewsStreamLatestvariable until it contains 10 rows. Then, the latest news stories overwrite the older ones inmnNewsStreamLatest. To access the code for this function, enteredit mnNewsStreamEventHandler.m.

news(c,'Subscription','on')

The workspace variablemnNewsStreamLatestappears 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, openmnNewsStreamLatestin the Variables editor.

Stop the real-time news data stream.

news(c,'Subscription','off')

Money.Net stops updating news stories inmnNewsStreamLatest.

Close Money.Net Connection

close(c)

See Also

|||

Related Topics

External Websites