检索实时货币.NET数据
This example shows how to retrieve real-time data from Money.Net for a symbol. It explains how to subscribe to real-time updates, stop subscription, and process real-time updates using a custom event handler function.
要处理实时数据更新,您可以使用默认事件处理程序功能。或者,对于其他方法,您可以编写自定义事件处理程序功能。对于使用Money.NET数据编写自定义事件处理程序功能,请参见realtime
。For custom event handler functions, seeWriting and Running Custom Event Handler Functions。
This example requires a Money.Net user name and password. To request these credentials, contactMoney.net。
要访问此示例的代码,请输入编辑MoneyNetDataworkFlowExample.m
。
创建Money.net连接
创建Money.net连接C
using a user name and password.
用户名='user@company.com';pwd ='999999';C = MoneyNet(用户名,PWD);
检索一个符号的实时数据
Retrieve Money.Net real-time data updates for the IBM®象征。
符号='IBM';realtime(c,symbol)
默认事件处理程序mnrealtimeeventhandler
processes all real-time data updates. To access the code for the default event handler, enter编辑mnRealTimeEventHandler.m
。
这mnrealtimeeventhandler
函数创建工作区变量ibmrealtime
。这mnrealtimeeventhandler
功能填充表ibmrealtime
带有实时数据更新。要查看实时数据,请打开ibmrealtime
在变量编辑器中。
停止实时数据更新
停止符号订阅。
停止(c)
mnrealtimeeventhandler
停止s processing all real-time data updates. The last real-time data update remains inibmrealtime
。
使用自定义事件处理程序功能检索实时数据
定义自定义事件处理程序功能myfcn
。这myfcn
函数将Money.NET实时数据显示到命令窗口。
myfcn = @(x)disp(x);
Retrieve Money.Net real-time data updates for the IBM symbol usingmyfcn
。
符号='IBM';实时(c,符号,myfcn)
Symbol Description Yesterday YesterdayDateTime Bid Ask ExchangeOfTheCurrentBidPrice ExchangeOfTheCurrentAskPrice High Low Volume YearHigh YearHighDateTime YearLow YearLowDateTime Dividend DividendYield EPS EPSDateTime EPSDiluted EPSDilutedDateTime PERatio BidSize AskSize LastTradeDate LastTradeTime Open MarketCap Exchange TimeOfLastUpdatetoBidAskOrTrade LastTradeCondition QuoteBidAskCondition AverageVolume CurrencyCode ShortInterest PricetoBookRatio SharesOutstanding Beta VWAP LastOutsideOfMarketHours LastTradeDateOutsideOfMarketHours LastTradeTimeOutsideOfMarketHours LastTradeDirection LastTradeSize LastTradeExchange Last SecurityType ______ ______________________________ __________________________ ______ ______ ____________________________ ____________________________ ______ ______ __________ ________ ________________ _______ _______________ ________ _____________ _____ _________________ __________ __________________ _______ _______ _______ _____________ _____________ ______ _________ ________ _______________________________ __________________ ____________________ _____________ ____________ _____________ ________________ _________________ ____ ______ ________________________ _________________________________ _________________________________ __________________ _____________ _________________ ______ ____________ 'IBM' 'INTERNATIONAL BUSINESS MACHS' 148.31 05/24/16 00:00:00 151.65 151.67 '' '' 151.67 148.50 2476783.00 173.78 07/20/15 116.90 02/11/16 5.60 3.77 13.30 02/29/16 00:00:00 13.25 02/29/16 00:00:00:00 11.00 11.00 11.00 3.00 05/25/16 13:44:44:52 148.93 148.93 148.93 142371.96NYSE'13:44:52''''4141081.00'USD'20241776.00 9.44 959962000.00 0.70 150.72 150.72 148.79 05/25/16 09:30:30:30:00
myfcn
displays real-time data updates for IBM in the Command Window.
停止符号订阅。
停止(c,符号)
myfcn
停止s displaying real-time data updates in the Command Window.
关闭Money.net连接
关闭(c)