Пример #1
0
        public void TestRegisterDataCenter()
        {
            string path = TestCaseManager.GetTestCasePath(GetType(), "output_RegisterDataCenter.config");

            try
            {
                DataCenterManager mgr = DataCenterManager.Create(path);

                string         uri    = "file:/e:/futures/mockdatacenter/";
                string         id     = "d1";
                DataCenterInfo config = GetDataCenterInfo(uri, id);
                mgr.RegisterDataCenter(config);
                Assert.AreEqual(1, mgr.GetAllConfig().Count);
                DataCenter dataCenter = mgr.GetDataCenterByUri(uri);
                Assert.AreEqual(uri, dataCenter.Config.Uri);

                string uri2 = "file:/d:/scdata/cnfutures/";
                string id2  = "d2";
                config = GetDataCenterInfo(uri2, id2);
                mgr.RegisterDataCenter(config);
                Assert.AreEqual(2, mgr.GetAllConfig().Count);

                mgr.UnRegisterDataCenter(uri);
                dataCenter = mgr.GetDataCenterByUri(uri);
                Assert.IsNull(dataCenter);
                Assert.AreEqual(1, mgr.GetAllConfig().Count);
            }
            finally
            {
                File.Delete(path);
            }
        }
Пример #2
0
        public void TestConfigLoad()
        {
            string           fileName = "strategy.common.strategyconfig";
            string           filePath = TestCaseManager.GetTestCasePath(typeof(TestStrategyAssemblyConfig), fileName);
            StrategyAssembly config   = new StrategyAssembly();

            config.Load(filePath);
            Assert.AreEqual("com.wer.sc.strategy.common", config.AssemblyName);
            Assert.AreEqual("基础策略测试", config.Description);
            Assert.AreEqual("基础策略", config.Name);

            IList <IStrategyInfo> strategies = config.GetSubStrategyInfo("");

            Assert.AreEqual(1, strategies.Count);
            Assert.AreEqual("mock测试", strategies[0].Name);
            Assert.AreEqual("com.wer.sc.strategy.common.test.Strategy_Mock", strategies[0].ClassName);

            IList <string> paths = config.GetSubPath("");

            Assert.AreEqual(4, paths.Count);
            Assert.AreEqual("\\均线", paths[0]);
            Assert.AreEqual("\\转折点查找", paths[1]);
            Assert.AreEqual("\\量能分析", paths[2]);
            Assert.AreEqual("\\平台分析", paths[3]);

            Assert.AreEqual("\\平台分析\\子平台分析", config.GetSubPath("\\平台分析")[0]);

            IList <IStrategyInfo> subStrategies = config.GetSubStrategyInfo("\\均线");

            Assert.AreEqual(1, subStrategies.Count);
            Assert.AreEqual("均线策略", subStrategies[0].Name);
        }
Пример #3
0
        public void TestTickDataStore_Append()
        {
            TickData data = (TickData)MockDataLoader.GetTickData("m1005", 20100108);

            String   path = TestCaseManager.GetTestCasePath(GetType(), "output_");
            TickData d1   = data.SubData(0, 100);
            TickData d2   = data.SubData(101, data.Length - 1);

            TickDataStore_File_Single store = new TickDataStore_File_Single(path);

            store.Save(d1);

            TickDataStore_File_Single store2 = new TickDataStore_File_Single(path);

            store2.Append(d2);

            TickDataStore_File_Single store3 = new TickDataStore_File_Single(path);
            TickData data2 = store3.Load();

            for (int i = 0; i < data.Length; i++)
            {
                data.BarPos  = i;
                data2.BarPos = i;
                Assert.AreEqual(data.ToString(), data2.ToString());
            }
            File.Delete(path);
        }
