Exemple #1
0
        public void TestStrategyResult_CodePeriod_MainContract()
        {
            string      code       = "RB";
            int         startDate  = 20170101;
            int         endDate    = 20180101;
            ICodePeriod codePeriod = DataCenter.Default.CodePeriodFactory.CreateCodePeriod_MainContract(code, startDate, endDate);

            StrategyReferedPeriods referedPeriods = new StrategyReferedPeriods();

            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_15Minute);
            referedPeriods.UseTickData = true;
            StrategyForwardPeriod forwardPeriod = new StrategyForwardPeriod(true, KLinePeriod.KLinePeriod_15Minute);

            StrategyArguments_CodePeriod arguments = new StrategyArguments_CodePeriod(codePeriod, referedPeriods, forwardPeriod);

            arguments.IsSaveResult = true;
            IStrategyExecutor_Single executor = StrategyCenter.Default.GetStrategyExecutorFactory().CreateExecutor_History(arguments);

            //IStrategy strategy = StrategyGetter.GetStrategy(typeof(MockStrategy_Simple));
            MockStrategy_Results strategy = new MockStrategy_Results();

            strategy.Name     = "策略结果保存";
            executor.Strategy = strategy;
            executor.Run();
        }
Exemple #2
0
        public void TestStrategyExecutorEvent_CodePeriod1()
        {
            string      code       = "RB";
            int         startDate  = 20170101;
            int         endDate    = 20180101;
            ICodePeriod codePeriod = DataCenter.Default.CodePeriodFactory.CreateCodePeriod_MainContract(code, startDate, endDate);

            StrategyReferedPeriods referedPeriods = new StrategyReferedPeriods();

            referedPeriods.UseTickData = false;
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Minute);
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_5Minute);
            StrategyForwardPeriod forwardPeriod = new StrategyForwardPeriod(false, KLinePeriod.KLinePeriod_1Minute);

            //StrategyArguments_DataPackage strategyCodePeriod = new StrategyArguments_DataPackage(dataPackage, referedPeriods, forwardPeriod);
            StrategyArguments_CodePeriod strategyCodePeriod = new StrategyArguments_CodePeriod(codePeriod, referedPeriods, forwardPeriod);
            IStrategyExecutor_Single     executor           = StrategyCenter.Default.GetStrategyExecutorFactory().CreateExecutor_History(strategyCodePeriod);

            executor.OnBarFinished += Executor_OnBarFinished;
            executor.OnDayFinished += Executor_OnDayFinished;
            executor.OnFinished    += Executor_OnFinished;

            IStrategy strategy = StrategyGetter.GetStrategy(typeof(MockStrategy_Empty));

            executor.Strategy = strategy;
            executor.Run();
        }
Exemple #3
0
        public void TestRunStrategy_Minute()
        {
            string            code        = "RB1710";
            int               startDate   = 20170301;
            int               endDate     = 20170603;
            IDataPackage_Code dataPackage = CommonData.GetDataPackage(code, startDate, endDate);

            StrategyReferedPeriods referedPeriods = new StrategyReferedPeriods();

            referedPeriods.UseTickData = false;
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Minute);
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_5Minute);
            StrategyForwardPeriod forwardPeriod = new StrategyForwardPeriod(false, KLinePeriod.KLinePeriod_1Minute);

            StrategyArguments_DataPackage strategyDataPackage = new StrategyArguments_DataPackage(dataPackage, referedPeriods, forwardPeriod);
            //strategyDataPackage.IsSaveResult = true;
            IStrategyExecutor_Single executor = StrategyCenter.Default.GetStrategyExecutorFactory().CreateExecutor_History(strategyDataPackage);

            IStrategy strategy = StrategyGetter.GetStrategy(typeof(MockStrategy_Simple));

            executor.Strategy = strategy;
            executor.Run();

            Console.WriteLine(executor.StrategyResult);
        }
