diff --git a/src/a-d/Adl/Adl.Api.cs b/src/a-d/Adl/Adl.Api.cs index 578643174..15a55c42e 100644 --- a/src/a-d/Adl/Adl.Api.cs +++ b/src/a-d/Adl/Adl.Api.cs @@ -12,4 +12,13 @@ public static IEnumerable GetAdl( where TQuote : IQuote => quotes .ToQuoteD() .CalcAdl(smaPeriods); + + // TASK, from TQuote + /// + /// + public static Task> GetAdlAsync( + this IEnumerable quotes, + int? smaPeriods = null) + where TQuote : IQuote => Task.Run(() => quotes + .GetAdl(smaPeriods)); } diff --git a/tests/indicators/a-d/Adl/Adl.Tests.cs b/tests/indicators/a-d/Adl/Adl.Tests.cs index a0a21f4b0..2540ab988 100644 --- a/tests/indicators/a-d/Adl/Adl.Tests.cs +++ b/tests/indicators/a-d/Adl/Adl.Tests.cs @@ -32,6 +32,31 @@ public void Standard() Assert.AreEqual(null, r2.AdlSma); } + [TestMethod] + public async Task Async() + { + List ogList = quotes + .GetAdl() + .ToList(); + + IEnumerable results = await quotes + .GetAdlAsync() + .ConfigureAwait(false); + + List rsList = results.ToList(); + + Assert.AreEqual(ogList.Count, rsList.Count); + + for (int i = 0; i < rsList.Count; i++) + { + AdlResult o = ogList[i]; + AdlResult r = rsList[i]; + + Assert.AreEqual(o.Date, r.Date); + Assert.AreEqual(o.Adl, r.Adl); + } + } + [TestMethod] public void WithSma() {