Ejemplo n.º 1
0
        private static IStrategyAssemblyMgr GetStrategyMgr()
        {
            string path = GetStrategyPath();
            IStrategyAssemblyMgr strategyMgr = StrategyMgrFactory.CreatePluginMgr(path);

            return(strategyMgr);
        }
Ejemplo n.º 2
0
        public void TestStrategyAssembly()
        {
            IStrategyAssemblyMgr strategyMgr = GetStrategyMgr();
            IStrategyAssembly    assembly1   = strategyMgr.GetStrategyAssembly(assemblyName1);

            //string path1 = "com.wer.sc.plugin.mock.strategy";
            //string path2 = "com.wer.sc.plugin.mock.zb";
            //string path3 = "com.wer.sc.plugin.mock.strategy.complex";

            IList <IStrategyInfo> strategyInfos = null;//assembly1.GetSubStrategies("");

            //Assert.AreEqual(2, strategyInfos.Count);
            AssertMockStrategy_TurningPoint(assembly1.GetStrategyInfo(STRATEGY_TURNINGPOINT));
            AssertMockStrategy_Volume(assembly1.GetStrategyInfo(STRATEGY_VOLUME));
            AssertMockStrategy_Ma(assembly1.GetStrategyInfo(STRATEGY_MA));

            //strategyInfos = assembly1.GetSubStrategies(path2);
            //Assert.AreEqual(1, strategyInfos.Count);
            //AssertMockStrategy_Ma(strategyInfos[0]);

            //IList<string> subPath2 = assembly1.GetSubPath(path1);
            //Assert.AreEqual(1, subPath2.Count);
            //Assert.AreEqual(path3, subPath2[0]);
            //Assert.AreEqual(null, assembly1.GetSubPath(path2));

            //strategyInfos = assembly1.GetSubStrategies(path3);
            //AssertMockStrategy_Complex(strategyInfos[0]);

            //IStrategyAssembly assembly2 = strategyMgr.GetStrategyAssembly(assemblyName2);
            //Assert.AreEqual(3, assembly2.GetAllStrategies().Count);
        }
Ejemplo n.º 3
0
        public StrategyCenter(DataCenter dataCenter)
        {
            this.dataCenter = dataCenter;
            this.strategyExecutorFactory = new StrategyExecutorFactory(this);
            this.strategyAssemblyMgr     = StrategyMgrFactory.DefaultPluginMgr;
            this.strategyExecutorPool    = new StrategyExecutorPool();
            Uri uri = new Uri(dataCenter.DataCenterInfo.Uri);

            this.strategyResultStore = new StrategyResultStore_File(new StrategyDataPathUtils(uri.LocalPath));
        }
Ejemplo n.º 4
0
        public void TestCreateStrategyObject()
        {
            IStrategyAssemblyMgr strategyMgr = GetStrategyMgr();
            IStrategyAssembly    assembly1   = strategyMgr.GetStrategyAssembly(assemblyName1);
            IStrategy            strategy_ma = assembly1.CreateStrategyObject(STRATEGY_MA);

            AssertMockStrategy_Ma_Object1(strategy_ma);

            IStrategyAssembly assembly2    = strategyMgr.GetStrategyAssembly(assemblyName2);
            IStrategy         strategy_ma2 = assembly2.CreateStrategyObject(STRATEGY_MA);

            AssertMockStrategy_Ma_Object2(strategy_ma2);
        }
Ejemplo n.º 5
0
        public void TestStrategyScan()
        {
            IStrategyAssemblyMgr      strategyMgr = GetStrategyMgr();
            IList <IStrategyAssembly> assemblies  = strategyMgr.GetAllStrategyAssemblies();

            Assert.AreEqual(2, assemblies.Count);

            string            assemblyName = "com.wer.sc.plugin.mock.strategy.20170115";
            IStrategyAssembly assembly1    = strategyMgr.GetStrategyAssembly(assemblyName);

            Assert.AreEqual(GetStrategyPath() + assemblyName + ".dll", assembly1.FullPath);
            Assert.AreEqual(assemblyName, assembly1.AssemblyName);
            Assert.AreEqual(4, assembly1.GetAllStrategies().Count);
        }
Ejemplo n.º 6
0
        public void TestStrategyAssembly()
        {
            IStrategyAssemblyMgr strategyMgr = GetStrategyMgr();
            IStrategyAssembly    assembly1   = strategyMgr.GetStrategyAssembly(assemblyName1);

            string path1 = "com.wer.sc.plugin.mock.strategy";
            string path2 = "com.wer.sc.plugin.mock.zb";
            string path3 = "com.wer.sc.plugin.mock.strategy.complex";

            IList <String> rootPaths = assembly1.GetRootPath();

            Assert.AreEqual(1, rootPaths.Count);
            Assert.AreEqual("com.wer.sc.plugin.mock", rootPaths[0]);
            IList <String> firstSubPaths = assembly1.GetSubPath(rootPaths[0]);

            Assert.AreEqual(2, firstSubPaths.Count);
            //TODO
            Assert.AreEqual(path1, firstSubPaths[1]);
            Assert.AreEqual(path2, firstSubPaths[0]);

            IList <StrategyInfo> strategyInfos = assembly1.GetSubStrategies(path1);

            Assert.AreEqual(2, strategyInfos.Count);
            AssertMockStrategy_TurningPoint(strategyInfos[0]);
            AssertMockStrategy_Volume(strategyInfos[1]);

            strategyInfos = assembly1.GetSubStrategies(path2);
            Assert.AreEqual(1, strategyInfos.Count);
            AssertMockStrategy_Ma(strategyInfos[0]);

            IList <string> subPath2 = assembly1.GetSubPath(path1);

            Assert.AreEqual(1, subPath2.Count);
            Assert.AreEqual(path3, subPath2[0]);
            Assert.AreEqual(null, assembly1.GetSubPath(path2));

            strategyInfos = assembly1.GetSubStrategies(path3);
            AssertMockStrategy_Complex(strategyInfos[0]);

            IStrategyAssembly assembly2 = strategyMgr.GetStrategyAssembly(assemblyName2);

            Assert.AreEqual(3, assembly2.GetAllStrategies().Count);
        }
Ejemplo n.º 7
0
        private void btRefresh_Click(object sender, EventArgs e)
        {
            IStrategyAssemblyMgr mgr = StrategyCenter.Default.GetStrategyMgr();

            if (this.strategyData == null)
            {
                mgr.Refresh();
                return;
            }
            string assemblyId = this.strategyData.StrategyInfo.StrategyAssembly.AssemblyName;
            string className  = this.strategyData.StrategyInfo.ClassName;

            mgr.Refresh();

            IStrategyInfo strategyInfo = mgr.GetStrategyAssembly(assemblyId).GetStrategyInfo(className);
            IStrategyData strategyData = strategyInfo.CreateStrategyData();

            this.chartComponent.StrategyData = strategyData;
            this.Init(strategyData);
            MessageBox.Show("策略刷新成功");
        }