www.gusucode.com > trading工具箱matlab源码程序 > trading/tradingdemos/cqgexpressioneventhandler.m
function cqgexpressioneventhandler(varargin) %CQGEXPRESSIONEVENTHANDLER Example CQG expression event handler switch varargin{end} case {'ExpressionResolved','ExpressionAdded','ExpressionUpdated'} % Get the number of items in the expression cqgExpression = varargin{3}; numItems = cqgExpression.Count; % Preallocate output cqgHistoryData = zeros(numItems,2); cqgHistoryDates = cell(numItems,1); % Get the data and dates for i = 0:numItems-1 cqgHistoryDates{i+1,1} = cqgExpression.Item(i).Timestamp; cqgExpressionOutputs = cqgExpression.Item(i); for j = 1:cqgExpressionOutputs.Count cqgHistoryData(i+1,j+1) = cqgExpressionOutputs.Item(int32(j-1)); end end % Convert the dates to date numbers cqgHistoryData(:,1) = datenum(cqgHistoryDates); % Send data to base workspace assignin('base','cqgHistoryData',cqgHistoryData) end