Пример #4
0
        public void TestSaveLoadUpdatedDataInfo()
        {
            string path = TestCaseManager.GetTestCasePath(GetType(), "path_updateinfo");

            if (Directory.Exists(path))
            {
                Directory.Delete(path, true);
            }

            UpdatedDataInfo updatedDataInfo = new UpdatedDataInfo(path);

            updatedDataInfo.WriteUpdateInfo_Tick(CODE1, 20140120);
            updatedDataInfo.WriteUpdateInfo_Tick(CODE2, 20140520);
            updatedDataInfo.WriteUpdateInfo_KLine(CODE1, KLinePeriod.KLinePeriod_1Minute, 20140121);
            updatedDataInfo.WriteUpdateInfo_KLine(CODE1, KLinePeriod.KLinePeriod_5Minute, 20140122);
            updatedDataInfo.WriteUpdateInfo_KLine(CODE1, KLinePeriod.KLinePeriod_15Minute, 20140123);
            updatedDataInfo.WriteUpdateInfo_KLine(CODE1, KLinePeriod.KLinePeriod_1Day, 20140124);
            updatedDataInfo.WriteUpdateInfo_KLine(CODE2, KLinePeriod.KLinePeriod_1Minute, 20140525);
            updatedDataInfo.Save();

            UpdatedDataInfo updatedDataInfo2 = new UpdatedDataInfo(path);

            Assert.AreEqual(20140120, updatedDataInfo2.GetLastUpdatedTickData(CODE1));
            Assert.AreEqual(20140520, updatedDataInfo2.GetLastUpdatedTickData(CODE2));

            Assert.AreEqual(20140121, updatedDataInfo2.GetLastUpdatedKLineData(CODE1, KLinePeriod.KLinePeriod_1Minute));
            Assert.AreEqual(20140122, updatedDataInfo2.GetLastUpdatedKLineData(CODE1, KLinePeriod.KLinePeriod_5Minute));
            Assert.AreEqual(20140123, updatedDataInfo2.GetLastUpdatedKLineData(CODE1, KLinePeriod.KLinePeriod_15Minute));
            Assert.AreEqual(20140124, updatedDataInfo2.GetLastUpdatedKLineData(CODE1, KLinePeriod.KLinePeriod_1Day));
            Assert.AreEqual(20140525, updatedDataInfo2.GetLastUpdatedKLineData(CODE2, KLinePeriod.KLinePeriod_1Minute));

            Directory.Delete(path, true);
        }
Пример #5
0
        public void TestGetAllCodes()
        {
            List <CodeInfo>     codes = CsvUtils_Code.Load(TestCaseManager.GetTestCasePath(GetType(), "Codes"));
            CacheUtils_CodeInfo cache = new CacheUtils_CodeInfo(codes);

            List <CodeInfo> newcodes = cache.GetAllCodes();

            AssertUtils.AssertEqual_List("Codes", GetType(), newcodes);
        }
Пример #6
0
        public void TestCreateDataCenter2()
        {
            string            path       = TestCaseManager.GetTestCasePath(GetType(), "datacenter.config");
            DataCenterManager mgr        = DataCenterManager.Create(path);
            string            uri        = "file:/e:/FUTURES/MOCKDATACENTER/";
            DataCenter        dataCenter = mgr.GetDataCenterByUri(uri);

            Assert.AreEqual(uri, dataCenter.Config.Uri);
        }
Пример #7
0
        public void TestGetDataCenter()
        {
            string          filePath    = TestCaseManager.GetTestCasePath(GetType(), "datacenter.config");
            DataCenter      dataCenter  = DataCenterManager.Create(filePath).GetDataCenterByUri("file:/E:/FUTURES/MOCKDATACENTER/");
            List <CodeInfo> instruments = dataCenter.DataReader.CodeReader.GetAllCodes();

            AssertUtils.PrintLineList(instruments);
            AssertUtils.AssertEqual_List("instruments", GetType(), instruments);
        }
Пример #8
0
        public void TestGetAllCodesByVariety()
        {
            List <CodeInfo>     codes = CsvUtils_Code.Load(TestCaseManager.GetTestCasePath(GetType(), "Codes"));
            CacheUtils_CodeInfo cache = new CacheUtils_CodeInfo(codes);

            List <CodeInfo> newcodes = cache.GetCodesByCatelog("m", 20160101);

            //AssertUtils.PrintLineList(newcodes);
            AssertUtils.AssertEqual_List("Codes_M_20160101", GetType(), newcodes);
        }
Пример #9
0
        public void TestAssemblyCreate()
        {
            string fileName = "strategy.common.strategyconfig";
            string filePath = TestCaseManager.GetTestCasePath(typeof(TestStrategyAssemblyConfig), fileName);
            //StrategyAssembly config = new StrategyAssembly();
            //config.Load(filePath);

            StrategyAssembly strategyAssembly = StrategyAssembly.Create(filePath);
            IStrategyInfo    strategyInfo     = strategyAssembly.GetStrategyInfo("com.wer.sc.strategy.common.ma.Strategy_MultiMa");

            Console.WriteLine(strategyInfo);
        }
Пример #10
0
        public static List <string> GetAllTestUris()
        {
            List <string>         uris    = new List <string>();
            string                path    = TestCaseManager.GetTestCasePath(typeof(UriGetter), "datacenter.config");
            DataCenterManager     mgr     = DataCenterManager.Create(path);
            List <DataCenterInfo> configs = mgr.GetAllConfig();

            foreach (DataCenterInfo config in configs)
            {
                uris.Add(config.Uri);
            }
            return(uris);
        }