Exemple #4
0
        public void TestRunStrategy_Tick()
        {
            //data.reader.IDataReader dataReader = CommonData.GetDataReader();

            string code    = "RB1710";
            int    start   = 20170601;
            int    endDate = 20170603;

            IDataPackage_Code dataPackage = CommonData.GetDataPackage(code, start, endDate);

            StrategyReferedPeriods referedPeriods = new StrategyReferedPeriods();

            referedPeriods.UseTickData = true;
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Minute);
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_5Minute);

            StrategyForwardPeriod         forwardPeriod = new StrategyForwardPeriod(true, KLinePeriod.KLinePeriod_1Minute);
            StrategyArguments_DataPackage arguments     = new StrategyArguments_DataPackage(dataPackage, referedPeriods, forwardPeriod);
            IStrategyExecutor_Single      runner        = StrategyCenter.Default.GetStrategyExecutorFactory().CreateExecutor_History(arguments);

            DateTime prevtime = DateTime.Now;

            runner.Strategy = new MockStrategy(referedPeriods);
            runner.Run();

            DateTime time = DateTime.Now;
            TimeSpan span = time.Subtract(prevtime);

            Console.WriteLine(span.Minutes * 60 * 1000 + span.Seconds * 1000 + span.Milliseconds);
        }
Exemple #5
0
 private void AddExecutingExecutor(IStrategyExecutor_Single executor)
 {
     lock (lockExecutingObj)
     {
         this.executingExecutors.Add(executor);
     }
 }
Exemple #6
0
 private void RemoveExecutingExecutor(IStrategyExecutor_Single executor)
 {
     lock (lockExecutingObj)
     {
         this.executingExecutors.Remove(executor);
     }
 }
Exemple #7
0
        public void TestTrade()
        {
            string code      = "RB1710";
            int    startDate = 20170601;
            int    endDate   = 20170603;

            StrategyReferedPeriods referedPeriods = new StrategyReferedPeriods();

            referedPeriods.UseTickData = false;
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Minute);
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_5Minute);
            StrategyForwardPeriod forwardPeriod = new StrategyForwardPeriod(false, KLinePeriod.KLinePeriod_1Minute);

            StrategyArguments_CodePeriod strategyCodePeriod = new StrategyArguments_CodePeriod(code, startDate, endDate, referedPeriods, forwardPeriod);
            IStrategyExecutor_Single     executor           = StrategyCenter.Default.GetStrategyExecutorFactory().CreateExecutor_History(strategyCodePeriod);

            StrategyAbstract strategy = (StrategyAbstract)StrategyGetter.GetStrategy(typeof(MockStrategy_Trade));

            executor.Strategy = strategy;
            executor.Run();

            StrategyTrader_History trader     = ((StrategyTrader_History)strategy.StrategyHelper.Trader);
            IList <TradeInfo>      tradeInfos = trader.Account.CurrentTradeInfo;

            AssertUtils.PrintLineList((IList)tradeInfos);
            AssertUtils.AssertEqual_List("StrategyTrade", GetType(), tradeInfos);
            Assert.AreEqual(96250, trader.Account.Asset);
            //Assert.AreEqual(98870, trader.Account.Asset);
            //IList<OrderInfo> orderInfos = strategy.StrategyOperator.Trader.CurrentOrderInfo;
            //for (int i = 0; i < tradeInfos.Count; i++)
            //{
            //    Console.WriteLine(tradeInfos[i]);
            //}
            //Console.WriteLine(strategy.StrategyOperator.Trader.OwnerTrader.Account.Asset);
        }
Exemple #8
0
        public void TestExecuteStrategy()
        {
            string            code        = "RB1710";
            int               start       = 20170601;
            int               endDate     = 20170603;
            IDataPackage_Code dataPackage = CommonData.GetDataPackage(code, start, endDate);

            StrategyReferedPeriods referedPeriods = new StrategyReferedPeriods();

            referedPeriods.UseTickData = false;
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Minute);
            StrategyForwardPeriod forwardPeriod = new StrategyForwardPeriod(false, KLinePeriod.KLinePeriod_1Minute);

            StrategyArguments_DataPackage arguments = new StrategyArguments_DataPackage(dataPackage, referedPeriods, forwardPeriod);
            IStrategyExecutor_Single      runner    = StrategyCenter.Default.GetStrategyExecutorFactory().CreateExecutor_History(arguments);

            DateTime prevtime = DateTime.Now;

            runner.Strategy    = new MockStrategy(null);
            runner.OnFinished += Runner_OnFinished;
            runner.Execute();
            while (!isFinished)
            {
            }
            DateTime time = DateTime.Now;
            TimeSpan span = time.Subtract(prevtime);

            Console.WriteLine(span.Minutes * 60 + span.Seconds);
        }
