예제 #1
0
        public void Initialize(string folderOrfile, string symbolFile, TickFileMode mode)
        {
            string[] symbolParts = symbolFile.Split(new char[] { '.' });
            string   _symbol     = symbolParts[0];

            this.mode = mode;
            symbol    = Factory.Symbol.LookupSymbol(_symbol);
            InitLogging();
            var dataFolder = folderOrfile.Contains(@"Test\") ? appDataFolder : priceDataFolder;
            var filePath   = dataFolder + "\\" + folderOrfile;

            if (Directory.Exists(filePath))
            {
                fileName = filePath + "\\" + symbolFile.StripInvalidPathChars() + ".tck";
            }
            else if (File.Exists(folderOrfile))
            {
                fileName = folderOrfile;
            }
            else
            {
                Directory.CreateDirectory(filePath);
                fileName = filePath + "\\" + symbolFile.StripInvalidPathChars() + ".tck";
                //throw new ApplicationException("Requires either a file or folder to read data. Tried both " + folderOrfile + " and " + filePath);
            }
            CheckFileExtension();
            if (debug)
            {
                log.Debug("File Name = " + fileName);
            }
            OpenFile();
            isInitialized = true;
        }
예제 #2
0
        public void Initialize(string folderOrfile, string symbolFile, TickFileMode mode)
        {
            string[] symbolParts = symbolFile.Split(new char[] { '.' });
            string   _symbol     = symbolParts[0];

            this.mode = mode;
            symbol    = Factory.Symbol.LookupSymbol(_symbol);
            InitLogging();
            var dataFolder = folderOrfile.Contains(@"Test\") ? appDataFolder : priceDataFolder;
            var filePath   = dataFolder + "\\" + folderOrfile;

            if (Directory.Exists(filePath))
            {
                fileName = filePath + "\\" + symbolFile.StripInvalidPathChars() + ".tck";
            }
            else if (File.Exists(folderOrfile))
            {
                fileName = folderOrfile;
            }
            else
            {
                Directory.CreateDirectory(filePath);
                fileName = filePath + "\\" + symbolFile.StripInvalidPathChars() + ".tck";
                //throw new ApplicationException("Requires either a file or folder to read data. Tried both " + folderOrfile + " and " + filePath);
            }
            CheckFileExtension();
            if (debug)
            {
                log.Debug("File Name = " + fileName);
            }
            try
            {
                OpenFile();
            }
            catch (InvalidOperationException)
            {
                CloseFileForReading();
                // Must a be a legacy format
                isLegacy = true;
                legacy.Initialize(folderOrfile, symbolFile, mode);
            }
            catch (EndOfStreamException)
            {
                endOfData = true;
                log.Notice("File was empty: " + fileName);
            }
            isInitialized = true;
        }
예제 #3
0
        public void Initialize(string fileName, TickFileMode mode)
        {
            this.mode     = mode;
            this.fileName = fileName = Path.GetFullPath(fileName);
            string baseName = Path.GetFileNameWithoutExtension(fileName);

            if (symbol == null)
            {
                symbol  = Factory.Symbol.LookupSymbol(baseName.Replace("_Tick", ""));
                lSymbol = symbol.BinaryIdentifier;
            }
            InitLogging();
            Directory.CreateDirectory(Path.GetDirectoryName(fileName));
            CheckFileExtension();
            if (debug)
            {
                log.Debug("File Name = " + fileName);
            }
            OpenFile();
            isInitialized = true;
        }
예제 #4
0
        public void Initialize(string fileName, TickFileMode mode)
        {
            this.mode     = mode;
            this.fileName = fileName = Path.GetFullPath(fileName);
            string baseName = Path.GetFileNameWithoutExtension(fileName);

            if (symbol == null)
            {
                symbol  = Factory.Symbol.LookupSymbol(baseName.Replace("_Tick", ""));
                lSymbol = symbol.BinaryIdentifier;
            }
            InitLogging();
            Directory.CreateDirectory(Path.GetDirectoryName(fileName));
            CheckFileExtension();
            if (debug)
            {
                log.Debug("File Name = " + fileName);
            }
            try
            {
                OpenFile();
            }
            catch (InvalidOperationException)
            {
                CloseFileForReading();
                // Must a be a legacy format
                isLegacy = true;
                legacy.Initialize(fileName, mode);
            }
            catch (EndOfStreamException)
            {
                endOfData = true;
                log.Notice("File was empty: " + fileName);
            }
            isInitialized = true;
        }