主要内容

即时的

Retrieve Money.Net real-time data

描述

example

即时的(c,符号)subscribes to real-time data updates using the Money.Net connectionc对于指定的符号。默认事件处理程序功能mnrealtimeeventhandlerprocesses and retrieves real-time data updates for each specified symbol.

example

即时的(c,符号,EventHandler)使用自定义事件处理程序功能处理实时数据更新EventHandler

例子

全部收缩

Create Money.Net connectionc使用用户名和密码。

username ='user@company.com';PWD ='999999';C = MoneyNet(用户名,PWD);

检索IBM的Money.NET实时数据更新®象征。

符号='IBM';实时(C,符号)

默认事件处理程序mnrealtimeeventhandler处理所有实时数据更新。要访问默认事件处理程序的代码,请输入编辑mnrealtimeeventhandler.m

mnrealtimeeventhandlercreates the workspace variableIBMRealTime。这mnrealtimeeventhandlerfunction populates the tableIBMRealTimewith real-time data updates. To see the real-time data, openIBMRealTime在变量编辑器中。

Stop the symbol subscription.

stop(c)

mnrealtimeeventhandler停止处理所有实时数据更新。最后的实时数据更新仍在IBMRealTime

Close the Money.Net connection.

close(c)

Create Money.Net connectionc使用用户名和密码。

username ='user@company.com';PWD ='999999';C = MoneyNet(用户名,PWD);

检索Money.NET符号的实时数据更新IBM和Yahoo!®

符号= {'IBM','YHOO'}; realtime(c,symbols)

默认事件处理程序mnrealtimeeventhandler处理所有实时数据更新。要访问默认事件处理程序的代码,请输入编辑mnrealtimeeventhandler.m

mnrealtimeeventhandler函数创建工作区变量IBMRealTimeYHOORealTime。这mnrealtimeeventhandlerfunction populates the tablesIBMRealTimeYHOORealTimewith real-time data updates. To see the real-time data, open either variable in the Variables editor.

停止所有符号订阅。

stop(c)

mnrealtimeeventhandler停止处理所有实时数据更新。最后的实时数据更新仍在each workspace variable.

Close the Money.Net connection.

close(c)

Create Money.Net connectionc使用用户名和密码。

username ='user@company.com';PWD ='999999';C = MoneyNet(用户名,PWD);

定义自定义事件处理程序功能myfcn。这myfcnfunction displays real-time Money.Net data to the Command Window. You can write a custom function that processes real-time data updates differently. For details, see编写和运行自定义事件处理程序功能

myfcn = @(x)disp(x);

检索Money.net使用IBM符号的实时数据更新myfcn

符号='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 11.18 6.00 3.00 05/25/16 13:44:52 148.93 142371.96 'NYSE' 13:44:52 '' '' 4141081.00 'USD' 20241776.00 9.44 959962000.00 0.70 150.72 148.79 05/25/16 09:30:00 '=' 100.00 'OMDF' 151.66 NaN

myfcn在命令窗口中显示IBM的实时数据更新。

Stop the symbol subscription.

stop(c)

myfcn停止在命令窗口中显示实时数据更新。

Close the Money.Net connection.

close(c)

输入参数

全部收缩

Money.net连接,指定为使用的连接对象moneynet

Money.net符号列表,指定为字符向量,字符向量的单元格数组,字符串标量或字符串数​​组。要指定一个符号,请使用字符向量或字符串标量。要指定多个符号,请使用字符向量的单元格数组或字符串数​​组。

例子:'IBM'

例子:{'ibm','goog'}

数据类型:char|细胞|string

事件处理程序,指定为字符向量,字符串标量或指定事件处理程序函数名称的函数句柄。编写自定义事件处理程序功能以处理任何类型的实时货币。此函数必须至少具有一个表格参数。表格式必须类似于输出参数的格式GetData。这event handler function returns all available fields when it executes for the first time. The event handler function executes every time Money.Net provides a real-time update. For details about custom event handler functions, see编写和运行自定义事件处理程序功能

例如,要在命令窗口中显示实时数据更新,请输入此代码以定义自定义事件处理程序函数:

符号='IBM';myfcn = @(x)disp(x);实时(c,符号,myfcn)

如果未指定自定义事件处理程序功能,则默认事件处理程序mnrealtimeeventhandlerruns. To access the code for the default event handler, enter编辑mnrealtimeeventhandler.m

mnrealtimeeventhandler函数创建一个工作区变量。工作区变量名称是符号名称和单词的串联即时的。例如,mnrealtimeeventhandler将符号IBM的实时数据填充到IBMRealTime。This workspace variable is a table with columns for each field. The values in the table change when Money.Net provides a real-time data update. Empty fields from Money.Net populate asNaN,NaT, and so on, depending on the data type.

First,mnrealtimeeventhandler使用当前数据表运行。然后,mnrealtimeeventhandler每次发生更新时运行。

数据类型:char|function_handle|string

Version History

Introduced in R2016b