news
Search and stream Money.Net latest news stories
Description
returns news stories with additional options specified by one or more
n
= news(c
,Name,Value
)Name,Value
pair arguments.
news(
streams news stories in real time using the streaming options.c
,Name,Value
)
Examples
Retrieve News Stories
Create Money.Net connection c
using
a user name and password.
username = 'user@company.com'; pwd = '999999'; c = moneynet(username,pwd);
Retrieve news data n
for 50 news stories using the
Money.Net connection c
.
n = news(c);
n
returns as a table with 50 rows.
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
Close the Money.Net connection.
close(c)
Retrieve a Specific Number of Stories
Create Money.Net connection c
using
a user name and password.
username = 'user@company.com'; pwd = '999999'; c = moneynet(username,pwd);
Retrieve news data n
for 10 news stories using the
Money.Net connection c
.
n = news(c,'Number',10);
n
returns as a table with 10 rows.
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
Close the Money.Net connection.
close(c)
Filter News Story Retrieval by Specific Criteria
Create Money.Net connection c
using
a user name and password.
username = 'user@company.com'; pwd = '999999'; c = moneynet(username,pwd);
Retrieve news stories in the general finance category. Specify that the
news stories mention the term 'Dropbox'
and contain the
symbol for IBM®.
category = 'General Finance'; term = 'Dropbox'; symbol = 'IBM'; n = news(c,'Category',category,'SearchTerm',term,'Symbol',symbol);
n
is a table with one news story.
Display the news story title, identifier, and published time for the news story.
n(1,1:3)
ans = ArticleTitle ArticleID PublishedTime ________________________________________________________ __________ _________________ 'Hewlett Packard Enterprise (HPE) Teams Up with Dropbox' 4.0002e+09 06/08/16 11:11:05
Close the Money.Net connection.
close(c)
Stream News Data
Create Money.Net connection c
using
a user name and password.
username = 'user@company.com'; pwd = '999999'; c = moneynet(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
.
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, 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 connection.
close(c)
Stream News Data Using Custom Event Handler
Create Money.Net connection c
using
a user name and password.
username = 'user@company.com'; pwd = '999999'; c = moneynet(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)
ArticleTitle ArticleID PublishedTime PublisherCode PublisherName ArticleBodyDescription CategoryName URLLink SourceCode Priority Symbols ___________________________________________________________________ __________ _________________ _____________ _____________ ______________________ _________________ __________________________________________________________ __________ ________ _______ '@ETFcom: The Most Important ETF Of 2016 https://t.co/a5qCYK2o7c …' 3.9089e+09 05/17/16 14:39:10 'TWIT' 'Twitter' '' 'Twitter Finance' 'https://twitter.com/41120676/statuses/732641626921672704' 'MN' '0' {}
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 connection.
close(c)
Input Arguments
c
— Money.Net connection
connection object
Money.Net connection, specified as a connection object created
using moneynet
.
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.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: n = news(c,'Number',10);
Note
The name-value pair arguments in the searching and streaming groups are
independent. If you combine these name-value pair arguments, you receive this
error: Invalid combination of Name-Value pairs. Type HELP MONEYNET/NEWS
to see the valid syntax
.
Number
— Number of news stories
50
(default) | numeric scalar
Number of news stories, specified as the comma-separated pair
consisting of 'Number'
and a numeric scalar. The
maximum number of news stories that the Money.Net API 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
SearchTerm
— Search term
character vector | string scalar
Search term, specified as the comma-separated pair consisting of
'SearchTerm'
and a character vector or a 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
— Symbol
character vector | cell array of character vectors | string scalar | string array
Symbol, specified as the comma-separated pair consisting of
'Symbol'
and 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
Category
— News category
character vector | string scalar
News category, specified as the comma-separated pair consisting of
'Category'
and 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
Subscription
— Money.Net real-time news subscription
'on'
| 'off'
Money.Net real-time news subscription, specified as the
comma-separated pair consisting of 'Subscription'
and
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. Then, the
mnNewsStreamEventHandler
function updates the
list to display the latest news stories.
To specify a custom event handler function, use the name-value pair
argument 'EventHandler'
.
Example: news(c,'Subscription','on')
Example: news(c,'Subscription','on','EventHandler',myFcn)
EventHandler
— Custom event handler function
character vector | string scalar | function handle
Custom event handler function, specified as the comma-separated pair
consisting of 'EventHandler'
and 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 pair argument only with the name-value pair
argument 'Subscription'
and value
'on'
.
Example: news(c,'Subscription','on','EventHandler',myFcn)
Data Types: char
| function_handle
| string
Output Arguments
n
— News stories
table
News stories, returned as a table with these variables. Each row in the table represents one news story.
News Story Variable | Data Type | Variable Description |
---|---|---|
|
cell array of character vectors |
News story title |
|
double |
Internal Money.Net identifier of the news story |
|
|
Date and time the news story was published |
|
cell array of character vectors |
Publisher four-digit code |
|
cell array of character vectors |
Publisher name |
|
cell array of character vectors |
Body excerpt or short description of the news story |
|
cell array of character vectors |
Internal Money.Net category of the news story |
|
cell array of character vectors |
Website that contains the full news story |
|
cell array of character vectors |
News stream source code |
|
cell array of character vectors |
Priority of news story with these values:
|
|
cell array |
Symbols, or tickers, associated with the news story with these values:
|
Version History
Introduced in R2016b
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)