www.gusucode.com > trading工具箱matlab源码程序 > trading/trading/@xtrdr/createNotifier.m
function createNotifier(x,varargin) %CREATENOTIFIER Instrument notifier for X_TRADER. % CREATENOTIFIER(X,S) creates the XTRDR instrument notifier defined by the input % structure S. X is the XTRDR object. % % CREATENOTIFIER(X,'Property1','Value1','Property2','Value2',...) % creates the XTRDR instrument notifier defined by the given name/value pairs. % % See also XTRDR, CREATEINSTRUMENT, CREATEORDERPROFILE, CREATEORDERSET. % Copyright 2011-2012 The MathWorks, Inc. %Instantiate the X_TRADER XTAPI instrument object ttInstrNotify = actxserver('Xtapi.TTInstrNotify'); %Get valid properties of instrument object ttInstrNotifyProperties = fields(ttInstrNotify); %Create instrument from input structure if ~isempty(varargin) && isstruct(varargin{1}) %Get field names in structures structFields = fields(varargin{1}); %Set properties of ttInstrNotify for i = 1:length(structFields) if any(strcmp(structFields{i},ttInstrNotifyProperties)) ttInstrNotify.(structFields{i}) = varargin{1}.(structFields{i}); end end else %Create instrument from name/value pairs numInputs = length(varargin); if mod(numInputs,2) error(message('trading:xtrdr:nameValuePairMismatch')) end for i = 1:2:numInputs ttInstrNotify.(varargin{i}) = varargin{i+1}; end end %Add instruments to xtrdr object Instruments property nLengthNotifiers = length(x.InstrNotify); if nLengthNotifiers x.InstrNotify(nLengthNotifiers + 1) = ttInstrNotify; else x.InstrNotify = ttInstrNotify; end