Exemple #9
0
        public static IStrategyExecutor_Single CreateExecutor_CodePeriod(string code, int start, int end)
        {
            IStrategyExecutorFactory executorFactory = StrategyCenter.Default.GetStrategyExecutorFactory();
            StrategyReferedPeriods   referedPeriods  = GetReferedPeriods();
            StrategyForwardPeriod    forwardPeriod   = new StrategyForwardPeriod(true, KLinePeriod.KLinePeriod_1Minute);

            StrategyArguments_CodePeriod strategyCodePeriod = new StrategyArguments_CodePeriod(code, start, end, referedPeriods, forwardPeriod);
            IStrategyExecutor_Single     executor           = executorFactory.CreateExecutor_History(strategyCodePeriod);

            return(executor);
        }
Exemple #10
0
        public void TestExecuteStrategy()
        {
            string code  = "rb1710";
            int    start = 20170601;
            int    end   = 20170603;
            IStrategyExecutor_Single executor = StrategyTestUtils.CreateExecutor_CodePeriod(code, start, end);
            MockStrategy             strategy = new MockStrategy();

            executor.Strategy    = strategy;
            executor.OnFinished += Executor_OnFinished;
            executor.Execute();
            //AssertUtils.AssertEqual_List("executorhistory", GetType(), strategy.PrintData);
        }
Exemple #11
0
        public void Execute()
        {
            if (isRunning)
            {
                throw new ApplicationException("正在执行策略,不能加入新策略");
            }

            lock (lockExecutingObj)
            {
                if (isRunning)
                {
                    throw new ApplicationException("正在执行策略,不能加入新策略");
                }

                isRunning = true;
                try
                {
                    ThreadPool.SetMaxThreads(threadCount, threadCount);
                    while (waitingQueue.Count > 0)
                    {
                        if (executingExecutors.Count >= maxExecutorCount)
                        {
                            continue;
                        }
                        lock (lockExecutingListObj)
                        {
                            IStrategyExecutor_Single executor = waitingQueue.Dequeue();
                            executor.OnStart       += Executor_OnStart;
                            executor.OnDayFinished += Executor_OnDayFinished;
                            executor.OnFinished    += Executor_OnFinished;

                            ThreadPool.QueueUserWorkItem(new StrategyExecutorRuner(executor).Run, null);
                            ExecutingExecutors.Add(executor);
                        }
                    }
                    while (executingExecutors.Count > 0)
                    {
                    }
                    if (OnPoolFinished != null)
                    {
                        OnPoolFinished(this);
                    }
                }
                finally
                {
                    isRunning = false;
                }
            }
        }
Exemple #12
0
        public void TestExecuteStrategyExecutorPool()
        {
            try
            {
                StrategyExecutorPool pool = (StrategyExecutorPool)StrategyCenter.Default.GetStrategyExecutorPool();
                pool.ThreadCount      = 5;
                pool.MaxExecutorCount = 10;

                pool.OnStrategyStart       += Pool_OnStart;
                pool.OnStrategyDayFinished += Pool_OnDayFinished;
                pool.OnStrategyFinished    += Pool_OnFinished;

                List <string> codes = new List <string>();
                codes.Add("rb");
                codes.Add("m");
                codes.Add("ma");
                codes.Add("i");
                codes.Add("j");
                codes.Add("jd");
                codes.Add("jm");
                codes.Add("p");
                codes.Add("pp");
                StrategyArguments_CodePeriodList strategyCodePeriodPackage = GetStrategyPackage(codes, 20170101, 20170601);

                IList <IStrategyExecutor_Single> executors = StrategyCenter.Default.GetStrategyExecutorFactory().CreateExecutors_History(strategyCodePeriodPackage);
                for (int i = 0; i < executors.Count; i++)
                {
                    IStrategyExecutor_Single executor = executors[i];
                    executor.Strategy = new MockStrategy_Empty();
                    pool.Queue(executor);
                }

                //pool.Run();
                long startTick = DateTime.Now.Ticks;
                pool.OnPoolFinished += Pool_OnPoolFinished;
                pool.Execute();
                //Thread.Sleep(20000);

                while (!isFinished)
                {
                }
                long endTick = DateTime.Now.Ticks;
                Console.WriteLine(endTick - startTick);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }
        }
