diff --git a/src/_common/Quotes/Quote.Converters.cs b/src/_common/Quotes/Quote.Converters.cs index f7186f683..0a03e5e13 100644 --- a/src/_common/Quotes/Quote.Converters.cs +++ b/src/_common/Quotes/Quote.Converters.cs @@ -1,5 +1,3 @@ -using System.Globalization; - namespace Skender.Stock.Indicators; // QUOTE UTILITIES (CONVERTERS) diff --git a/src/_common/Quotes/Quote.Validation.cs b/src/_common/Quotes/Quote.Validation.cs index 04318e83b..382c955bb 100644 --- a/src/_common/Quotes/Quote.Validation.cs +++ b/src/_common/Quotes/Quote.Validation.cs @@ -1,9 +1,14 @@ +using System.Globalization; + namespace Skender.Stock.Indicators; // QUOTE UTILITIES: VALIDATION public static partial class Quotes { + private static readonly CultureInfo invariantCulture + = CultureInfo.InvariantCulture; + /// /// Check that quotes are valid and in ascending order. /// @@ -34,13 +39,17 @@ public static IReadOnlyList Validate( if (lastDate == currentDate) { - string msg = $"Duplicate date found on {currentDate}."; + string msg = + $"Duplicate date found on {currentDate.ToString("MM/dd/yyyy", invariantCulture)}."; + throw new InvalidQuotesException(nameof(quotes), msg); } if (lastDate > currentDate) { - string msg = $"Quotes are out of sequence on {currentDate}."; + string msg = + $"Quotes are out of sequence on {currentDate.ToString("MM/dd/yyyy", invariantCulture)}."; + throw new InvalidQuotesException(nameof(quotes), msg); } diff --git a/tests/indicators/TestBase.cs b/tests/indicators/TestBase.cs index d0d11019f..5486c5f0e 100644 --- a/tests/indicators/TestBase.cs +++ b/tests/indicators/TestBase.cs @@ -12,7 +12,7 @@ namespace Test.Data; public abstract class TestBase // base for all tests { - internal static readonly CultureInfo englishCulture = new("en-US", false); + internal static readonly CultureInfo invariantCulture = CultureInfo.InvariantCulture; internal static readonly IReadOnlyList Quotes = Data.GetDefault(); internal static readonly IReadOnlyList OtherQuotes = Data.GetCompare(); @@ -29,7 +29,7 @@ namespace Test.Data; protected static readonly double DoublePrecision = 1E-13; protected static readonly DateTime EvalDate - = DateTime.ParseExact("12/31/2018", "MM/dd/yyyy", englishCulture); + = DateTime.ParseExact("12/31/2018", "MM/dd/yyyy", invariantCulture); } /// diff --git a/tests/indicators/_common/Candles/Candles.Tests.cs b/tests/indicators/_common/Candles/Candles.Tests.cs index 85d6fe6e3..a23c94202 100644 --- a/tests/indicators/_common/Candles/Candles.Tests.cs +++ b/tests/indicators/_common/Candles/Candles.Tests.cs @@ -16,13 +16,13 @@ public void SortCandles() Assert.AreEqual(502, candles.Count); // sample values - DateTime firstDate = DateTime.ParseExact("01/18/2016", "MM/dd/yyyy", englishCulture); + DateTime firstDate = DateTime.ParseExact("01/18/2016", "MM/dd/yyyy", invariantCulture); Assert.AreEqual(firstDate, candles[0].Timestamp); - DateTime lastDate = DateTime.ParseExact("12/31/2018", "MM/dd/yyyy", englishCulture); + DateTime lastDate = DateTime.ParseExact("12/31/2018", "MM/dd/yyyy", invariantCulture); Assert.AreEqual(lastDate, candles[^1].Timestamp); - DateTime spotDate = DateTime.ParseExact("03/16/2017", "MM/dd/yyyy", englishCulture); + DateTime spotDate = DateTime.ParseExact("03/16/2017", "MM/dd/yyyy", invariantCulture); Assert.AreEqual(spotDate, candles[50].Timestamp); } diff --git a/tests/indicators/_common/Generics/Sorting.Tests.cs b/tests/indicators/_common/Generics/Sorting.Tests.cs index 77aa0c223..d89adf62f 100644 --- a/tests/indicators/_common/Generics/Sorting.Tests.cs +++ b/tests/indicators/_common/Generics/Sorting.Tests.cs @@ -11,15 +11,15 @@ public void ToSortedCollection() // baseline for comparison IReadOnlyList baseline = [ - new(Timestamp: DateTime.Parse("1/1/2000", englishCulture), Sma: null), - new(Timestamp: DateTime.Parse("1/2/2000", englishCulture), Sma: null), - new(Timestamp: DateTime.Parse("1/9/2000", englishCulture), Sma: null), - new(Timestamp: DateTime.Parse("1/3/2000", englishCulture), Sma: 3), - new(Timestamp: DateTime.Parse("1/4/2000", englishCulture), Sma: 4), - new(Timestamp: DateTime.Parse("1/5/2000", englishCulture), Sma: 5), - new(Timestamp: DateTime.Parse("1/6/2000", englishCulture), Sma: 6), - new(Timestamp: DateTime.Parse("1/7/2000", englishCulture), Sma: 7), - new(Timestamp: DateTime.Parse("1/8/2000", englishCulture), Sma: double.NaN) + new(Timestamp: DateTime.Parse("1/1/2000", invariantCulture), Sma: null), + new(Timestamp: DateTime.Parse("1/2/2000", invariantCulture), Sma: null), + new(Timestamp: DateTime.Parse("1/9/2000", invariantCulture), Sma: null), + new(Timestamp: DateTime.Parse("1/3/2000", invariantCulture), Sma: 3), + new(Timestamp: DateTime.Parse("1/4/2000", invariantCulture), Sma: 4), + new(Timestamp: DateTime.Parse("1/5/2000", invariantCulture), Sma: 5), + new(Timestamp: DateTime.Parse("1/6/2000", invariantCulture), Sma: 6), + new(Timestamp: DateTime.Parse("1/7/2000", invariantCulture), Sma: 7), + new(Timestamp: DateTime.Parse("1/8/2000", invariantCulture), Sma: double.NaN) ]; // PUBLIC VARIANT, generic sorted Collection @@ -27,6 +27,6 @@ public void ToSortedCollection() .ToSortedCollection(); Assert.AreEqual(5, sortResults[4].Sma); - Assert.AreEqual(DateTime.Parse("1/9/2000", englishCulture), sortResults.LastOrDefault().Timestamp); + Assert.AreEqual(DateTime.Parse("1/9/2000", invariantCulture), sortResults.LastOrDefault().Timestamp); } } diff --git a/tests/indicators/_common/Math/Numerical.Tests.cs b/tests/indicators/_common/Math/Numerical.Tests.cs index 4f0e1f939..e116fe11f 100644 --- a/tests/indicators/_common/Math/Numerical.Tests.cs +++ b/tests/indicators/_common/Math/Numerical.Tests.cs @@ -54,10 +54,10 @@ public void SlopeMismatch() public void RoundDownDate() { TimeSpan interval = PeriodSize.OneHour.ToTimeSpan(); - DateTime evDate = DateTime.Parse("2020-12-15 09:35:45", englishCulture); + DateTime evDate = DateTime.Parse("2020-12-15 09:35:45", invariantCulture); DateTime rnDate = evDate.RoundDown(interval); - DateTime exDate = DateTime.Parse("2020-12-15 09:00:00", englishCulture); + DateTime exDate = DateTime.Parse("2020-12-15 09:00:00", invariantCulture); Assert.AreEqual(exDate, rnDate); } diff --git a/tests/indicators/_common/Quotes/Quote.Aggregates.Tests.cs b/tests/indicators/_common/Quotes/Quote.Aggregates.Tests.cs index 0f9a4b449..9cb91b204 100644 --- a/tests/indicators/_common/Quotes/Quote.Aggregates.Tests.cs +++ b/tests/indicators/_common/Quotes/Quote.Aggregates.Tests.cs @@ -18,7 +18,7 @@ public void Aggregate() // sample values Quote r0 = results[0]; - Assert.AreEqual(DateTime.Parse("2020-12-15 09:30", englishCulture), r0.Timestamp); + Assert.AreEqual(DateTime.Parse("2020-12-15 09:30", TestBase.invariantCulture), r0.Timestamp); Assert.AreEqual(367.40m, r0.Open); Assert.AreEqual(367.775m, r0.High); Assert.AreEqual(367.02m, r0.Low); @@ -26,7 +26,7 @@ public void Aggregate() Assert.AreEqual(2401786m, r0.Volume); Quote r1 = results[1]; - Assert.AreEqual(DateTime.Parse("2020-12-15 09:45", englishCulture), r1.Timestamp); + Assert.AreEqual(DateTime.Parse("2020-12-15 09:45", TestBase.invariantCulture), r1.Timestamp); Assert.AreEqual(367.25m, r1.Open); Assert.AreEqual(367.44m, r1.High); Assert.AreEqual(366.69m, r1.Low); @@ -34,7 +34,7 @@ public void Aggregate() Assert.AreEqual(1669983m, r1.Volume); Quote r2 = results[2]; - Assert.AreEqual(DateTime.Parse("2020-12-15 10:00", englishCulture), r2.Timestamp); + Assert.AreEqual(DateTime.Parse("2020-12-15 10:00", TestBase.invariantCulture), r2.Timestamp); Assert.AreEqual(366.85m, r2.Open); Assert.AreEqual(367.17m, r2.High); Assert.AreEqual(366.57m, r2.Low); @@ -61,7 +61,7 @@ public void AggregateTimeSpan() // sample values Quote r0 = results[0]; - Assert.AreEqual(DateTime.Parse("2020-12-15 09:30", englishCulture), r0.Timestamp); + Assert.AreEqual(DateTime.Parse("2020-12-15 09:30", TestBase.invariantCulture), r0.Timestamp); Assert.AreEqual(367.40m, r0.Open); Assert.AreEqual(367.775m, r0.High); Assert.AreEqual(367.02m, r0.Low); @@ -69,7 +69,7 @@ public void AggregateTimeSpan() Assert.AreEqual(2401786m, r0.Volume); Quote r1 = results[1]; - Assert.AreEqual(DateTime.Parse("2020-12-15 09:45", englishCulture), r1.Timestamp); + Assert.AreEqual(DateTime.Parse("2020-12-15 09:45", TestBase.invariantCulture), r1.Timestamp); Assert.AreEqual(367.25m, r1.Open); Assert.AreEqual(367.44m, r1.High); Assert.AreEqual(366.69m, r1.Low); @@ -77,7 +77,7 @@ public void AggregateTimeSpan() Assert.AreEqual(1669983m, r1.Volume); Quote r2 = results[2]; - Assert.AreEqual(DateTime.Parse("2020-12-15 10:00", englishCulture), r2.Timestamp); + Assert.AreEqual(DateTime.Parse("2020-12-15 10:00", TestBase.invariantCulture), r2.Timestamp); Assert.AreEqual(366.85m, r2.Open); Assert.AreEqual(367.17m, r2.High); Assert.AreEqual(366.57m, r2.Low); @@ -102,7 +102,7 @@ public void AggregateMonth() // sample values Quote r0 = results[0]; - Assert.AreEqual(DateTime.Parse("2017-01-01", englishCulture), r0.Timestamp); + Assert.AreEqual(DateTime.Parse("2017-01-01", TestBase.invariantCulture), r0.Timestamp); Assert.AreEqual(212.61m, r0.Open); Assert.AreEqual(217.02m, r0.High); Assert.AreEqual(211.52m, r0.Low); @@ -110,7 +110,7 @@ public void AggregateMonth() Assert.AreEqual(1569087580m, r0.Volume); Quote r1 = results[1]; - Assert.AreEqual(DateTime.Parse("2017-02-01", englishCulture), r1.Timestamp); + Assert.AreEqual(DateTime.Parse("2017-02-01", TestBase.invariantCulture), r1.Timestamp); Assert.AreEqual(215.65m, r1.Open); Assert.AreEqual(224.20m, r1.High); Assert.AreEqual(214.29m, r1.Low); @@ -118,7 +118,7 @@ public void AggregateMonth() Assert.AreEqual(1444958340m, r1.Volume); Quote r23 = results[23]; - Assert.AreEqual(DateTime.Parse("2018-12-01", englishCulture), r23.Timestamp); + Assert.AreEqual(DateTime.Parse("2018-12-01", TestBase.invariantCulture), r23.Timestamp); Assert.AreEqual(273.47m, r23.Open); Assert.AreEqual(273.59m, r23.High); Assert.AreEqual(229.42m, r23.Low); diff --git a/tests/indicators/_common/Quotes/Quote.Converters.Tests.cs b/tests/indicators/_common/Quotes/Quote.Converters.Tests.cs index 6e10aadc9..704f4096b 100644 --- a/tests/indicators/_common/Quotes/Quote.Converters.Tests.cs +++ b/tests/indicators/_common/Quotes/Quote.Converters.Tests.cs @@ -18,15 +18,15 @@ public void ToSortedCollection() Assert.AreEqual(502, h.Count); // check first date - DateTime firstDate = DateTime.ParseExact("01/18/2016", "MM/dd/yyyy", englishCulture); + DateTime firstDate = DateTime.ParseExact("01/18/2016", "MM/dd/yyyy", TestBase.invariantCulture); Assert.AreEqual(firstDate, h[0].Timestamp); // check last date - DateTime lastDate = DateTime.ParseExact("12/31/2018", "MM/dd/yyyy", englishCulture); + DateTime lastDate = DateTime.ParseExact("12/31/2018", "MM/dd/yyyy", TestBase.invariantCulture); Assert.AreEqual(lastDate, h.LastOrDefault().Timestamp); // spot check an out of sequence date - DateTime spotDate = DateTime.ParseExact("03/16/2017", "MM/dd/yyyy", englishCulture); + DateTime spotDate = DateTime.ParseExact("03/16/2017", "MM/dd/yyyy", TestBase.invariantCulture); Assert.AreEqual(spotDate, h[50].Timestamp); } @@ -41,15 +41,15 @@ public void ToSortedList() Assert.AreEqual(502, h.Count); // check first date - DateTime firstDate = DateTime.ParseExact("01/18/2016", "MM/dd/yyyy", englishCulture); + DateTime firstDate = DateTime.ParseExact("01/18/2016", "MM/dd/yyyy", TestBase.invariantCulture); Assert.AreEqual(firstDate, h[0].Timestamp); // check last date - DateTime lastDate = DateTime.ParseExact("12/31/2018", "MM/dd/yyyy", englishCulture); + DateTime lastDate = DateTime.ParseExact("12/31/2018", "MM/dd/yyyy", TestBase.invariantCulture); Assert.AreEqual(lastDate, h[^1].Timestamp); // spot check an out of sequence date - DateTime spotDate = DateTime.ParseExact("03/16/2017", "MM/dd/yyyy", englishCulture); + DateTime spotDate = DateTime.ParseExact("03/16/2017", "MM/dd/yyyy", TestBase.invariantCulture); Assert.AreEqual(spotDate, h[50].Timestamp); } } diff --git a/tests/indicators/_common/Quotes/Quote.Validation.Tests.cs b/tests/indicators/_common/Quotes/Quote.Validation.Tests.cs index d5af907a5..b4526b8cd 100644 --- a/tests/indicators/_common/Quotes/Quote.Validation.Tests.cs +++ b/tests/indicators/_common/Quotes/Quote.Validation.Tests.cs @@ -1,3 +1,5 @@ +using System.Globalization; + namespace Utilities; // quote validation @@ -15,10 +17,10 @@ public void Validate() Assert.AreEqual(502, h.Count); // sample values - DateTime lastDate = DateTime.ParseExact("12/31/2018", "MM/dd/yyyy", englishCulture); + DateTime lastDate = DateTime.ParseExact("12/31/2018", "MM/dd/yyyy", invariantCulture); Assert.AreEqual(lastDate, h[501].Timestamp); - DateTime spotDate = DateTime.ParseExact("02/01/2017", "MM/dd/yyyy", englishCulture); + DateTime spotDate = DateTime.ParseExact("02/01/2017", "MM/dd/yyyy", invariantCulture); Assert.AreEqual(spotDate, h[20].Timestamp); } @@ -31,7 +33,7 @@ public void ValidateLong() Assert.AreEqual(5285, h.Count); // sample values - DateTime lastDate = DateTime.ParseExact("09/04/2020", "MM/dd/yyyy", englishCulture); + DateTime lastDate = DateTime.ParseExact("09/04/2020", "MM/dd/yyyy", invariantCulture); Assert.AreEqual(lastDate, h[5284].Timestamp); } @@ -80,11 +82,11 @@ public void ValidateDuplicates() { IReadOnlyList dupQuotes = new List { - new(Timestamp: DateTime.ParseExact("2017-01-03", "yyyy-MM-dd", englishCulture), Open: 214.86m, High: 220.33m, Low: 210.96m, Close: 216.99m, Volume: 5923254), - new(Timestamp: DateTime.ParseExact("2017-01-04", "yyyy-MM-dd", englishCulture), Open: 214.75m, High: 228.00m, Low: 214.31m, Close: 226.99m, Volume: 11213471), - new(Timestamp: DateTime.ParseExact("2017-01-05", "yyyy-MM-dd", englishCulture), Open: 226.42m, High: 227.48m, Low: 221.95m, Close: 226.75m, Volume: 5911695), - new(Timestamp: DateTime.ParseExact("2017-01-06", "yyyy-MM-dd", englishCulture), Open: 226.93m, High: 230.31m, Low: 225.45m, Close: 229.01m, Volume: 5527893), - new(Timestamp: DateTime.ParseExact("2017-01-06", "yyyy-MM-dd", englishCulture), Open: 228.97m, High: 231.92m, Low: 228.00m, Close: 231.28m, Volume: 3979484) + new(Timestamp: DateTime.ParseExact("2017-01-03", "yyyy-MM-dd", invariantCulture), Open: 214.86m, High: 220.33m, Low: 210.96m, Close: 216.99m, Volume: 5923254), + new(Timestamp: DateTime.ParseExact("2017-01-04", "yyyy-MM-dd", invariantCulture), Open: 214.75m, High: 228.00m, Low: 214.31m, Close: 226.99m, Volume: 11213471), + new(Timestamp: DateTime.ParseExact("2017-01-05", "yyyy-MM-dd", invariantCulture), Open: 226.42m, High: 227.48m, Low: 221.95m, Close: 226.75m, Volume: 5911695), + new(Timestamp: DateTime.ParseExact("2017-01-06", "yyyy-MM-dd", invariantCulture), Open: 226.93m, High: 230.31m, Low: 225.45m, Close: 229.01m, Volume: 5527893), + new(Timestamp: DateTime.ParseExact("2017-01-06", "yyyy-MM-dd", invariantCulture), Open: 228.97m, High: 231.92m, Low: 228.00m, Close: 231.28m, Volume: 3979484) }; InvalidQuotesException dx @@ -92,7 +94,7 @@ InvalidQuotesException dx () => dupQuotes.Validate()); dx.Message.Should() - .Be("Duplicate date found on 1/6/2017 12:00:00 AM. (Parameter 'quotes')"); + .Be("Duplicate date found on 01/06/2017. (Parameter 'quotes')"); } [TestMethod] @@ -100,11 +102,11 @@ public void ValidateOutOfSequence() { IReadOnlyList unorderedQuotes = new List { - new(Timestamp: DateTime.ParseExact("2017-01-03", "yyyy-MM-dd", englishCulture), Open: 214.86m, High: 220.33m, Low: 210.96m, Close: 216.99m, Volume: 5923254), - new(Timestamp: DateTime.ParseExact("2017-01-04", "yyyy-MM-dd", englishCulture), Open: 214.75m, High: 228.00m, Low: 214.31m, Close: 226.99m, Volume: 11213471), - new(Timestamp: DateTime.ParseExact("2017-01-06", "yyyy-MM-dd", englishCulture), Open: 228.97m, High: 231.92m, Low: 228.00m, Close: 231.28m, Volume: 3979484), - new(Timestamp: DateTime.ParseExact("2017-01-05", "yyyy-MM-dd", englishCulture), Open: 226.42m, High: 227.48m, Low: 221.95m, Close: 226.75m, Volume: 5911695), - new(Timestamp: DateTime.ParseExact("2017-01-06", "yyyy-MM-dd", englishCulture), Open: 226.93m, High: 230.31m, Low: 225.45m, Close: 229.01m, Volume: 5527893) + new(Timestamp: DateTime.ParseExact("2017-01-03", "yyyy-MM-dd", invariantCulture), Open: 214.86m, High: 220.33m, Low: 210.96m, Close: 216.99m, Volume: 5923254), + new(Timestamp: DateTime.ParseExact("2017-01-04", "yyyy-MM-dd", invariantCulture), Open: 214.75m, High: 228.00m, Low: 214.31m, Close: 226.99m, Volume: 11213471), + new(Timestamp: DateTime.ParseExact("2017-01-06", "yyyy-MM-dd", invariantCulture), Open: 228.97m, High: 231.92m, Low: 228.00m, Close: 231.28m, Volume: 3979484), + new(Timestamp: DateTime.ParseExact("2017-01-05", "yyyy-MM-dd", invariantCulture), Open: 226.42m, High: 227.48m, Low: 221.95m, Close: 226.75m, Volume: 5911695), + new(Timestamp: DateTime.ParseExact("2017-01-06", "yyyy-MM-dd", invariantCulture), Open: 226.93m, High: 230.31m, Low: 225.45m, Close: 229.01m, Volume: 5527893) }; InvalidQuotesException dx @@ -112,7 +114,6 @@ InvalidQuotesException dx () => unorderedQuotes.Validate()); dx.Message.Should() - .Be("Quotes are out of sequence on 1/5/2017 12:00:00 AM. (Parameter 'quotes')"); + .Be("Quotes are out of sequence on 01/05/2017. (Parameter 'quotes')"); } - } diff --git a/tests/indicators/_common/Reusable/Reusable.Utilities.Tests.cs b/tests/indicators/_common/Reusable/Reusable.Utilities.Tests.cs index 72c8433e6..f8bba07d7 100644 --- a/tests/indicators/_common/Reusable/Reusable.Utilities.Tests.cs +++ b/tests/indicators/_common/Reusable/Reusable.Utilities.Tests.cs @@ -41,7 +41,7 @@ public void ToReusableList() [TestMethod] public void QuoteToReusable() { - DateTime t = DateTime.Parse("5/5/2055", englishCulture); + DateTime t = DateTime.Parse("5/5/2055", invariantCulture); decimal l = 111111111111111m; decimal o = 222222222222222m; diff --git a/tests/indicators/_common/Use (QuotePart)/QuotePart.StaticSeries.Tests.cs b/tests/indicators/_common/Use (QuotePart)/QuotePart.StaticSeries.Tests.cs index 720328894..72c57b1a2 100644 --- a/tests/indicators/_common/Use (QuotePart)/QuotePart.StaticSeries.Tests.cs +++ b/tests/indicators/_common/Use (QuotePart)/QuotePart.StaticSeries.Tests.cs @@ -34,7 +34,7 @@ public override void Standard() QuotePart rohlc = ohlc[501]; // proper last date - DateTime lastDate = DateTime.ParseExact("12/31/2018", "MM/dd/yyyy", englishCulture); + DateTime lastDate = DateTime.ParseExact("12/31/2018", "MM/dd/yyyy", invariantCulture); Assert.AreEqual(lastDate, rc.Timestamp); // last values should be correct diff --git a/tests/indicators/_common/Use (QuotePart)/QuotePart.Utilities.Tests.cs b/tests/indicators/_common/Use (QuotePart)/QuotePart.Utilities.Tests.cs index ed7fe3524..bbf643f4b 100644 --- a/tests/indicators/_common/Use (QuotePart)/QuotePart.Utilities.Tests.cs +++ b/tests/indicators/_common/Use (QuotePart)/QuotePart.Utilities.Tests.cs @@ -22,7 +22,7 @@ public void ConvertQuote() QuotePart ohlc = Quotes[501].ToQuotePart(CandlePart.OHLC4); // proper last date - DateTime lastDate = DateTime.ParseExact("12/31/2018", "MM/dd/yyyy", englishCulture); + DateTime lastDate = DateTime.ParseExact("12/31/2018", "MM/dd/yyyy", invariantCulture); Assert.AreEqual(lastDate, c.Timestamp); // last values should be correct @@ -70,7 +70,7 @@ public void ConvertList() QuotePart rohlc = ohlc[501]; // proper last date - DateTime lastDate = DateTime.ParseExact("12/31/2018", "MM/dd/yyyy", englishCulture); + DateTime lastDate = DateTime.ParseExact("12/31/2018", "MM/dd/yyyy", invariantCulture); Assert.AreEqual(lastDate, rc.Timestamp); // last values should be correct diff --git a/tests/indicators/a-d/Beta/Beta.StaticSeries.Tests.cs b/tests/indicators/a-d/Beta/Beta.StaticSeries.Tests.cs index f2797f1c7..c8214d024 100644 --- a/tests/indicators/a-d/Beta/Beta.StaticSeries.Tests.cs +++ b/tests/indicators/a-d/Beta/Beta.StaticSeries.Tests.cs @@ -227,28 +227,28 @@ public void NoMatch() { IReadOnlyList quoteA = [ - new(DateTime.Parse("1/1/2020", englishCulture), 0, 0, 0, 1234, 0), - new(DateTime.Parse("1/2/2020", englishCulture), 0, 0, 0, 1234, 0), - new(DateTime.Parse("1/3/2020", englishCulture), 0, 0, 0, 1234, 0), - new(DateTime.Parse("1/4/2020", englishCulture), 0, 0, 0, 1234, 0), - new(DateTime.Parse("1/5/2020", englishCulture), 0, 0, 0, 1234, 0), - new(DateTime.Parse("1/6/2020", englishCulture), 0, 0, 0, 1234, 0), - new(DateTime.Parse("1/7/2020", englishCulture), 0, 0, 0, 1234, 0), - new(DateTime.Parse("1/8/2020", englishCulture), 0, 0, 0, 1234, 0), - new(DateTime.Parse("1/9/2020", englishCulture), 0, 0, 0, 1234, 0) + new(DateTime.Parse("1/1/2020", invariantCulture), 0, 0, 0, 1234, 0), + new(DateTime.Parse("1/2/2020", invariantCulture), 0, 0, 0, 1234, 0), + new(DateTime.Parse("1/3/2020", invariantCulture), 0, 0, 0, 1234, 0), + new(DateTime.Parse("1/4/2020", invariantCulture), 0, 0, 0, 1234, 0), + new(DateTime.Parse("1/5/2020", invariantCulture), 0, 0, 0, 1234, 0), + new(DateTime.Parse("1/6/2020", invariantCulture), 0, 0, 0, 1234, 0), + new(DateTime.Parse("1/7/2020", invariantCulture), 0, 0, 0, 1234, 0), + new(DateTime.Parse("1/8/2020", invariantCulture), 0, 0, 0, 1234, 0), + new(DateTime.Parse("1/9/2020", invariantCulture), 0, 0, 0, 1234, 0) ]; IReadOnlyList quoteB = [ - new(DateTime.Parse("1/1/2020", englishCulture), 0, 0, 0, 1234, 0), - new(DateTime.Parse("1/2/2020", englishCulture), 0, 0, 0, 1234, 0), - new(DateTime.Parse("1/3/2020", englishCulture), 0, 0, 0, 1234, 0), - new(DateTime.Parse("2/4/2020", englishCulture), 0, 0, 0, 1234, 0), // abberrant - new(DateTime.Parse("1/5/2020", englishCulture), 0, 0, 0, 1234, 0), - new(DateTime.Parse("1/6/2020", englishCulture), 0, 0, 0, 1234, 0), - new(DateTime.Parse("1/7/2020", englishCulture), 0, 0, 0, 1234, 0), - new(DateTime.Parse("1/8/2020", englishCulture), 0, 0, 0, 1234, 0), - new(DateTime.Parse("1/9/2020", englishCulture), 0, 0, 0, 1234, 0) + new(DateTime.Parse("1/1/2020", invariantCulture), 0, 0, 0, 1234, 0), + new(DateTime.Parse("1/2/2020", invariantCulture), 0, 0, 0, 1234, 0), + new(DateTime.Parse("1/3/2020", invariantCulture), 0, 0, 0, 1234, 0), + new(DateTime.Parse("2/4/2020", invariantCulture), 0, 0, 0, 1234, 0), // abberrant + new(DateTime.Parse("1/5/2020", invariantCulture), 0, 0, 0, 1234, 0), + new(DateTime.Parse("1/6/2020", invariantCulture), 0, 0, 0, 1234, 0), + new(DateTime.Parse("1/7/2020", invariantCulture), 0, 0, 0, 1234, 0), + new(DateTime.Parse("1/8/2020", invariantCulture), 0, 0, 0, 1234, 0), + new(DateTime.Parse("1/9/2020", invariantCulture), 0, 0, 0, 1234, 0) ]; Assert.ThrowsException(() diff --git a/tests/indicators/a-d/Dpo/Dpo.StaticSeries.Tests.cs b/tests/indicators/a-d/Dpo/Dpo.StaticSeries.Tests.cs index f6a3c71b3..08628d406 100644 --- a/tests/indicators/a-d/Dpo/Dpo.StaticSeries.Tests.cs +++ b/tests/indicators/a-d/Dpo/Dpo.StaticSeries.Tests.cs @@ -17,7 +17,7 @@ public override void Standard() for (int i = 0; i < csvData.Count; i++) { string[] csv = csvData[i].Split(","); - DateTime date = Convert.ToDateTime(csv[1], englishCulture); + DateTime date = Convert.ToDateTime(csv[1], invariantCulture); qot.Add(new Quote(date, 0, 0, 0, Close: csv[5].ToDecimal(), 0)); exp.Add(new(date, csv[7].ToDoubleNull(), csv[6].ToDoubleNull())); diff --git a/tests/indicators/s-z/Sma/Sma.StaticSeries.Tests.cs b/tests/indicators/s-z/Sma/Sma.StaticSeries.Tests.cs index beb01d021..d66fe61ff 100644 --- a/tests/indicators/s-z/Sma/Sma.StaticSeries.Tests.cs +++ b/tests/indicators/s-z/Sma/Sma.StaticSeries.Tests.cs @@ -59,7 +59,7 @@ public void CandlePartVolume() Assert.AreEqual(157958070.8, r290.Sma); SmaResult r501 = results[501]; - Assert.AreEqual(DateTime.ParseExact("12/31/2018", "MM/dd/yyyy", englishCulture), r501.Timestamp); + Assert.AreEqual(DateTime.ParseExact("12/31/2018", "MM/dd/yyyy", invariantCulture), r501.Timestamp); Assert.AreEqual(163695200, r501.Sma); } diff --git a/tests/indicators/s-z/Vwap/Vwap.StaticSeries.Tests.cs b/tests/indicators/s-z/Vwap/Vwap.StaticSeries.Tests.cs index df7973627..cb07abc66 100644 --- a/tests/indicators/s-z/Vwap/Vwap.StaticSeries.Tests.cs +++ b/tests/indicators/s-z/Vwap/Vwap.StaticSeries.Tests.cs @@ -35,7 +35,7 @@ public override void Standard() public void WithStartDate() { DateTime startDate = - DateTime.ParseExact("2020-12-15 10:00", "yyyy-MM-dd h:mm", englishCulture); + DateTime.ParseExact("2020-12-15 10:00", "yyyy-MM-dd h:mm", invariantCulture); IReadOnlyList results = intraday .ToVwap(startDate); @@ -109,7 +109,7 @@ public void Removed() // with start date DateTime startDate = - DateTime.ParseExact("2020-12-15 10:00", "yyyy-MM-dd h:mm", englishCulture); + DateTime.ParseExact("2020-12-15 10:00", "yyyy-MM-dd h:mm", invariantCulture); IReadOnlyList sdResults = intraday .ToVwap(startDate) @@ -127,7 +127,7 @@ public void Exceptions() { // bad SMA period DateTime startDate = - DateTime.ParseExact("2000-12-15", "yyyy-MM-dd", englishCulture); + DateTime.ParseExact("2000-12-15", "yyyy-MM-dd", invariantCulture); Assert.ThrowsException(() => Quotes.ToVwap(startDate));