예제 #1
0
        public void Should_Parse_TickMessageProtocol62_Culture_Independent(string cultureName)
        {
            // Arrange
            TestHelper.SetThreadCulture(cultureName);

            // Act
            var tickMessageParsed = TickMessage.Parse(_messageProtocol62);

            // Assert
            Assert.AreEqual(tickMessageParsed, _expectedMessageProtocol62);
        }
예제 #2
0
        public void Should_Convert_Csv_To_Original_MessageProtocol60(string cultureName)
        {
            // Arrange
            TestHelper.SetThreadCulture(cultureName);
            var tickMessage1 = TickMessage.Parse(_messageProtocol60);

            // Act
            var tickMessage1Csv = tickMessage1.ToCsv();
            var tickMessage2    = TickMessage.Parse(tickMessage1Csv);

            // Assert
            Assert.AreEqual(tickMessage2, tickMessage1);
        }
예제 #3
0
        public void Should_Parse_TickMessage_Culture_Independent(string cultureName)
        {
            // Arrange
            TestHelper.SetThreadCulture(cultureName);
            var message = "2018-04-17 17:51:22.123456,96.0700,1061909,0,0.0000,0.0000,4145784264,O,19,143A";

            // Act
            var tickMessageParsed = TickMessage.Parse(message);

            var timestamp   = DateTime.ParseExact("2018-04-17 17:51:22.123456", TickMessage.TickDateTimeFormat, CultureInfo.InvariantCulture);
            var tickMessage = new TickMessage <double>(timestamp, 96.07d, 1061909, 0, 0.0d, 0.0d, 4145784264, 'O', 19, "143A");

            // Assert
            Assert.AreEqual(tickMessageParsed, tickMessage);
        }
예제 #4
0
        public IEnumerable <IHistoricalMessage> Parse()
        {
            ZipFile zipFile;

            using (var unzipped = Compression.Unzip(_zipPath, _zipEntry, out zipFile))
            {
                if (unzipped == null)
                {
                    yield break;
                }
                string line;
                while ((line = unzipped.ReadLine()) != null)
                {
                    yield return(TickMessage.Parse(line));
                }
            }
            zipFile.Dispose();
        }
예제 #5
0
        private IEnumerable <HistoricalData> GetData(MarketRequest request, string filename)
        {
            switch (request.DataType)
            {
            case DataType.Tick:
                return(LookupMessageFileParser.ParseFromFile(line => new HistoricalData(TickMessage.Parse(line).Timestamp, line), filename));

            case DataType.Daily:
                return(LookupMessageFileParser.ParseFromFile(line => new HistoricalData(DailyWeeklyMonthlyMessage.Parse(line).Timestamp, line), filename));

            default:
                throw new NotSupportedException();
            }
        }