Ejemplo n.º 1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="dataDirectory"></param>
        /// <param name="symbol"></param>
        /// <param name="timeFrom"></param>
        /// <param name="timeTo"></param>
        public DucascopyReader(IConfiguration configuration, IFileManager <DucascopySymbol> fileManager, DucascopySymbol symbol, DateTime?timeFrom, DateTime timeTo)
        {
            _symbol        = symbol ?? throw new ArgumentNullException("symbol", "Symbol must be specified");
            _configuration = configuration;
            _fileManager   = fileManager;

            _files       = new LinkedList <IFile>(fileManager.GetExistingFiles(symbol, timeFrom ?? symbol.StartDate, timeTo).Where(f => f.Time >= timeFrom && f.Time < timeTo));
            _fileCurrent = _files.First;

            _stream = new DucascopyFileSteam(Path.Combine(configuration.DataPath, _fileCurrent.Value.DestinationFile));
            _reader = new DucascopyFileStreamReader(symbol, _fileCurrent.Value.Time, _stream);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Dispose
        /// </summary>
        /// <param name="disposing">Disposing</param>
        public void Dispose(bool disposing)
        {
            if (_stream != null)
            {
                _stream.Dispose();
                _stream = null;
            }

            if (_reader != null)
            {
                _reader.Dispose();
                _reader = null;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Connect next reader
        /// </summary>
        private void ConnectNextReader()
        {
            _fileCurrent = _fileCurrent.Next;

            try
            {
                _stream = new DucascopyFileSteam(Path.Combine(_configuration.DataPath, _fileCurrent.Value.DestinationFile));
            }
            catch (Exception exp)
            {
                Console.Write(exp.ToString());
                ConnectNextReader();
            }

            _reader = new DucascopyFileStreamReader(_symbol, _fileCurrent.Value.Time, _stream);
        }