mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-15 17:18:05 +00:00
xml doc rewrite
This commit is contained in:
+37
-1
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user