Skip to content

Commit

Permalink
convert to naming for static series
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveSkender committed Oct 14, 2024
1 parent 5df1ffd commit 70c6d60
Show file tree
Hide file tree
Showing 193 changed files with 1,115 additions and 1,166 deletions.
8 changes: 4 additions & 4 deletions src/_common/ObsoleteV3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,28 @@ public static IEnumerable<EmaResult> GetEma<TQuote>(
public static IEnumerable<AdlResult> GetAdl<TQuote>(
this IEnumerable<TQuote> quotes, int smaPeriods)
where TQuote : IQuote
=> quotes.ToSortedList().CalcAdl();
=> quotes.ToSortedList().ToAdl();

[ExcludeFromCodeCoverage]
[Obsolete("Use a chained `results.GetSma(smaPeriods)` to generate a moving average.", true)] // v3.0.0
public static IEnumerable<ObvResult> GetObv<TQuote>(
this IEnumerable<TQuote> quotes, int smaPeriods)
where TQuote : IQuote
=> quotes.GetObv();
=> quotes.ToObv();

[ExcludeFromCodeCoverage]
[Obsolete("Use a chained `results.GetSma(smaPeriods)` to generate a moving average.", true)] // v3.0.0
public static IEnumerable<PrsResult> GetPrs<TQuote>(
this IEnumerable<TQuote> quotesEval, IEnumerable<TQuote> quotesBase, int lookbackPeriods, int smaPeriods)
where TQuote : IQuote
=> quotesEval.Use(CandlePart.Close).GetPrs(quotesBase.Use(CandlePart.Close), lookbackPeriods);
=> quotesEval.Use(CandlePart.Close).ToPrs(quotesBase.Use(CandlePart.Close), lookbackPeriods);

[ExcludeFromCodeCoverage]
[Obsolete("Use a chained `results.GetSma(smaPeriods)` to generate a moving average.", true)] // v3.0.0
public static IEnumerable<RocResult> GetRoc<TQuote>(
this IEnumerable<TQuote> quotes, int lookbackPeriods, int smaPeriods)
where TQuote : IQuote
=> quotes.Use(CandlePart.Close).GetRoc(lookbackPeriods);
=> quotes.Use(CandlePart.Close).ToRoc(lookbackPeriods);

[ExcludeFromCodeCoverage]
[Obsolete("Use a chained `results.GetSma(smaPeriods)` to generate a moving average.", true)] // v3.0.0
Expand Down
19 changes: 0 additions & 19 deletions src/a-d/Adl/Adl.Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,6 @@ namespace Skender.Stock.Indicators;

public static partial class Adl
{
// SERIES, from TQuote
///<summary>
///Accumulation / Distribution Line(ADL) is a rolling accumulation of Chaikin Money Flow Volume.
///<para>
///See
///<see href="https://dotnet.StockIndicators.dev/indicators/Adl/#content?utm_source=library&amp;utm_medium=inline-help&amp;utm_campaign=embedded"> documentation</see>
///for more information.
///</para>
///</summary>
///<typeparam name = "TQuote" > Configurable Quote type. See Guide for more information.</typeparam>
///<param name="quotes">Historical price quotes.</param>
///<returns>Time series of ADL values.</returns>
public static IReadOnlyList<AdlResult> GetAdl<TQuote>(
this IEnumerable<TQuote> quotes)
where TQuote : IQuote
=> quotes
.ToSortedList()
.CalcAdl();

// OBSERVER, from Quote Provider
public static AdlHub<TIn> ToAdl<TIn>(
this IQuoteProvider<TIn> quoteProvider)
Expand Down
6 changes: 4 additions & 2 deletions src/a-d/Adl/Adl.StaticSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ namespace Skender.Stock.Indicators;

public static partial class Adl
{
internal static List<AdlResult> CalcAdl<TQuote>(
this List<TQuote> source)
public static IReadOnlyList<AdlResult> ToAdl<TQuote>(
this IReadOnlyList<TQuote> source)
where TQuote : IQuote
{
ArgumentNullException.ThrowIfNull(source);

// initialize
int length = source.Count;
List<AdlResult> results = new(length);
Expand Down
4 changes: 2 additions & 2 deletions src/a-d/Adx/Adx.Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ namespace Skender.Stock.Indicators;

// AVERAGE DIRECTIONAL INDEX (API)

public static partial class Indicator
public static partial class Adx
{
// SERIES, from TQuote
/// <include file='./info.xml' path='info/type[@name="standard"]/*' />
///
public static IReadOnlyList<AdxResult> GetAdx<TQuote>(
public static IReadOnlyList<AdxResult> ToAdx<TQuote>(
this IEnumerable<TQuote> quotes,
int lookbackPeriods = 14)
where TQuote : IQuote => quotes
Expand Down
18 changes: 0 additions & 18 deletions src/a-d/Adx/Adx.Common.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/a-d/Adx/Adx.StaticSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace Skender.Stock.Indicators;

// AVERAGE DIRECTIONAL INDEX (SERIES)

public static partial class Indicator
public static partial class Adx
{
private static List<AdxResult> CalcAdx(
this List<QuoteD> source,
Expand Down
14 changes: 13 additions & 1 deletion src/a-d/Adx/Adx.Utilities.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Skender.Stock.Indicators;

public static partial class Indicator
public static partial class Adx
{
// remove recommended periods
/// <inheritdoc cref="Utility.RemoveWarmupPeriods{T}(IReadOnlyList{T})"/>
Expand All @@ -13,4 +13,16 @@ public static IReadOnlyList<AdxResult> RemoveWarmupPeriods(

return results.Remove(2 * n + 100);
}

// parameter validation
internal static void Validate(
int lookbackPeriods)
{
// check parameter arguments
if (lookbackPeriods <= 1)
{
throw new ArgumentOutOfRangeException(nameof(lookbackPeriods), lookbackPeriods,
"Lookback periods must be greater than 1 for ADX.");
}
}
}
2 changes: 1 addition & 1 deletion src/a-d/Alligator/Alligator.Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static partial class Alligator
/// <exception cref="ArgumentOutOfRangeException">
/// Invalid parameter value provided.
/// </exception>
public static IReadOnlyList<AlligatorResult> GetAlligator<T>(
public static IReadOnlyList<AlligatorResult> ToAlligator<T>(
this IEnumerable<T> source,
int jawPeriods = 13,
int jawOffset = 8,
Expand Down
2 changes: 1 addition & 1 deletion src/a-d/Alma/Alma.Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Skender.Stock.Indicators;
public static partial class Indicator
{
// SERIES, from CHAIN
public static IReadOnlyList<AlmaResult> GetAlma<T>(
public static IReadOnlyList<AlmaResult> ToAlma<T>(
this IReadOnlyList<T> results,
int lookbackPeriods = 9,
double offset = 0.85,
Expand Down
4 changes: 2 additions & 2 deletions src/a-d/Aroon/Aroon.Api.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
namespace Skender.Stock.Indicators;

// AROON OSCILLATOR (API)
public static partial class Indicator
public static partial class Aroon
{
// SERIES, from TQuote
/// <include file='./info.xml' path='info/*' />
///
public static IReadOnlyList<AroonResult> GetAroon<TQuote>(
public static IReadOnlyList<AroonResult> ToAroon<TQuote>(
this IEnumerable<TQuote> quotes,
int lookbackPeriods = 25)
where TQuote : IQuote => quotes
Expand Down
19 changes: 0 additions & 19 deletions src/a-d/Aroon/Aroon.Common.cs

This file was deleted.

4 changes: 2 additions & 2 deletions src/a-d/Aroon/Aroon.StaticSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ namespace Skender.Stock.Indicators;

// AROON OSCILLATOR (SERIES)

public static partial class Indicator
public static partial class Aroon
{
private static List<AroonResult> CalcAroon(
this List<QuoteD> source,
int lookbackPeriods)
{
// check parameter arguments
Aroon.Validate(lookbackPeriods);
Validate(lookbackPeriods);

// initialize
int length = source.Count;
Expand Down
14 changes: 13 additions & 1 deletion src/a-d/Aroon/Aroon.Utilities.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Skender.Stock.Indicators;

public static partial class Indicator
public static partial class Aroon
{
// remove recommended periods
/// <inheritdoc cref="Utility.RemoveWarmupPeriods{T}(IReadOnlyList{T})"/>
Expand All @@ -13,4 +13,16 @@ public static IReadOnlyList<AroonResult> RemoveWarmupPeriods(

return results.Remove(removePeriods);
}

// parameter validation
internal static void Validate(
int lookbackPeriods)
{
// check parameter arguments
if (lookbackPeriods <= 0)
{
throw new ArgumentOutOfRangeException(nameof(lookbackPeriods), lookbackPeriods,
"Lookback periods must be greater than 0 for Aroon.");
}
}
}
2 changes: 1 addition & 1 deletion src/a-d/Atr/Atr.Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public static partial class Atr
// SERIES, from TQuote
/// <include file='./info.xml' path='info/*' />
///
public static IReadOnlyList<AtrResult> GetAtr<TQuote>(
public static IReadOnlyList<AtrResult> ToAtr<TQuote>(
this IEnumerable<TQuote> quotes,
int lookbackPeriods = 14)
where TQuote : IQuote => quotes
Expand Down
2 changes: 1 addition & 1 deletion src/a-d/AtrStop/AtrStop.Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public static partial class AtrStop
// SERIES, from TQuote
/// <include file='./info.xml' path='info/*' />
///
public static IReadOnlyList<AtrStopResult> GetAtrStop<TQuote>(
public static IReadOnlyList<AtrStopResult> ToAtrStop<TQuote>(
this IEnumerable<TQuote> quotes,
int lookbackPeriods = 21,
double multiplier = 3,
Expand Down
4 changes: 2 additions & 2 deletions src/a-d/Awesome/Awesome.Api.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
namespace Skender.Stock.Indicators;

// AWESOME OSCILLATOR (API)
public static partial class Indicator
public static partial class Awesome
{
// SERIES, from CHAIN
public static IReadOnlyList<AwesomeResult> GetAwesome<T>(
public static IReadOnlyList<AwesomeResult> ToAwesome<T>(
this IEnumerable<T> source,
int fastPeriods = 5,
int slowPeriods = 34)
Expand Down
26 changes: 0 additions & 26 deletions src/a-d/Awesome/Awesome.Common.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/a-d/Awesome/Awesome.StaticSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace Skender.Stock.Indicators;

// AWESOME OSCILLATOR (SERIES)

public static partial class Indicator
public static partial class Awesome
{
private static List<AwesomeResult> CalcAwesome<T>(
this List<T> source,
Expand Down
21 changes: 20 additions & 1 deletion src/a-d/Awesome/Awesome.Utilities.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Skender.Stock.Indicators;

public static partial class Indicator
public static partial class Awesome
{
// remove recommended periods
/// <inheritdoc cref="Utility.RemoveWarmupPeriods{T}(IReadOnlyList{T})"/>
Expand All @@ -13,4 +13,23 @@ public static IReadOnlyList<AwesomeResult> RemoveWarmupPeriods(

return results.Remove(removePeriods);
}

// parameter validation
internal static void Validate(
int fastPeriods,
int slowPeriods)
{
// check parameter arguments
if (fastPeriods <= 0)
{
throw new ArgumentOutOfRangeException(nameof(slowPeriods), slowPeriods,
"Fast periods must be greater than 0 for Awesome Oscillator.");
}

if (slowPeriods <= fastPeriods)
{
throw new ArgumentOutOfRangeException(nameof(slowPeriods), slowPeriods,
"Slow periods must be larger than Fast Periods for Awesome Oscillator.");
}
}
}
4 changes: 2 additions & 2 deletions src/a-d/Beta/Beta.Api.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
namespace Skender.Stock.Indicators;

// BETA COEFFICIENT (API)
public static partial class Indicator
public static partial class Beta
{
// SERIES, from CHAINS (both inputs reusable)
public static IReadOnlyList<BetaResult> GetBeta<T>(
public static IReadOnlyList<BetaResult> ToBeta<T>(
this IEnumerable<T> evalSource,
IEnumerable<T> mrktSource,
int lookbackPeriods,
Expand Down
30 changes: 0 additions & 30 deletions src/a-d/Beta/Beta.Common.cs

This file was deleted.

4 changes: 2 additions & 2 deletions src/a-d/Beta/Beta.StaticSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace Skender.Stock.Indicators;

// BETA COEFFICIENT (SERIES)

public static partial class Indicator
public static partial class Beta
{
// NOTE: sequence swapped from API
private static List<BetaResult> CalcBeta<T>(
Expand Down Expand Up @@ -146,7 +146,7 @@ private static List<BetaResult> CalcBeta<T>(
}

// calculate correlation, covariance, and variance
CorrResult c = PeriodCorrelation(
CorrResult c = Correlation.PeriodCorrelation(
default,
[.. dataA],
[.. dataB]);
Expand Down
Loading

0 comments on commit 70c6d60

Please sign in to comment.