public StrategyExecutor_CodePeriod_MainContract(IStrategyCenter strategyCenter, StrategyArguments_CodePeriod strategyArguments) : base(strategyCenter, strategyArguments)
        {
            this.strategyArguments = strategyArguments;
            this.PrepareStrategyHelper();

            IList <ICodePeriod> codePeriods = this.strategyArguments.CodePeriod.Contracts;

            this.dataPackages = new List <IDataPackage_Code>();
            for (int i = 0; i < codePeriods.Count; i++)
            {
                ICodePeriod codePeriod = codePeriods[i];
                this.dataPackages.Add(strategyCenter.BelongDataCenter.DataPackageFactory.CreateDataPackage_Code(codePeriod.Code, codePeriod.StartDate, codePeriod.EndDate));
            }
            this.BuildExecutorInfo();
            for (int i = 0; i < dataPackages.Count; i++)
            {
                IDataPackage_Code dataPackage            = dataPackages[i];
                StrategyHelper    executorStrategyHelper = new StrategyHelper();
                executorStrategyHelper.QueryResultManager = this.strategyHelper.QueryResultManager;
                executorStrategyHelper.Drawer             = null;//TODO
                executorStrategyHelper.Trader             = this.strategyHelper.Trader;

                StrategyArguments_DataPackage strategyArgument = new StrategyArguments_DataPackage(dataPackage, strategyArguments.ReferedPeriods, strategyArguments.ForwardPeriod, executorStrategyHelper);
                StrategyExecutor_DataPackage  executor         = new StrategyExecutor_DataPackage(strategyCenter, strategyArgument, this.strategyExecutorInfo);
                executor.OnBarFinished += Executor_OnBarFinished;
                executor.OnDayFinished += Executor_OnDayFinished;
                this.executors.Add(executor);
            }
        }
        private bool RunExecutor_DataPackage(StrategyExecutor_DataPackage executor)
        {
            currentExecutor = executor;
            executor.Run();
            if (isCancel)
            {
                DealCancelEvent(new StrategyCanceledArguments(StrategyExecutorInfo));
                return(false);
            }

            if (this.strategyArguments.CloseOnCodeChanged)
            {
                StrategyHelper.Trader.CloseAll();
            }
            return(true);
        }
        public override void Run()
        {
            if (executors.Count == 0)
            {
                return;
            }
            if (this.state != StrategyExecutorState.NotStart)
            {
                return;
            }
            lock (lockRunObject)
            {
                if (this.state != StrategyExecutorState.NotStart)
                {
                    return;
                }

                this.BuildStrategyResult();

                StrategyExecutor_DataPackage firstExecutor = executors[0];
                DealStartEvent(new StrategyStartArguments(firstExecutor.StrategyExecutorInfo));

                for (int i = 0; i < executors.Count; i++)
                {
                    StrategyExecutor_DataPackage executor = executors[i];
                    bool continueRun = RunExecutor_DataPackage(executor);
                    if (!continueRun)
                    {
                        return;
                    }
                }

                if (IsSaveResult)
                {
                    this.PrepareStrategyResult();
                    this.SaveStrategyResult();
                }
                StrategyExecutor_DataPackage lastExecutor = executors[executors.Count - 1];
                DealFinishedEvent(new StrategyFinishedArguments(Strategy, lastExecutor.StrategyExecutorInfo, StrategyResult));
            }
        }