检索Money.net新闻报道
这个示例展示了如何检索新闻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.
要运行此示例,您需要Money.NET用户名和密码。要请求这些凭据,请联系Money.net。
要访问此示例的代码,请输入编辑MoneyNetnewsworkFlowExample.m
。
创建Money.net连接
创建Money.net连接C
使用用户名用户名
和密码PWD
。
用户名='user@company.com';PWD='999999';C = MoneyNet(用户名,PWD);
检索特定数量的新闻报道
检索新闻数据n
使用Money.net连接的10个新闻报道C
。
n =新闻(c,'数字',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.给PC所有者一些新的AL…'3.8917E+09 05/13/16 10:00:02
使用搜索词搜索新闻故事
检索提到窗口一词的新闻报道®。n
是一张具有50个新闻报道的数据的桌子。
术语='视窗';n =新闻(c,'搜索词',学期);
展示新闻故事的标题,标识符,并发布了第一个新闻故事的时间。
n(1,1:3)
ans = ArticleTitle ArticleID PublishedTime ___________________________________________________________________ __________ _________________ 'LogMein Shares Edge Lower;LastPass说浏览器扩展名现在是…'4.0005e+09 06/08/16 13:22:04
使用类别搜索新闻故事
在通用财务类别中检索新闻报道。n
是一张具有50个新闻报道的数据的桌子。
类别=“一般金融”;n =新闻(c,'类别',类别);
展示新闻故事的标题,标识符,并发布了第一个新闻故事的时间。
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
使用符号搜索新闻故事
检索包含Microsoft符号的新闻故事®。n
是一张具有50个新闻报道的数据的桌子。
符号='MSFT';n =新闻(c,'Symbol',象征);
展示新闻故事的标题,标识符,并发布了第一个新闻故事的时间。
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
分析分析师评分的新闻报道
搜索Microsoft的分析师评分类别。返回100个新闻报道。
符号='MSFT';类别='Analyst Ratings';n =新闻(c,'数字',100,'Symbol',象征,'类别',类别);
将新闻故事标题转换为字符串阵列标题
。
标题=字符串(n.ArticleTitle);
使用使用标题的非case敏感搜索包含
。在这里,假设这个词'买'
represents a buy rating for Microsoft from an investment analyst. Count the occurrences of buy ratings in the 100 news stories.
情感=包含(标题,'买',,,,“无知酶”,,,,true); sum(sentiment)
ANS = 33
要比较购买评级与卖出和持有评级,请替换'买'
带有相应的项并计算出现。通过这些计数,您可以看到哪些评分更普遍。
实时流媒体报道
使用默认事件处理程序功能开始订阅Money.net实时新闻数据流mnnewsstreameventhandler
。功能mnnewsstreameventhandler
通过填充工作区变量来处理新闻数据事件mnnewsstreamlatest
with the latest news stories. News stories populate in themnnewsstreamlatest
variable until it contains 10 rows. Then, the latest news stories overwrite the older ones inmnnewsstreamlatest
。要访问此功能的代码,请输入编辑mnnewsstreameventhandler.m
。
新闻(c,'订阅',,,,'上')
工作区变量mnnewsstreamlatest
出现在matlab中®Workspace.
展示新闻故事的标题,标识符,并发布了第一个新闻故事的时间。
mnnewsstreamlatest(1,1:3)
ans = ArticleTitle ArticleID PublishedTime ___________________________________________________________________ __________ _________________ 'Stop talking about replacements.给PC所有者一些新的AL…'3.8917E+09 05/13/16 10:00:02
要查看最新的10个新闻报道,请打开mnnewsstreamlatest
在变量编辑器中。
停止实时新闻数据流。
新闻(c,'订阅',,,,'离开')
Money.netstops updating news stories inmnnewsstreamlatest
。
关闭Money.net连接
关闭(c)