Пример #11
0
        public void TestTickDataLoadSave()
        {
            String path = TestCaseManager.GetTestCasePath(GetType(), "TickData_Output.csv");

            string[]  lines    = TestCaseManager.LoadTestCaseFile(GetType(), "CsvUtils_TickData").Split('\r');
            ITickData tickData = CsvUtils_TickData.LoadByLines(lines);

            CsvUtils_TickData.Save(path, tickData);

            ITickData newtickData = CsvUtils_TickData.Load(path);

            AssertUtils.AssertEqual_TickData(newtickData, tickData);
        }
Пример #12
0
        public void TestTradingDaySaveLoad()
        {
            string     path       = TestCaseManager.GetTestCasePath(GetType(), "CsvUtils_TradingDay");
            List <int> tradingDay = CsvUtils_TradingDay.Load(path);

            string outputPath = TestCaseManager.GetTestCasePath(GetType(), "TradingDay_Output.csv");

            CsvUtils_TradingDay.Save(outputPath, tradingDay);

            List <int> newTradingDay = CsvUtils_TradingDay.Load(outputPath);

            AssertUtils.AssertEqual_List_ToString(tradingDay, newTradingDay);
        }
Пример #13
0
        public void TestTradingTimeSaveLoad()
        {
            string path = TestCaseManager.GetTestCasePath(GetType(), "CsvUtils_TradingTime");
            List <ITradingTime> TradingTime = CsvUtils_TradingTime.Load(path);

            string outputPath = TestCaseManager.GetTestCasePath(GetType(), "TradingTime_Output.csv");

            CsvUtils_TradingTime.Save(outputPath, TradingTime);

            List <ITradingTime> newTradingTime = CsvUtils_TradingTime.Load(outputPath);

            AssertUtils.AssertEqual_List_ToString(TradingTime, newTradingTime);
        }
Пример #14
0
        public void TestLoadParameters()
        {
            IParameters parameters = ParameterFactory.CreateParameters();
            string      testCase   = TestCaseManager.GetTestCasePath(GetType(), "Parameters");
            XmlDocument doc        = new XmlDocument();

            doc.Load(testCase);

            parameters.Load(doc.DocumentElement);

            IParameters parameters2 = GetParameters();

            Assert.AreEqual(parameters.ToString(), parameters2.ToString());
        }
Пример #15
0
        public void TestTickDataStore_SaveLoad()
        {
            TickData data = (TickData)MockDataLoader.GetTickData("m1005", 20100108);
            String   path = TestCaseManager.GetTestCasePath(GetType(), "output_tick_saveload");
            TickDataStore_File_Single store = new TickDataStore_File_Single(path);

            store.Save(data);

            TickDataStore_File_Single store2 = new TickDataStore_File_Single(path);
            TickData data2 = store2.Load();

            AssertUtils.AssertEqual_TickData(data, data2);
            File.Delete(path);
        }
Пример #16
0
        public void TestKLineDataStore_LoadByDate()
        {
            string path = TestCaseManager.GetTestCasePath(GetType(), "output_20100107_20100120");

            IKLineData data = MockDataLoader.GetKLineData("m1005", 20100107, 20100120, KLinePeriod.KLinePeriod_1Minute);
            KLineDataStore_File_Single store = new KLineDataStore_File_Single(path);

            store.Save(data);

            KLineDataStore_File_Single store2 = new KLineDataStore_File_Single(path);
            IKLineData data2 = store2.Load(20100107, 20120111);

            AssertUtils.PrintKLineData(data2);
            File.Delete(path);
        }
Пример #17
0
        public void TestTradingDaySaveLoad()
        {
            string     path        = TestCaseManager.GetTestCasePath(GetType(), "output_TradingDay");
            List <int> tradingDays = MockDataLoader.GetAllTradingDays();

            TradingDayStore_File store = new TradingDayStore_File(path);

            store.Save(tradingDays);

            TradingDayStore_File newstore     = new TradingDayStore_File(path);
            List <int>           tradingDays2 = newstore.Load();

            AssertUtils.AssertEqual_List(tradingDays, tradingDays2);
            File.Delete(path);
        }
