Ejemplo n.º 1
0
        private void ExportToList(FileInfo file_input, FileInfo file_output)
        {
            Stream _stream = new MemoryStream();
            // 加载文件,支持7z解压
            var fileStream = file_input.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            {
                try
                {
                    using (var zip = new SevenZipExtractor(fileStream))
                    {
                        // 只解压了第0个,如果有多个也只解压第一个
                        zip.ExtractFile(0, _stream);
                        _stream.Seek(0, SeekOrigin.Begin);
                    }
                }
                catch
                {
                    _stream = fileStream;
                    _stream.Seek(0, SeekOrigin.Begin);
                }
            }

            PbTickCodec codec = new PbTickCodec();

            QuantBox.Data.Serializer.PbTickSerializer Serializer = new QuantBox.Data.Serializer.PbTickSerializer();
            List <PbTickView> list = Serializer.Read2View(_stream);

            ListToCSV(list, file_output);
        }
Ejemplo n.º 2
0
        public TickReader(FileInfo file)
        {
            Serializer = new PbTickSerializer();
            Codec = new QuantBox.Data.Serializer.V2.PbTickCodec();
            _stream = new MemoryStream();
            _originalLength = (int)file.Length;

            // 加载文件,支持7z解压
            var fileStream = file.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            {
                try
                {
                    using (var zip = new SevenZipExtractor(fileStream))
                    {
                        zip.ExtractFile(0, _stream);
                        _stream.Seek(0, SeekOrigin.Begin);
                    }
                }
                catch
                {
                    _stream = fileStream;
                    _stream.Seek(0, SeekOrigin.Begin);
                }
            }
        }
Ejemplo n.º 3
0
        public static void Write(IEnumerable <PbTick> list, Stream stream)
        {
            if (list == null)
            {
                return;
            }

            foreach (PbTick item in list)
            {
                PbTickSerializer.WriteOne(item, stream);
            }
        }
Ejemplo n.º 4
0
        private void ExportToList(FileInfo file_input, FileInfo file_output, bool toCsv, bool toKdb, bool saveQuote)
        {
            // 都没选,跳过
            if (toCsv || toKdb)
            {
            }
            else
            {
                return;
            }

            Stream _stream = new MemoryStream();
            // 加载文件,支持7z解压
            var fileStream = file_input.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            {
                try
                {
                    using (var zip = new SevenZipExtractor(fileStream))
                    {
                        // 只解压了第0个,如果有多个也只解压第一个
                        zip.ExtractFile(0, _stream);
                        _stream.Seek(0, SeekOrigin.Begin);
                    }
                }
                catch
                {
                    _stream = fileStream;
                    _stream.Seek(0, SeekOrigin.Begin);
                }
            }

            PbTickCodec codec = new PbTickCodec();

            QuantBox.Data.Serializer.PbTickSerializer Serializer = new QuantBox.Data.Serializer.PbTickSerializer();
            List <PbTickView> list = Serializer.Read2View(_stream);

            if (toCsv)
            {
                ListToCSV(list, file_output);
            }
            // 得加入kdb+支持
            if (toKdb)
            {
                ListToKdb(list, saveQuote);
            }
        }
Ejemplo n.º 5
0
        public static List <PbTick> Read(Stream stream)
        {
            PbTick diff = null;

            List <PbTick> _list = new List <PbTick>();

            while (true)
            {
                diff = PbTickSerializer.ReadOne(stream);
                if (diff == null)
                {
                    break;
                }

                _list.Add(diff);
            }
            stream.Close();

            return(_list);
        }
Ejemplo n.º 6
0
        private void ExportToList(FileInfo file_input,FileInfo file_output)
        {
            Stream _stream = new MemoryStream();
            // 加载文件,支持7z解压
            var fileStream = file_input.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            {
                try
                {
                    using (var zip = new SevenZipExtractor(fileStream))
                    {
                        // 只解压了第0个,如果有多个也只解压第一个
                        zip.ExtractFile(0, _stream);
                        _stream.Seek(0, SeekOrigin.Begin);
                    }
                }
                catch
                {
                    _stream = fileStream;
                    _stream.Seek(0, SeekOrigin.Begin);
                }
            }

            PbTickCodec codec = new PbTickCodec();
            QuantBox.Data.Serializer.PbTickSerializer Serializer = new QuantBox.Data.Serializer.PbTickSerializer();
            List<PbTickView> list = Serializer.Read2View(_stream);
            ListToCSV(list, file_output);
        }