mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-22 04:28:04 +00:00
tests and cleanup
This commit is contained in:
@@ -7,15 +7,37 @@ namespace QuanTAlib;
|
||||
/// The Slope class calculates the slope of a linear regression line, along with other
|
||||
/// statistical measures such as intercept, standard deviation, R-squared, and the last
|
||||
/// point on the regression line. It uses the least squares method for calculation.
|
||||
///
|
||||
/// In financial analysis, slope is important for:
|
||||
/// - Identifying trends in price movements or other financial metrics.
|
||||
/// - Measuring the rate of change in a financial time series.
|
||||
/// - Assessing the strength and direction of relationships between variables.
|
||||
/// - Supporting technical analysis indicators and trading strategies.
|
||||
/// </remarks>
|
||||
public class Slope : AbstractBase
|
||||
{
|
||||
private readonly int _period;
|
||||
private readonly CircularBuffer _buffer;
|
||||
private readonly CircularBuffer _timeBuffer;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the y-intercept of the regression line.
|
||||
/// </summary>
|
||||
public double? Intercept { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the standard deviation of the y-values.
|
||||
/// </summary>
|
||||
public double? StdDev { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the R-squared value, indicating the goodness of fit of the regression line.
|
||||
/// </summary>
|
||||
public double? RSquared { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the y-value of the last point on the regression line.
|
||||
/// </summary>
|
||||
public double? Line { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -90,6 +112,13 @@ public class Slope : AbstractBase
|
||||
/// It also calculates and updates the Intercept, StdDev, RSquared, and Line properties.
|
||||
/// If there are fewer than 2 data points, or if the sum of squared x deviations is 0,
|
||||
/// the method returns 0 and sets the additional properties to null.
|
||||
///
|
||||
/// Interpretation of results:
|
||||
/// - Positive slope: Indicates an upward trend in the data.
|
||||
/// - Negative slope: Indicates a downward trend in the data.
|
||||
/// - Slope close to 0: Indicates a relatively flat or no clear trend in the data.
|
||||
/// The magnitude of the slope represents the rate of change in the dependent variable
|
||||
/// (y) for each unit change in the independent variable (x).
|
||||
/// </remarks>
|
||||
protected override double Calculation()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user