Exemple #13
0
 private void Executor_OnFinished(object sender, StrategyFinishedArguments arguments)
 {
     if (OnStrategyFinished != null)
     {
         OnStrategyFinished(sender, arguments);
     }
     if (sender != null && sender is IStrategyExecutor_Single)
     {
         IStrategyExecutor_Single executor = ((IStrategyExecutor_Single)sender);
         executor.OnStart       -= Executor_OnStart;
         executor.OnDayFinished -= Executor_OnDayFinished;
         executor.OnFinished    -= Executor_OnFinished;
         executingExecutors.Remove(executor);
     }
 }
Exemple #14
0
        public StrategyExecutor_Multi(IStrategyCenter strategyCenter, StrategyArguments_CodePeriodList arguments)
        {
            this.strategyCenter = strategyCenter;
            this.arguments      = arguments;

            IList <ICodePeriod> codePeriods = this.arguments.CodePeriodPackage.CodePeriods;

            for (int i = 0; i < codePeriods.Count; i++)
            {
                ICodePeriod codePeriod = codePeriods[i];
                StrategyArguments_CodePeriod strategyCodePeriod = new StrategyArguments_CodePeriod(codePeriod, arguments.ReferedPeriods, arguments.ForwardPeriod);
                IStrategyExecutor_Single     executor           = strategyCenter.GetStrategyExecutorFactory().CreateExecutor_History(strategyCodePeriod);
                this.executors.Add(executor);
            }
        }
Exemple #15
0
        public void TestStrategyResult_DataPackage()
        {
            //ICodePeriodFactory factory = DataCenter.Default.CodePeriodFactory;
            //ICodePeriod codePeriod = factory.CreateCodePeriod("rb1801", 20170501, 20170801);

            StrategyReferedPeriods referedPeriods = new StrategyReferedPeriods();

            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_15Minute);
            referedPeriods.UseTickData = true;
            StrategyForwardPeriod forwardPeriod = new StrategyForwardPeriod(true, KLinePeriod.KLinePeriod_15Minute);
            //StrategyArguments_CodePeriod strategyCodePeriod = new StrategyArguments_CodePeriod(codePeriod, referedPeriods, forwardPeriod);
            IDataPackage_Code             dataPackage       = DataCenter.Default.DataPackageFactory.CreateDataPackage_Code("rb1801", 20170501, 20170801);
            StrategyArguments_DataPackage strategyArguments = new StrategyArguments_DataPackage(dataPackage, referedPeriods, forwardPeriod);

            //自动保存结果
            strategyArguments.IsSaveResult = true;
            IStrategyExecutor_Single executor = StrategyCenter.Default.GetStrategyExecutorFactory().CreateExecutor_History(strategyArguments);
            MockStrategy_Results     strategy = new MockStrategy_Results();

            strategy.Name     = "策略结果保存";
            executor.Strategy = strategy;
            executor.Run();

            //IStrategyTrader trader = executor.StrategyHelper.Trader;

            int             day        = int.Parse(DateTime.Now.ToString("yyyyMMdd"));
            IStrategyResult result     = executor.StrategyResult;
            string          resultName = executor.StrategyResult.Name;

            IStrategyResultStore store     = StrategyCenter.Default.StrategyResultStore;
            IList <int>          savedDays = store.GetAllSavedDays();

            for (int i = 0; i < savedDays.Count; i++)
            {
                Console.Write(savedDays[i] + ",");
            }
            Console.WriteLine();

            IStrategyResult result2 = store.LoadStrategyResult(day, resultName);

            Console.WriteLine(result2);
            Assert.AreEqual(result.ToString(), result2.ToString());

            Assert.AreEqual(1, result2.StrategyResult_Codes.Count);
            Assert.AreEqual(1, result2.StrategyQueryResultManager.GetQueryResults().Count);
            Console.WriteLine(result2.StrategyResult_Codes[0]);
            Assert.AreEqual(result.StrategyResult_Codes[0].ToString(), result2.StrategyResult_Codes[0].ToString());
        }
