/// <summary>
        /// 从wind或本地CSV获取当天数据
        /// </summary>
        /// <param name="today">今天的日期</param>
        /// <param name="code">代码</param>
        /// <returns></returns>
        private List <FuturesMinute> getData(DateTime today, string code)
        {
            //从本地csv 或者 wind获取数据,从wind拿到额数据会保存在本地
            List <FuturesMinute> data = KLineDataUtils.leakFilling(Platforms.container.Resolve <FuturesMinuteRepository>().fetchFromLocalCsvOrWindAndSave(code, today));

            return(data);
        }
Example #2
0
        /// <summary>
        /// 从wind或本地CSV获取当天数据
        /// </summary>
        /// <param name="today">今天的日期</param>
        /// <param name="code">代码</param>
        /// <returns></returns>
        private List <FuturesMinute> getData(DateTime today, string code)
        {
            //从本地csv 或者 wind获取数据,从wind拿到额数据会保存在本地
            List <FuturesMinute> data = KLineDataUtils.leakFilling(Platforms.container.Resolve <FuturesMinuteRepository>().fetchFromLocalCsvOrWindAndSave(code, today));
            var dataModified          = FreqTransferUtils.minuteToNMinutes(data, frequency);

            return(dataModified);
        }
Example #3
0
        /// <summary>
        /// 从wind或本地CSV获取当天数据
        /// </summary>
        /// <param name="today">今天的日期</param>
        /// <param name="code">代码</param>
        /// <returns></returns>
        private List <FuturesMinute> getData(DateTime today, string code)
        {
            List <FuturesMinute> orignalList = Platforms.container.Resolve <FuturesMinuteRepository>().fetchFromLocalCsvOrWindAndSave(code, today);
            List <FuturesMinute> data        = KLineDataUtils.leakFilling(orignalList);

            //从本地csv 或者 wind获取数据,从wind拿到额数据会保存在本地
            //List<FuturesMinute> data = KLineDataUtils.leakFilling(Platforms.container.Resolve<FuturesMinuteRepository>().fetchFromLocalCsvOrWindAndSave(code, today));

            #region 20170118更新
            //下面这行需要注释掉,因为可能data的count为0
            var dataModified = FreqTransferUtils.minuteToNMinutes(data, frequency);
            #endregion

            return(dataModified);
        }
Example #4
0
        public static List <FuturesMinute> GetFutureDataFromWind(int startDate, int endDate, string underlying)
        {
            //取到的数据
            List <FuturesMinute> data = new List <FuturesMinute>();
            //交易日列表
            List <DateTime> tradeDays = new List <DateTime>();

            DateTime startDateTime = Kit.ToDate(startDate);
            DateTime endDateTime   = Kit.ToDate(endDate);

            tradeDays = DateUtils.GetTradeDays(startDateTime, endDateTime);
            for (int i = 0; i < tradeDays.Count; i++)
            {
                DateTime today     = tradeDays[i];
                var      dataToday = KLineDataUtils.leakFilling(Platforms.container.Resolve <FuturesMinuteRepository>().fetchFromLocalCsvOrWindAndSave(underlying, today));
                data.AddRange(dataToday);
                Console.WriteLine("获取" + underlying + " " + today.ToShortDateString() + " " + "数据......");
            }
            return(data);
        }
Example #5
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);
        }