Пример #18
0
        public void TestKLineDataStore_SaveLoad()
        {
            IKLineData klineData = MockDataLoader.GetKLineData("m1005", 20100107, 20100120, KLinePeriod.KLinePeriod_1Minute);

            String path = TestCaseManager.GetTestCasePath(GetType(), "output_20100107_20100120");
            KLineDataStore_File_Single store = new KLineDataStore_File_Single(path);

            store.Save(klineData);

            KLineDataStore_File_Single store2 = new KLineDataStore_File_Single(path);
            KLineData klineData2 = store.LoadAll();

            AssertUtils.AssertEqual_KLineData(klineData, klineData2);
            File.Delete(path);
        }
Пример #19
0
        public void TestKLineDataSaveLoad()
        {
            String filename = "KLineData_Output.csv";

            string[]   lines     = TestCaseManager.LoadTestCaseFile(GetType(), "CsvUtils_KLineData").Split('\r');
            IKLineData klineData = CsvUtils_KLineData.LoadByLines(lines);

            string testCasePath = TestCaseManager.GetTestCasePath(GetType(), filename);

            CsvUtils_KLineData.Save(testCasePath, klineData);
            IKLineData newklineData = CsvUtils_KLineData.Load(testCasePath);

            File.Delete(testCasePath);

            AssertUtils.AssertEqual_KLineData(klineData, newklineData);
        }
Пример #20
0
        public void TestInstrumentsSaveLoad()
        {
            String outputPath     = TestCaseManager.GetTestCasePath(GetType(), "codes");
            string instrumentPath = TestCaseManager.GetTestCasePath(GetType(), "Store_Code");

            InstrumentStore_File store = new InstrumentStore_File(instrumentPath);
            List <CodeInfo>      codes = store.Load();

            InstrumentStore_File store2 = new InstrumentStore_File(outputPath);

            store2.Save(codes);
            List <CodeInfo> codes2 = store2.Load();

            AssertUtils.AssertEqual_List_ToString(codes, codes2);
            File.Delete(outputPath);
        }
Пример #21
0
        public void TestInstrumentsSaveLoad()
        {
            string          path        = TestCaseManager.GetTestCasePath(GetType(), "CsvUtils_Instruments");
            List <CodeInfo> instruments = CsvUtils_Code.Load(path);

            string outputPath = TestCaseManager.GetTestCasePath(GetType(), "Instruments_Output.csv");

            CsvUtils_Code.Save(outputPath, instruments);

            List <CodeInfo> newInstruments = CsvUtils_Code.Load(outputPath);

            AssertUtils.AssertEqual_List(instruments, newInstruments);
            //TestCaseManager.SaveTestCaseFile(GetType(),)
            //List<InstrumentInfo> instruments = MockDataLoader.GetAllInstruments();
            //AssertUtils.AssertEqual_List("CsvUtils_Instruments", GetType(), instruments);
        }
Пример #22
0
        public void TestAccountFeeStore()
        {
            String outputPath     = TestCaseManager.GetTestCasePath(GetType(), "accountfee");
            string instrumentPath = TestCaseManager.GetTestCasePath(GetType(), "Store_AccountFee");

            AccountFeeInfoStore_File store = new AccountFeeInfoStore_File(instrumentPath);
            List <AccountFeeInfo>    codes = store.LoadAllAccountFee();

            AccountFeeInfoStore_File store2 = new AccountFeeInfoStore_File(outputPath);

            store2.SaveAccountFee(codes);
            List <AccountFeeInfo> codes2 = store2.LoadAllAccountFee();

            AssertUtils.AssertEqual_List_ToString(codes, codes2);
            File.Delete(outputPath);
        }
Пример #23
0
        public void TestKLineDataStore_Append()
        {
            IKLineData klineData  = MockDataLoader.GetKLineData("m1005", 20100107, 20100114, KLinePeriod.KLinePeriod_1Minute);
            IKLineData klineData2 = MockDataLoader.GetKLineData("m1005", 20100115, 20100120, KLinePeriod.KLinePeriod_1Minute);

            List <IKLineData> ks = new List <IKLineData>();

            ks.Add(klineData);
            ks.Add(klineData2);
            IKLineData klineData_Merge = KLineData.Merge(ks);

            String path = TestCaseManager.GetTestCasePath(GetType(), "output_append");
            KLineDataStore_File_Single store = new KLineDataStore_File_Single(path);

            store.Save(klineData);
            store.Append(klineData2);

            IKLineData klineData_Merge2 = store.LoadAll();

            AssertUtils.AssertEqual_KLineData(klineData_Merge, klineData_Merge2);

            File.Delete(path);
        }
Пример #24
0
        private KLineData GetKLineData_1Min()
        {
            string path = TestCaseManager.GetTestCasePath(GetType(), "KLineData_M01_1Minute");

            return((KLineData)CsvUtils_KLineData.Load(path));
        }