Exemple #16
0
        /// <summary>
        /// 运行
        /// </summary>
        public void Execute()
        {
            IStrategyExecutorPool pool = this.strategyCenter.GetStrategyExecutorPool();

            for (int i = 0; i < executors.Count; i++)
            {
                IStrategyExecutor_Single executor = executors[i];
                executor.OnStart       += Executor_OnStart;
                executor.OnBarFinished += Executor_OnBarFinished;
                executor.OnDayFinished += Executor_OnDayFinished;
                executor.OnCanceled    += Executor_OnCanceled;
                executor.OnFinished    += Executor_OnFinished;
                executor.Strategy       = strategy;
                pool.Queue(executor);
            }
        }
Exemple #17
0
        public void TestParamter()
        {
            IStrategy strategy = new MockStrategy_Parameter();

            strategy.Parameters.SetParameterValue("PERIOD", KLinePeriod.KLinePeriod_15Minute);

            string code  = "rb1710";
            int    start = 20170601;
            int    end   = 20170603;
            IStrategyExecutor_Single executor = StrategyTestUtils.CreateExecutor_CodePeriod(code, start, end);

            executor.Strategy = strategy;
            executor.Run();

            //List<string> results = (List<string>)strategy.GetData("RESULT");
            //AssertUtils.AssertEqual_List("StrategyParameter_15Minute", GetType(), results);
        }
Exemple #18
0
        /// <summary>
        /// 运行策略,并且将策略运行结果绑定到该
        /// </summary>
        public void Run()
        {
            if (this.strategyData == null || this.strategyData.Strategy == null)
            {
                return;
            }
            IStrategy strategy = this.strategyData.Strategy;
            StrategyReferedPeriods referedPeriods = strategy.GetReferedPeriods();

            if (referedPeriods == null)
            {
                referedPeriods = new StrategyReferedPeriods();
                KLinePeriod currentPeriod = this.compChart.Controller.ChartComponentData.KlinePeriod;
                referedPeriods.UsedKLinePeriods.Add(currentPeriod);
                if (strategy is StrategyAbstract)
                {
                    ((StrategyAbstract)strategy).MainKLinePeriod = currentPeriod;
                }
            }
            KLinePeriod           mainPeriod    = referedPeriods.MainPeriod;
            StrategyForwardPeriod forwardPeriod = new StrategyForwardPeriod(referedPeriods.UseTickData, mainPeriod);

            IStrategyExecutorFactory executorFactory = StrategyCenter.Default.GetStrategyExecutorFactory();
            IDataPackage_Code        dataPackage     = this.compChart.Controller.CurrentNavigater.DataPackage;

            Dictionary <KLinePeriod, int> dic_KLinePeriod_StartPos = new Dictionary <KLinePeriod, int>();

            for (int i = 0; i < referedPeriods.UsedKLinePeriods.Count; i++)
            {
                KLinePeriod period = referedPeriods.UsedKLinePeriods[i];
                dic_KLinePeriod_StartPos.Add(period, dataPackage.GetKLineData(period).BarPos);
            }

            drawOperator = new ChartComponentStrategyDrawer(this.compChart.Drawer, dic_KLinePeriod_StartPos, 0, 0);
            StrategyArguments_DataPackage strategyDataPackage = new StrategyArguments_DataPackage(dataPackage, referedPeriods, forwardPeriod);;
            StrategyHelper strategyOperator = new StrategyHelper();

            strategyOperator.Drawer = drawOperator;
            strategyExecutor        = executorFactory.CreateExecutor_History(strategyDataPackage);

            strategyExecutor.Strategy = strategy;
            //strategyExecutor.Run();
            //strategyExecutor.ExecuteFinished += StrategyExecutor_ExecuteFinished;
            strategyExecutor.Execute();
        }
        private void InitByCodePeriod(IStrategyCenter strategyCenter, StrategyArguments_CodePeriod strategyArguments)
        {
            ICodePeriod codePeriod = strategyArguments.CodePeriod;

            if (codePeriod.IsFromContracts)
            {
                this.strategyExecutor = new StrategyExecutor_CodePeriod_MainContract(strategyCenter, strategyArguments);
            }
            else
            {
                IDataPackage_Code             dataPackage         = strategyCenter.BelongDataCenter.DataPackageFactory.CreateDataPackage_Code(codePeriod.Code, codePeriod.StartDate, codePeriod.EndDate);
                StrategyArguments_DataPackage strategyDataPackage = new StrategyArguments_DataPackage(dataPackage, strategyArguments.ReferedPeriods, strategyArguments.ForwardPeriod);
                this.strategyExecutor = strategyCenter.GetStrategyExecutorFactory().CreateExecutor_History(strategyDataPackage);
            }

            this.strategyExecutor.OnStart       += StrategyExecutor_OnStart;;
            this.strategyExecutor.OnBarFinished += StrategyExecutor_OnBarFinished;
            this.strategyExecutor.OnDayFinished += StrategyExecutor_OnDayFinished;
            this.strategyExecutor.OnCanceled    += StrategyExecutor_OnCanceled;
            this.strategyExecutor.OnFinished    += StrategyExecutor_OnFinished;
        }
        public void TestReferOtherStrategy()
        {
            string code      = "RB1710";
            int    startDate = 20170601;
            int    endDate   = 20170603;

            StrategyReferedPeriods referedPeriods = new StrategyReferedPeriods();

            referedPeriods.UseTickData = false;
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Minute);
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_5Minute);
            StrategyForwardPeriod forwardPeriod = new StrategyForwardPeriod(false, KLinePeriod.KLinePeriod_1Minute);

            StrategyArguments_CodePeriod strategyCodePeriod = new StrategyArguments_CodePeriod(code, startDate, endDate, referedPeriods, forwardPeriod);
            IStrategyExecutor_Single     executor           = StrategyCenter.Default.GetStrategyExecutorFactory().CreateExecutor_History(strategyCodePeriod);

            IStrategy strategy = StrategyGetter.GetStrategy(typeof(MockStrategy_ReferOtherStrategy));

            executor.Strategy = strategy;
            executor.Run();
        }
