Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
hmG3 committed Aug 29, 2024
1 parent f60bcd0 commit cf2cb21
Show file tree
Hide file tree
Showing 8 changed files with 242 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/TALib.NETCore/Core/CandleSettingType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public enum CandleSettingType

/// <summary>
/// When measuring distance between parts of candles or width of gaps.
/// "equal" means "<=5% of the average of the 5 previous candles' high-low range"
/// "equal" means "5% of the average of the 5 previous candles' high-low range"
/// </summary>
Equal
}
Expand Down
43 changes: 43 additions & 0 deletions src/TALib.NETCore/Functions/TA_Accbands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,44 @@ namespace TALib;

public static partial class Functions
{
/// <summary>
/// Acceleration Bands (Volume Indicators)
/// </summary>
/// <typeparam name="T">
/// The numeric data type, typically <see cref="float"/> or <see cref="double"/>,
/// implementing the <see cref="IFloatingPointIeee754{T}"/> interface.
/// </typeparam>
/// <param name="inHigh">A span of input high prices.</param>
/// <param name="inLow">A span of input low prices.</param>
/// <param name="inClose">A span of input close prices.</param>
/// <param name="inRange">A range of indices that determines the portion of data to be calculated within the input spans.</param>
/// <param name="outRealUpperBand">The span in which to store the calculated upper band values.</param>
/// <param name="outRealMiddleBand">The span in which to store the calculated middle band values.</param>
/// <param name="outRealLowerBand">The span in which to store the calculated lower band values.</param>
/// <param name="outRange">The range of indices that represent the valid portion of values within the output spans.</param>
/// <param name="optInTimePeriod">The time period.</param>
/// <returns>
/// A <see cref="Core.RetCode"/> value indicating the success or failure of the calculation.
/// Returns <see cref="Core.RetCode.Success"/> on successful calculation, or an appropriate error code otherwise.
/// </returns>
/// <remarks>
/// Acceleration Bands are a type of volatility indicator that expands and contracts based on the price movement.
/// They are used to determine potential breakout points and to measure the strength of the trend.
/// <para>
/// The calculation involves the following steps:
/// <list type="number">
/// <item>
/// <description>Calculate the upper and lower bands based on the high and low prices adjusted by a factor.</description>
/// </item>
/// <item>
/// <description>Compute the simple moving average (SMA) of the close prices to form the middle band.</description>
/// </item>
/// <item>
/// <description>Apply the SMA to the upper and lower bands to smooth them out.</description>
/// </item>
/// </list>
/// </para>
/// </remarks>
[PublicAPI]
public static Core.RetCode Accbands<T>(

Check warning on line 64 in src/TALib.NETCore/Functions/TA_Accbands.cs

View workflow job for this annotation

GitHub Actions / analyze (ubuntu-latest)

Method has 9 parameters, which is greater than the 7 authorized. (https://rules.sonarsource.com/csharp/RSPEC-107)
ReadOnlySpan<T> inHigh,
Expand All @@ -35,6 +73,11 @@ public static Core.RetCode Accbands<T>(
int optInTimePeriod = 20) where T : IFloatingPointIeee754<T> =>
AccbandsImpl(inHigh, inLow, inClose, inRange, outRealUpperBand, outRealMiddleBand, outRealLowerBand, out outRange, optInTimePeriod);

/// <summary>
/// Returns the lookback period for <see cref="Accbands{T}"/>.
/// </summary>
/// <param name="optInTimePeriod">The time period.</param>
/// <returns>The number of periods required before the first output value can be calculated.</returns>
[PublicAPI]
public static int AccbandsLookback(int optInTimePeriod = 20) => optInTimePeriod < 2 ? -1 : SmaLookback(optInTimePeriod);

Expand Down
22 changes: 22 additions & 0 deletions src/TALib.NETCore/Functions/TA_Acos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ namespace TALib;

public static partial class Functions
{
/// <summary>
/// Vector Trigonometric ACos (Math Transform)
/// </summary>
/// <typeparam name="T">
/// The numeric data type, typically <see cref="float"/> or <see cref="double"/>,
/// implementing the <see cref="IFloatingPointIeee754{T}"/> interface.
/// </typeparam>
/// <param name="inReal">A span of input values.</param>
/// <param name="inRange">A range of indices that determines the portion of data to be calculated within the input span.</param>
/// <param name="outReal">The span in which to store the calculated values.</param>
/// <param name="outRange">The range of indices that represent the valid portion of data within the output span.</param>
/// <returns>
/// A <see cref="Core.RetCode"/> value indicating the success or failure of the calculation.
/// Returns <see cref="Core.RetCode.Success"/> on successful calculation, or an appropriate error code otherwise.
/// </returns>
/// <remarks>
/// The arc cosine is the inverse function of the cosine, returning the angle in radians whose cosine is the input value.
/// </remarks>
[PublicAPI]
public static Core.RetCode Acos<T>(
ReadOnlySpan<T> inReal,
Expand All @@ -30,6 +48,10 @@ public static Core.RetCode Acos<T>(
out Range outRange) where T : IFloatingPointIeee754<T> =>
AcosImpl(inReal, inRange, outReal, out outRange);

/// <summary>
/// Returns the lookback period for <see cref="Acos{T}"/>.
/// </summary>
/// <returns>Always 0 since no historical data is required for this calculation.</returns>
[PublicAPI]
public static int AcosLookback() => 0;

Check warning on line 56 in src/TALib.NETCore/Functions/TA_Acos.cs

View workflow job for this annotation

GitHub Actions / analyze (ubuntu-latest)

Remove this method and declare a constant for this value. (https://rules.sonarsource.com/csharp/RSPEC-3400)

Expand Down
32 changes: 32 additions & 0 deletions src/TALib.NETCore/Functions/TA_Ad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,34 @@ namespace TALib;

public static partial class Functions
{
/// <summary>
/// Chaikin A/D Line (Volume Indicators)
/// </summary>
/// <typeparam name="T">
/// The numeric data type, typically <see cref="float"/> or <see cref="double"/>,
/// implementing the <see cref="IFloatingPointIeee754{T}"/> interface.
/// </typeparam>
/// <param name="inHigh">A span of input high prices.</param>
/// <param name="inLow">A span of input low prices.</param>
/// <param name="inClose">A span of input close prices.</param>
/// <param name="inVolume">A span of input volume data.</param>
/// <param name="inRange">A range of indices that determines the portion of data to be calculated within the input spans.</param>
/// <param name="outReal">The span in which to store the calculated values.</param>
/// <param name="outRange">The range of indices that represent the valid portion of data within the output span.</param>
/// <returns>
/// A <see cref="Core.RetCode"/> value indicating the success or failure of the calculation.
/// Returns <see cref="Core.RetCode.Success"/> on successful calculation, or an appropriate error code otherwise.
/// </returns>
/// <remarks>
/// The function computes the Accumulation/Distribution line by calculating the cumulative flow of money into and out of the security.
/// The formula takes into account the high, low, and close prices, as well as the volume, to assess the buying and selling pressure.
/// This indicator can help in identifying divergences between price and volume,
/// which may indicate potential changes in the market trend.
/// <para>
/// Due to the nature of cumulative calculations, using double precision is recommended for better accuracy,
/// especially when dealing with large datasets.
/// </para>
/// </remarks>
[PublicAPI]
public static Core.RetCode Ad<T>(
ReadOnlySpan<T> inHigh,
Expand All @@ -33,6 +61,10 @@ public static Core.RetCode Ad<T>(
out Range outRange) where T : IFloatingPointIeee754<T> =>
AdImpl(inHigh, inLow, inClose, inVolume, inRange, outReal, out outRange);

/// <summary>
/// Returns the lookback period for <see cref="Ad{T}"/>.
/// </summary>
/// <returns>Always 0 since no historical data is required for this calculation.</returns>
[PublicAPI]
public static int AdLookback() => 0;

Check warning on line 69 in src/TALib.NETCore/Functions/TA_Ad.cs

View workflow job for this annotation

GitHub Actions / analyze (ubuntu-latest)

Remove this method and declare a constant for this value. (https://rules.sonarsource.com/csharp/RSPEC-3400)

Expand Down
35 changes: 35 additions & 0 deletions src/TALib.NETCore/Functions/TA_AdOsc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,35 @@ namespace TALib;

public static partial class Functions
{
/// <summary>
/// Chaikin A/D Oscillator (Volume Indicators)
/// </summary>
/// <typeparam name="T">
/// The numeric data type, typically <see cref="float"/> or <see cref="double"/>,
/// implementing the <see cref="IFloatingPointIeee754{T}"/> interface.
/// </typeparam>
/// <param name="inHigh">A span of input high prices.</param>
/// <param name="inLow">A span of input low prices.</param>
/// <param name="inClose">A span of input close prices.</param>
/// <param name="inVolume">A span of input volume data.</param>
/// <param name="inRange">A range of indices that determines the portion of data to be calculated within the input spans.</param>
/// <param name="outReal">The span in which to store the calculated values.</param>
/// <param name="outRange">The range of indices representing the valid values within the output span.</param>
/// <param name="optInFastPeriod">The time period for the fast moving average.</param>
/// <param name="optInSlowPeriod">The time period for the slow moving average.</param>
/// <returns>
/// A <see cref="Core.RetCode"/> value indicating the success or failure of the calculation.
/// Returns <see cref="Core.RetCode.Success"/> on successful calculation, or an appropriate error code otherwise.
/// </returns>
/// <remarks>
/// The function computes the Chaikin Accumulation/Distribution Oscillator,
/// which is the difference between two EMAs of the Accumulation/Distribution line.
/// The oscillator is used to identify momentum in the market by comparing short-term and long-term buying and selling pressure.
/// <para>
/// Note that depending on the specified periods, the "fastEMA" may not always be faster than the "slowEMA" in practice,
/// but the calculation logic remains consistent.
/// </para>
/// </remarks>
[PublicAPI]
public static Core.RetCode AdOsc<T>(
ReadOnlySpan<T> inHigh,
Expand All @@ -35,6 +64,12 @@ public static Core.RetCode AdOsc<T>(
int optInSlowPeriod = 10) where T : IFloatingPointIeee754<T> =>
AdOscImpl(inHigh, inLow, inClose, inVolume, inRange, outReal, out outRange, optInFastPeriod, optInSlowPeriod);

/// <summary>
/// Returns the lookback period for <see cref="AdOsc{T}"/>.
/// </summary>
/// <param name="optInFastPeriod">The time period for the fast moving average.</param>
/// <param name="optInSlowPeriod">The time period for the slow moving average.</param>
/// <returns>The number of periods required before the first output value can be calculated.</returns>
[PublicAPI]
public static int AdOscLookback(int optInFastPeriod = 3, int optInSlowPeriod = 10)
{
Expand Down
23 changes: 23 additions & 0 deletions src/TALib.NETCore/Functions/TA_Add.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,25 @@ namespace TALib;

public static partial class Functions
{
/// <summary>
/// Vector Arithmetic Add (Math Operators)
/// </summary>
/// <typeparam name="T">
/// The numeric data type, typically <see cref="float"/> or <see cref="double"/>,
/// implementing the <see cref="IFloatingPointIeee754{T}"/> interface.
/// </typeparam>
/// <param name="inReal0">The first span of input values.</param>
/// <param name="inReal1">The second span of input values.</param>
/// <param name="inRange">A range of indices that determines the portion of data to be calculated within the input spans.</param>
/// <param name="outReal">The span in which to store the calculated values.</param>
/// <param name="outRange">The range of indices that represent the valid portion of data within the output span.</param>
/// <returns>
/// A <see cref="Core.RetCode"/> value indicating the success or failure of the calculation.
/// Returns <see cref="Core.RetCode.Success"/> on successful calculation, or an appropriate error code otherwise.
/// </returns>
/// <remarks>
/// The function computes the element-wise addition of two input spans, storing the results in the output span.
/// </remarks>
[PublicAPI]
public static Core.RetCode Add<T>(
ReadOnlySpan<T> inReal0,
Expand All @@ -31,6 +50,10 @@ public static Core.RetCode Add<T>(
out Range outRange) where T : IFloatingPointIeee754<T> =>
AddImpl(inReal0, inReal1, inRange, outReal, out outRange);

/// <summary>
/// Returns the lookback period for <see cref="Add{T}"/>.
/// </summary>
/// <returns>Always 0 since no historical data is required for this calculation.</returns>
[PublicAPI]
public static int AddLookback() => 0;

Check warning on line 58 in src/TALib.NETCore/Functions/TA_Add.cs

View workflow job for this annotation

GitHub Actions / analyze (ubuntu-latest)

Remove this method and declare a constant for this value. (https://rules.sonarsource.com/csharp/RSPEC-3400)

Expand Down
45 changes: 45 additions & 0 deletions src/TALib.NETCore/Functions/TA_Adx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,46 @@ namespace TALib;

public static partial class Functions
{
/// <summary>
/// Average Directional Movement Index (Momentum Indicators)
/// </summary>
/// <typeparam name="T">
/// The numeric data type, typically <see cref="float"/> or <see cref="double"/>,
/// implementing the <see cref="IFloatingPointIeee754{T}"/> interface.
/// </typeparam>
/// <param name="inHigh">A span of input high prices.</param>
/// <param name="inLow">A span of input low prices.</param>
/// <param name="inClose">A span of input close prices.</param>
/// <param name="inRange">A range of indices that determines the portion of data to be calculated within the input spans.</param>
/// <param name="outReal">The span in which to store the calculated values.</param>
/// <param name="outRange">The range of indices representing the valid values within the output span.</param>
/// <param name="optInTimePeriod">The time period.</param>
/// <returns>
/// A <see cref="Core.RetCode"/> value indicating the success or failure of the calculation.
/// Returns <see cref="Core.RetCode.Success"/> on successful calculation, or an appropriate error code otherwise.
/// </returns>
/// <remarks>
/// The function calculates the Average Directional Index, which is a measure of trend strength.
/// It does not indicate trend direction, only the strength of the trend.
/// The ADX is derived from the smoothed averages of the difference between +DI and -DI.
/// <para>
/// The ADX calculation involves several steps:
/// <list type="number">
/// <item>
/// <description>Calculate the True Range (TR), +DM (Directional Movement), and -DM for the specified time period.</description>
/// </item>
/// <item>
/// <description>Compute the smoothed averages of +DM and -DM, and then calculate the +DI and -DI.</description>
/// </item>
/// <item>
/// <description>Calculate the DX (Directional Index) from the difference between +DI and -DI.</description>
/// </item>
/// <item>
/// <description>Finally, compute the ADX as the smoothed average of the DX values.</description>
/// </item>
/// </list>
/// </para>
/// </remarks>
[PublicAPI]
public static Core.RetCode Adx<T>(
ReadOnlySpan<T> inHigh,
Expand All @@ -33,6 +73,11 @@ public static Core.RetCode Adx<T>(
int optInTimePeriod = 14) where T : IFloatingPointIeee754<T> =>
AdxImpl(inHigh, inLow, inClose, inRange, outReal, out outRange, optInTimePeriod);

/// <summary>
/// Returns the lookback period for <see cref="Adx{T}"/>.
/// </summary>
/// <param name="optInTimePeriod">The time period.</param>
/// <returns>The number of periods required before the first output value can be calculated.</returns>
[PublicAPI]
public static int AdxLookback(int optInTimePeriod = 14) =>
optInTimePeriod < 2 ? -1 : optInTimePeriod * 2 + Core.UnstablePeriodSettings.Get(Core.UnstableFunc.Adx) - 1;
Expand Down
41 changes: 41 additions & 0 deletions src/TALib.NETCore/Functions/TA_Adxr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,42 @@ namespace TALib;

public static partial class Functions
{
/// <summary>
/// Average Directional Movement Index Rating (Momentum Indicators)
/// </summary>
/// <typeparam name="T">
/// The numeric data type, typically <see cref="float"/> or <see cref="double"/>,
/// implementing the <see cref="IFloatingPointIeee754{T}"/> interface.
/// </typeparam>
/// <param name="inHigh">A span of input high prices.</param>
/// <param name="inLow">A span of input low prices.</param>
/// <param name="inClose">A span of input close prices.</param>
/// <param name="inRange">A range of indices that determines the portion of data to be calculated within the input spans.</param>
/// <param name="outReal">The span in which to store the calculated values.</param>
/// <param name="outRange">The range of indices representing the valid values within the output span.</param>
/// <param name="optInTimePeriod">The time period.</param>
/// <returns>
/// A <see cref="Core.RetCode"/> value indicating the success or failure of the calculation.
/// Returns <see cref="Core.RetCode.Success"/> on successful calculation, or an appropriate error code otherwise.
/// </returns>
/// <remarks>
/// The function computes the Average Directional Movement Rating,
/// which is essentially the average of the current ADX value and the ADX value from the previous time period.
/// This indicator is designed to smooth out the ADX and make it less sensitive to small fluctuations,
/// providing a more stable measure of trend strength.
/// <para>
/// The calculation steps are as follows:
/// <list type="number">
/// <item>
/// <description>First, the ADX values are computed for the required period.</description>
/// </item>
/// <item>
/// <description>The ADXR is then calculated by averaging the current ADX value with the ADX value from a previous period
/// (typically one period earlier).</description>
/// </item>
/// </list>
/// </para>
/// </remarks>
[PublicAPI]
public static Core.RetCode Adxr<T>(
ReadOnlySpan<T> inHigh,
Expand All @@ -33,6 +69,11 @@ public static Core.RetCode Adxr<T>(
int optInTimePeriod = 14) where T : IFloatingPointIeee754<T> =>
AdxrImpl(inHigh, inLow, inClose, inRange, outReal, out outRange, optInTimePeriod);

/// <summary>
/// Returns the lookback period for <see cref="Adxr{T}"/>.
/// </summary>
/// <param name="optInTimePeriod">The time period.</param>
/// <returns>The number of periods required before the first output value can be calculated.</returns>
[PublicAPI]
public static int AdxrLookback(int optInTimePeriod = 14) =>
optInTimePeriod < 2 ? -1 : optInTimePeriod + AdxLookback(optInTimePeriod) - 1;
Expand Down

0 comments on commit cf2cb21

Please sign in to comment.