xml doc rewrite

This commit is contained in:
Miha
2024-10-27 09:38:53 -07:00
parent c21b96152c
commit b2fcdda785
71 changed files with 2607 additions and 1102 deletions
+37 -1
View File
@@ -1,10 +1,39 @@
using System;
namespace QuanTAlib;
/// <summary>
/// WMA: Weighted Moving Average
/// A moving average that assigns linearly decreasing weights to older data points.
/// The most recent price has the highest weight, and each older price receives
/// linearly less weight, creating a more responsive average than SMA.
/// </summary>
/// <remarks>
/// The WMA calculation process:
/// 1. Assigns weights linearly decreasing with age
/// 2. Most recent price gets weight of period
/// 3. Each older price gets decremented weight
/// 4. Normalizes weights by sum of weights
/// 5. Applies weights through convolution
///
/// Key characteristics:
/// - Linear weight distribution
/// - More responsive than SMA
/// - Less lag than SMA
/// - Emphasizes recent prices
/// - Implemented using efficient convolution operations
///
/// Sources:
/// https://www.investopedia.com/articles/technical/060401.asp
/// https://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:weighted_moving_average
/// </remarks>
public class Wma : AbstractBase
{
private readonly int _period;
private readonly Convolution _convolution;
/// <param name="period">The number of data points used in the WMA calculation.</param>
/// <exception cref="ArgumentException">Thrown when period is less than 1.</exception>
public Wma(int period)
{
if (period < 1)
@@ -18,12 +47,19 @@ public class Wma : AbstractBase
Init();
}
/// <param name="source">The data source object that publishes updates.</param>
/// <param name="period">The number of data points used in the WMA calculation.</param>
public Wma(object source, int period) : this(period)
{
var pubEvent = source.GetType().GetEvent("Pub");
pubEvent?.AddEventHandler(source, new ValueSignal(Sub));
}
/// <summary>
/// Generates the linearly weighted convolution kernel for the WMA calculation.
/// </summary>
/// <param name="period">The period for which to generate the kernel.</param>
/// <returns>An array of normalized linearly decreasing weights for the convolution operation.</returns>
private static double[] GenerateWmaKernel(int period)
{
double[] kernel = new double[period];
@@ -64,4 +100,4 @@ public class Wma : AbstractBase
return result;
}
}
}