public void Should_TryParse_Return_False_When_Invalid_Data_Overflow()
        {
            // Act
            var parsed = DailyWeeklyMonthlyMessage.TryParse($"2018-04-27,164.3300,160.6300,164.0000,162.3200,35655839,{long.MaxValue},", out _);

            // Assert
            Assert.IsFalse(parsed);
        }
        public void Should_Parse_DailyWeeklyMonthlyMessage_With_Large_PeriodVolume()
        {
            // Arrange
            var message = $"2018-04-27,164.3300,160.6300,164.0000,162.3200,{long.MaxValue},0,";

            // Act
            var dailyWeeklyMonthlyMessage = DailyWeeklyMonthlyMessage.Parse(message);

            // Assert
            Assert.AreEqual(dailyWeeklyMonthlyMessage.PeriodVolume, long.MaxValue);
        }
        public void Should_Parse_DailyWeeklyMonthlyMessage_Invariant(string cultureName)
        {
            // Arrange
            TestHelper.SetThreadCulture(cultureName);

            // Act
            var dailyWeeklyMonthlyMessage = DailyWeeklyMonthlyMessage.Parse(_message);

            // Assert
            Assert.AreEqual(dailyWeeklyMonthlyMessage, _expectedMessage);
        }
        public void Should_TryParse_Return_True(string cultureName)
        {
            // Arrange
            TestHelper.SetThreadCulture(cultureName);

            // Act
            var parsed = DailyWeeklyMonthlyMessage.TryParse(_message, out var tickMessage);

            // Assert
            Assert.IsTrue(parsed);
            Assert.AreEqual(tickMessage, _expectedMessage);
        }
        public void Should_Parse_DailyWeeklyMonthlyMessage_Culture_Independant(string cultureName)
        {
            // Arrange
            TestHelper.SetThreadCulture(cultureName);
            var message = "2018-04-27,164.3300,160.6300,164.0000,162.3200,35655839,0,";

            // Act
            var dailyWeeklyMonthlyMessage           = new DailyWeeklyMonthlyMessage(new DateTime(2018, 04, 27), 164.33f, 160.63f, 164f, 162.32f, 35655839, 0);
            var dailyWeeklyMonthlyMessageFromValues = DailyWeeklyMonthlyMessage.Parse(message);

            // Assert
            Assert.AreEqual(dailyWeeklyMonthlyMessage, dailyWeeklyMonthlyMessageFromValues);
        }
Example #6
0
        public void Should_Csv_DailyWeeklyMonthlyMessage_With_RequestId_Invariant(string cultureName)
        {
            // Arrange
            TestHelper.SetThreadCulture(cultureName);
            var dailyWeeklyMonthlyMessage = new DailyWeeklyMonthlyMessage(new DateTime(2020, 01, 02, 9, 30, 0), 1.21, 1.22, 1.23, 1.24, 10, 1, "TEST123");

            // Act
            var csv = dailyWeeklyMonthlyMessage.ToCsv();

            // Assert
            var expectedCsv = "TEST123,2020-01-02,1.21,1.22,1.23,1.24,10,1";

            Assert.AreEqual(csv, expectedCsv);
        }
        private Func <string, HistoricalData> GetParseFunc(DataType dataType)
        {
            switch (dataType)
            {
            case DataType.Fundamental:
                return(FundamentalData.Parse);

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

            default:
                throw new NotSupportedException();
            }
        }
Example #8
0
        /// <summary>
        /// Stream IQFeed DailyWeeklyMonthlyMessage from disk to Lean TradeBar
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="request"></param>
        /// <returns>Converted TradeBar</returns>
        private IEnumerable <BaseData> GetDataFromDailyMessages(string filename, HistoryRequest request)
        {
            var dataTimeZone = _marketHoursDatabase.GetDataTimeZone(request.Symbol.ID.Market, request.Symbol, request.Symbol.SecurityType);

            foreach (var daily in DailyWeeklyMonthlyMessage.ParseFromFile(filename))
            {
                var dStartTime = daily.Timestamp;
                dStartTime = dStartTime.ConvertTo(TimeZones.NewYork, dataTimeZone);
                yield return(new TradeBar(
                                 dStartTime,
                                 request.Symbol,
                                 (decimal)daily.Open,
                                 (decimal)daily.High,
                                 (decimal)daily.Low,
                                 (decimal)daily.Close,
                                 daily.PeriodVolume,
                                 request.Resolution.ToTimeSpan()
                                 ));
            }

            File.Delete(filename);
        }
        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();
            }
        }
 public DailyWeeklyMonthlyMessageTests()
 {
     _message         = "2018-04-27,164.3300,160.6300,164.0000,162.3200,35655839,0,";
     _expectedMessage = new DailyWeeklyMonthlyMessage(new DateTime(2018, 04, 27), 164.33, 160.63, 164, 162.32, 35655839, 0);
 }