コード例 #1
0
        public override bool Run()
        {
            USeProductManager varietiesManager = CreateVarietiesManager();

            DirectoryInfo klineDir = new DirectoryInfo(m_kLineFolder);

            FileInfo[] klineFiles = klineDir.GetFiles("1min-*.csv");

            List <LogFileInfo> logFileList = new List <LogFileInfo>();

            foreach (FileInfo fileItem in klineFiles)
            {
                //if (fileItem.Name.StartsWith("1min") || fileItem.Name.StartsWith("1day"))
                //if (fileItem.Name.StartsWith("1min-cu1707"))//  || fileItem.Name.StartsWith("1day"))
                {
                    LogFileInfo logFileInfo = LogFileInfo.ParseLogFile(fileItem, varietiesManager);
                    logFileList.Add(logFileInfo);
                }
            }

            if (logFileList.Count < 0)
            {
                string text = "无可导入文件";
                m_eventLogger.WriteInformation(text);
                USeConsole.WriteLine(text);
                return(true);
            }

            int index = 0;

            foreach (LogFileInfo file in logFileList)
            {
                index++;
                try
                {
                    ClosePrice2Importer importer = new ClosePrice2Importer(file);

                    List <ClosePrice2Entity> closePriceList = importer.ParseClosePrice2();
                    string text = string.Format("解析{0}.{1}午盘数据完成,共计{2}条",
                                                importer.InstrumentCode, importer.Market, closePriceList.Count);
                    USeConsole.WriteLine(text);
                    Stopwatch stopWathch = new Stopwatch();
                    stopWathch.Start();
                    SaveClosePrice2Data(importer.Market, closePriceList);
                    stopWathch.Stop();
                    long useSecondes = stopWathch.ElapsedMilliseconds / 1000;
                    USeConsole.WriteLine(string.Format("导入{0}.{1}午盘数据完成,共计{2}条,耗时{3}秒,平均速度{4}/秒,Finish{5}/{6}",
                                                       importer.InstrumentCode, importer.Market, closePriceList.Count, useSecondes,
                                                       useSecondes > 0 ? closePriceList.Count / useSecondes : 0, index, logFileList.Count));
                }
                catch (Exception ex)
                {
                    string text = string.Format("导入数据失败,文件路径:{0},错误:{1}", file.FileInfo.FullName, ex.Message);
                    m_eventLogger.WriteInformation(text);
                    USeConsole.WriteLine(text);
                }
            }

            return(true);
        }
コード例 #2
0
        private List <LogFileInfo> GetLogFiles(USeProductManager productManager)
        {
            DirectoryInfo klineDir     = new DirectoryInfo(m_kLineFolder);
            string        searchParten = "";

            if (m_cycle == USeCycleType.Day)
            {
                searchParten = "1day-*.csv";
            }
            else if (m_cycle == USeCycleType.Min1)
            {
                searchParten = "1min-*.csv";
            }
            else
            {
                throw new NotSupportedException(string.Format("未知的周期类型文件:{0}", m_cycle));
            }
            FileInfo[] klineFiles = klineDir.GetFiles(searchParten);

            List <LogFileInfo> logFileList = new List <LogFileInfo>();

            foreach (FileInfo fileItem in klineFiles)
            {
                //if (fileItem.Name.StartsWith("1min-cu1707") || fileItem.Name.StartsWith("1day-cu1707"))
                {
                    LogFileInfo logFileInfo = LogFileInfo.ParseLogFile(fileItem, productManager);
                    logFileList.Add(logFileInfo);
                }
            }

            return(logFileList);
        }
コード例 #3
0
ファイル: KLineImporter.cs プロジェクト: handayu/TFS-WebKit
        public KLineImporter(LogFileInfo fileInfo)
        {
            m_logFileInfo = fileInfo;

            m_filePath       = fileInfo.FileInfo.FullName;
            m_cycle          = fileInfo.Cycle;
            m_market         = fileInfo.Market;
            m_instrumentCode = fileInfo.InstrumentCode;
        }
コード例 #4
0
        private TimeSpan m_logNoonTime    = new TimeSpan(11 + 3, 32, 00); //午盘时间 前推三个小时
        #endregion

        public ClosePrice2Importer(LogFileInfo fileInfo)
        {
            Debug.Assert(fileInfo.Cycle == USeCycleType.Min1);
            m_logFileInfo = fileInfo;

            m_filePath       = fileInfo.FileInfo.FullName;
            m_cycle          = fileInfo.Cycle;
            m_market         = fileInfo.Market;
            m_instrumentCode = fileInfo.InstrumentCode;
        }
コード例 #5
0
ファイル: LogProtocol.cs プロジェクト: handayu/TFS-WebKit
        public static LogFileInfo ParseLogFile(FileInfo fileInfo, USeProductManager productManager)
        {
            string[] items = fileInfo.Name.Split(new char[] { '-', '.' });
            if (items.Length != 3 && items[2].ToLower() != "csv")
            {
                throw new Exception("Undistinguish fileName:" + fileInfo.Name);
            }

            USeCycleType cycle          = USeCycleType.Unknown;
            string       cycleValue     = items[0].ToLower();
            string       instrumentCode = items[1];

            if (cycleValue == "1min")
            {
                cycle = USeCycleType.Min1;
            }
            else if (cycleValue == "5min")
            {
                cycle = USeCycleType.Min5;
            }
            else if (cycleValue == "1day")
            {
                cycle = USeCycleType.Day;
            }
            else
            {
                throw new Exception("Undistinguish cycel:" + cycleValue);
            }

            string     productCode = USeTraderProtocol.GetVarieties(instrumentCode);
            USeProduct product     = productManager.GetPruduct(productCode);

            if (product == null)
            {
                throw new Exception("Undistinguish cycel:" + cycleValue);
            }

            LogFileInfo logInfo = new LogFileInfo();

            logInfo.InstrumentCode = GetOfficeInstrumentCode(instrumentCode, product.Market);
            logInfo.Market         = product.Market;
            logInfo.Cycle          = cycle;
            logInfo.FileInfo       = fileInfo;

            return(logInfo);
        }