mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-16 01:28:05 +00:00
xml doc rewrite
This commit is contained in:
+34
-1
@@ -1,9 +1,35 @@
|
||||
using System;
|
||||
namespace QuanTAlib;
|
||||
|
||||
/// <summary>
|
||||
/// FWMA: Fibonacci Weighted Moving Average
|
||||
/// A moving average that uses Fibonacci numbers as weights in its calculation. The weights
|
||||
/// are arranged in reverse order so that recent prices receive higher weights corresponding
|
||||
/// to larger Fibonacci numbers.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The FWMA calculation process:
|
||||
/// 1. Generates a Fibonacci sequence up to the specified period
|
||||
/// 2. Reverses the sequence to give higher weights to recent prices
|
||||
/// 3. Normalizes the weights to sum to 1
|
||||
/// 4. Applies the weights through convolution
|
||||
///
|
||||
/// Key characteristics:
|
||||
/// - Uses Fibonacci sequence for weight distribution
|
||||
/// - Recent prices receive higher weights
|
||||
/// - Natural progression of weights based on the golden ratio
|
||||
/// - Implemented using efficient convolution operations
|
||||
///
|
||||
/// Implementation:
|
||||
/// Original implementation based on Fibonacci sequence principles
|
||||
/// </remarks>
|
||||
|
||||
public class Fwma : AbstractBase
|
||||
{
|
||||
private readonly Convolution _convolution;
|
||||
|
||||
/// <param name="period">The number of data points used in the FWMA calculation.</param>
|
||||
/// <exception cref="ArgumentException">Thrown when period is less than 1.</exception>
|
||||
public Fwma(int period)
|
||||
{
|
||||
if (period < 1)
|
||||
@@ -16,12 +42,19 @@ public class Fwma : AbstractBase
|
||||
Init();
|
||||
}
|
||||
|
||||
/// <param name="source">The data source object that publishes updates.</param>
|
||||
/// <param name="period">The number of data points used in the FWMA calculation.</param>
|
||||
public Fwma(object source, int period) : this(period)
|
||||
{
|
||||
var pubEvent = source.GetType().GetEvent("Pub");
|
||||
pubEvent?.AddEventHandler(source, new ValueSignal(Sub));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates the Fibonacci-based convolution kernel for the FWMA calculation.
|
||||
/// </summary>
|
||||
/// <param name="period">The period for which to generate the kernel.</param>
|
||||
/// <returns>An array of normalized Fibonacci-based weights for the convolution operation.</returns>
|
||||
public static double[] GenerateKernel(int period)
|
||||
{
|
||||
double[] kernel = new double[period];
|
||||
@@ -78,4 +111,4 @@ public class Fwma : AbstractBase
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user