Main Content

news

Search and stream Money.Net latest news stories

Since R2021b

Description

Retrieve Money.Net News Stories

n = news(c) returns Money.Net news stories n using the Money.Net web socket interface connection c.

example

n = news(c,Name=Value) specifies options using one or more name-value arguments. For example, Number=25 returns 25 news stories.

example

Subscribe to Real-Time Updates for Money.Net News Stories

news(c,Subscription="on",EventHandler=eventhandler) subscribes to real-time updates for news stories. This syntax executes the specified event handler function when a new news story becomes available.

example

news(c,Subscription="off") stops the real-time updates for news stories.

example

Examples

collapse all

Create Money.Net web socket interface connection c using a user name and password.

username = "user@company.com";
pwd = "999999";

c = moneynetws(username,pwd);

Retrieve news data n for 50 news stories using the Money.Net web socket interface connection c.

n = news(c);

n returns as a table with 50 rows.

Close the Money.Net web socket interface connection.

close(c)

Create Money.Net web socket interface connection c using a user name and password.

username = "user@company.com";
pwd = "999999";

c = moneynetws(username,pwd);

Retrieve news data n for 10 news stories using the Money.Net web socket interface connection c.

n = news(c,Number=10);

n returns as a table with 10 rows.

Close the Money.Net web socket interface connection.

close(c)

Create Money.Net web socket interface connection c using a user name and password.

username = "user@company.com";
pwd = "999999";

c = moneynetws(username,pwd);

Retrieve news stories in the general finance category. Specify that the news stories mention the term "stock" and contain the symbol for IBM®.

category = "General Finance";
term = "stock";
symbol = "IBM";
n = news(c,Category=category,SearchTerm=term,Symbol=symbol);

n is a table with 50 news stories.

Close the Money.Net web socket interface connection.

close(c)

Create Money.Net web socket interface connection c using a user name and password.

username = "user@company.com";
pwd = "999999";

c = moneynetws(username,pwd);

Turn on 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.

eventhandler = "mnNewsStreamEventHandler";
news(c,Subscription="on",EventHandler=eventhandler)

The workspace variable mnNewsStreamLatest appears in the MATLAB® Workspace. To see the latest 10 news stories, explore mnNewsStreamLatest in the Variables editor.

Turn off the real-time news data stream.

news(c,Subscription="off")

Real-time updates stop in the workspace variable mnNewsStreamLatest.

Close the Money.Net web socket interface connection.

close(c)

Create Money.Net web socket interface connection c using a user name and password.

username = "user@company.com";
pwd = "999999";

c = moneynetws(username,pwd);

Turn on the subscription to the Money.Net real-time news data stream using the custom event handler function myfnc. Here, define myfnc to display Money.Net news data to the Command Window. You can write a custom event handler function to process streaming news stories differently. For details, see Writing and Running Custom Event Handler Functions.

myfnc = @(x)disp(x);
news(c,Subscription="on",EventHandler=myfnc)

Money.Net news stories stream to the Command Window.

Turn off the real-time news data stream.

news(c,Subscription="off")

Real-time updates stop in the Command Window.

Close the Money.Net web socket interface connection.

close(c)

Input Arguments

collapse all

Money.Net web socket interface connection, specified as a moneynetws object created using the moneynetws function.

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 Money.Net events related to news stories. For details about custom event handler functions, see Writing and Running Custom Event Handler Functions.

Data Types: char | function_handle | string

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: n = news(c,Number=10); returns 10 Money.Net news stories.

Note

The name-value arguments in the searching and streaming groups are independent. If you combine these name-value arguments, you receive this error: Invalid combination of Name-Value pairs. Type HELP MONEYNET/NEWS to see the valid syntax.

Searching News Stories Options

collapse all

Number of news stories, specified as a numeric scalar. The maximum number of news stories that the Money.Net web socket interface can return is 500.

The number of news stories returned can be fewer than the specified number because Money.Net provides only available news stories. When you specify this option by itself, news does not filter the story content.

Example: n = news(c,Number=10);

Data Types: double

Search term, specified as a character vector or string scalar. news returns available news stories that contain the search term in the title or body of the news story.

Example: n = news(c,SearchTerm="Windows 10");

Data Types: char | string

Symbol, 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. news returns news stories related to the specified symbols.

Example: n = news(c,Symbol=["IBM" "YHOO"]);

Data Types: char | cell | string

News category, specified as a character vector or a string scalar. news returns stories only in the news category specified.

Example: n = news(c,Category="General Finance");

Data Types: char | string

Streaming News Stories Options

collapse all

Money.Net real-time news subscription, specified as the values "on" or "off". To turn on the Money.Net real-time news subscription, specify the value "on". To turn off the subscription, specify the value "off".

By default, the sample event handler function mnNewsStreamEventHandler processes the retrieval of news stories during real-time news subscription. To access the code for this function, enter edit mnNewsStreamEventHandler.m. The mnNewsStreamEventHandler function creates the workspace variable mnNewsStreamLatest. Then, mnNewsStreamEventHandler populates the table mnNewsStreamLatest with the latest 10 news stories from Money.Net. The mnNewsStreamEventHandler function updates the list to display the latest news stories.

To specify a custom event handler function, use the name-value argument EventHandler.

Example: news(c,Subscription="on")

Example: news(c,Subscription="on",EventHandler=myFcn)

Custom event handler function, specified as a character vector, string scalar, or function handle. To process the latest news stories, you can write your own custom event handler function. This function must have an input argument specified as a table. Each new news story from Money.Net is a single row in a table. For details about working with custom event handler functions, see Writing and Running Custom Event Handler Functions.

Specify this name-value argument only with the name-value argument Subscription and value "on".

Example: news(c,Subscription="on",EventHandler=myFcn)

Data Types: char | function_handle | string

Output Arguments

collapse all

News stories, returned as a table with these variables. Each row in the table represents one news story.

News Story VariableData TypeVariable Description

id

string array

News story identifier

publisher

table

Publisher name and identifier

headline

string array

News story headline

content

string array

Portion of news story content

url

string array

URL for the website that contains the news story

tickers

cell array

List of tickers associated with the news story

posted

datetime array

Date and time the news story was posted

updated

datetime array

Date and time the news story was last updated

category

string array

Category for the news story

Version History

Introduced in R2021b