www.gusucode.com > trading工具箱matlab源码程序 > trading/tradingdemos/CQGRealtimeRequestWorkflow.m
%% CQG Realtime Data Request Workflow %Create connection and API handles c = cqg; %Set event handlers eventNames = {'CELStarted','DataError','IsReady','DataConnectionStatusChanged','GWConnectionStatusChanged','GWEnvironmentChanged'}; for i = 1:length(eventNames) c.Handle.registerevent({eventNames{i},@(varargin)cqgconnectioneventhandler(varargin{:})}); end %Set API configuration properties c.APIConfig.TimeZoneCode = 'tzEastern'; %Start the CQG session c.startUp; % Default event handlers streamEventNames = {'InstrumentSubscribed','InstrumentChanged','IncorrectSymbol'}; for i = 1:length(streamEventNames) c.Handle.registerevent({streamEventNames{i},@(varargin)cqgrealtimeeventhandler(varargin{:})}); end % Subscribe to a security % The variable cqgDataEZC is written to the base workspace by the example % event handler cqgRealTimeEventHandler c.realtime('F.US.CLE')