Exemple #21
0
        public void TestExecuteStrategy_MA()
        {
            string code  = "rb1710";
            int    start = 20170601;
            int    end   = 20170603;
            IStrategyExecutor_Single executor = StrategyTestUtils.CreateExecutor_CodePeriod(code, start, end);
            MockStrategy_Ma          strategy = new MockStrategy_Ma();

            executor.Strategy = strategy;
            executor.Run();

            List <float>      floats      = strategy.MAList;
            IDataPackage_Code dataPackage = DataCenter.Default.DataPackageFactory.CreateDataPackage_Code(code, start, end);
            IKLineData_Extend klineData   = dataPackage.GetKLineData(KLinePeriod.KLinePeriod_1Minute);
            List <float>      floats2     = KLineDataUtils.MaList(klineData, klineData.BarPos, klineData.Length - 1, 5);

            for (int i = 0; i < floats.Count; i++)
            {
                Console.WriteLine(floats[i] + "," + floats2[i]);
            }
            AssertUtils.AssertEqual_List(floats2, floats);
        }
        private void ExecuteStrategy_Event(string code, int startDate, int endDate)
        {
            IDataPackage_Code dataPackage = CommonData.GetDataPackage(code, startDate, endDate);

            StrategyReferedPeriods referedPeriods = new StrategyReferedPeriods();

            referedPeriods.UseTickData = false;
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Minute);
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_5Minute);
            StrategyForwardPeriod forwardPeriod = new StrategyForwardPeriod(false, KLinePeriod.KLinePeriod_1Minute);

            StrategyArguments_DataPackage strategyCodePeriod = new StrategyArguments_DataPackage(dataPackage, referedPeriods, forwardPeriod);
            IStrategyExecutor_Single      executor           = StrategyCenter.Default.GetStrategyExecutorFactory().CreateExecutor_History(strategyCodePeriod);

            executor.OnBarFinished += Executor_OnBarFinished;
            executor.OnDayFinished += Executor_OnDayFinished;
            executor.OnFinished    += Executor_OnFinished;

            IStrategy strategy = StrategyGetter.GetStrategy(typeof(MockStrategy_Empty));

            executor.Strategy = strategy;
            executor.Run();
        }
Exemple #23
0
 public void Queue(IStrategyExecutor_Single strategyExecutor)
 {
     this.waitingQueue.Enqueue(strategyExecutor);
 }
Exemple #24
0
 public StrategyExecutorRuner(IStrategyExecutor_Single executor)
 {
     this.executor = executor;
 }