www.gusucode.com > trading工具箱matlab源码程序 > trading/tradingdemos/CQGHistoricalDataRequestWorkflow.m
%% CQG Historical Data Request Workflow %Create connection and API handles c = cqg; %Set event handlers eventNames = {'CELStarted','DataError','IsReady','DataConnectionStatusChanged'}; 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; %%Request 10 days worth of data for EP % Data is written to the variable cqgHistoryData in the base workspace % Historical request event handlers histEventNames = {'ExpressionResolved','ExpressionAdded','ExpressionUpdated'}; for i = 1:length(histEventNames) c.Handle.registerevent({histEventNames{i},@(varargin)cqgexpressioneventhandler(varargin{:})}); end % Historical request properties r.UpdatesEnabled = false; % Do not update with subsequent events % Make historical request % The variable cqgHistoryData is written to the MATLAB workspace by example event handler c.history({'Close(F.US.CLE)','Open(F.US.CLE)'},floor(now)-10,floor(now),'hpDaily',r) pause(1) % Close the CQG session c.shutDown;