mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-07-27 17:27:43 +00:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -22,7 +22,7 @@ public class StatisticsUpdateTests
|
||||
double open = GetRandomDouble();
|
||||
double high = open + Math.Abs(GetRandomDouble());
|
||||
double low = open - Math.Abs(GetRandomDouble());
|
||||
double close = low + (high - low) * GetRandomDouble();
|
||||
double close = low + ((high - low) * GetRandomDouble());
|
||||
return new TBar(DateTime.Now, open, high, low, close, 1000, IsNew);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,6 @@ namespace QuanTAlib;
|
||||
///
|
||||
/// Note: Returns a value between 0 and 1
|
||||
/// </remarks>
|
||||
|
||||
[SkipLocalsInit]
|
||||
public sealed class Hurst : AbstractBase
|
||||
{
|
||||
@@ -184,7 +183,7 @@ public sealed class Hurst : AbstractBase
|
||||
double hurst = 0.5; // Default to random walk
|
||||
if (numPoints > 1)
|
||||
{
|
||||
double slope = (numPoints * sumXY - sumX * sumY) / (numPoints * sumX2 - sumX * sumX);
|
||||
double slope = ((numPoints * sumXY) - (sumX * sumY)) / ((numPoints * sumX2) - (sumX * sumX));
|
||||
hurst = Math.Max(0, Math.Min(1, slope)); // Clamp between 0 and 1
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ namespace QuanTAlib;
|
||||
///
|
||||
/// Note: Returns three values: upper, middle, and lower bands
|
||||
/// </remarks>
|
||||
|
||||
[SkipLocalsInit]
|
||||
public sealed class Bband : AbstractBase
|
||||
{
|
||||
|
||||
@@ -36,7 +36,6 @@ namespace QuanTAlib;
|
||||
///
|
||||
/// Note: Returns annualized volatility as a percentage
|
||||
/// </remarks>
|
||||
|
||||
[SkipLocalsInit]
|
||||
public sealed class Ccv : AbstractBase
|
||||
{
|
||||
|
||||
@@ -38,7 +38,6 @@ namespace QuanTAlib;
|
||||
///
|
||||
/// Note: Returns two values: long exit and short exit levels
|
||||
/// </remarks>
|
||||
|
||||
[SkipLocalsInit]
|
||||
public sealed class Ce : AbstractBase
|
||||
{
|
||||
|
||||
@@ -43,7 +43,6 @@ namespace QuanTAlib;
|
||||
///
|
||||
/// Note: Returns annualized volatility as a percentage
|
||||
/// </remarks>
|
||||
|
||||
[SkipLocalsInit]
|
||||
public sealed class Cv : AbstractBase
|
||||
{
|
||||
@@ -126,7 +125,7 @@ public sealed class Cv : AbstractBase
|
||||
}
|
||||
|
||||
// Update variance estimate using GARCH(1,1)
|
||||
double variance = _omega + _alpha * squaredReturn + _beta * _prevVariance;
|
||||
double variance = _omega + (_alpha * squaredReturn) + (_beta * _prevVariance);
|
||||
_prevVariance = variance;
|
||||
|
||||
// Calculate annualized volatility as percentage
|
||||
|
||||
@@ -41,7 +41,6 @@ namespace QuanTAlib;
|
||||
///
|
||||
/// Note: Returns annualized volatility as a percentage
|
||||
/// </remarks>
|
||||
|
||||
[SkipLocalsInit]
|
||||
public sealed class Ewma : AbstractBase
|
||||
{
|
||||
@@ -121,7 +120,7 @@ public sealed class Ewma : AbstractBase
|
||||
}
|
||||
|
||||
// Update EWMA
|
||||
_ewma = _lambda * _ewma + (1 - _lambda) * squaredReturn;
|
||||
_ewma = (_lambda * _ewma) + ((1 - _lambda) * squaredReturn);
|
||||
|
||||
// Calculate volatility
|
||||
double volatility = Math.Sqrt(_ewma);
|
||||
|
||||
@@ -38,7 +38,6 @@ namespace QuanTAlib;
|
||||
///
|
||||
/// Note: Returns three values: upper, middle, and lower bands
|
||||
/// </remarks>
|
||||
|
||||
[SkipLocalsInit]
|
||||
public sealed class Fcb : AbstractBase
|
||||
{
|
||||
@@ -134,8 +133,8 @@ public sealed class Fcb : AbstractBase
|
||||
}
|
||||
|
||||
// Apply smoothing to bands
|
||||
_upperBand = _smoothing * _upperEma + (1 - _smoothing) * BarInput.High;
|
||||
_lowerBand = _smoothing * _lowerEma + (1 - _smoothing) * BarInput.Low;
|
||||
_upperBand = (_smoothing * _upperEma) + ((1 - _smoothing) * BarInput.High);
|
||||
_lowerBand = (_smoothing * _lowerEma) + ((1 - _smoothing) * BarInput.Low);
|
||||
_middleBand = (_upperBand + _lowerBand) / 2;
|
||||
|
||||
IsHot = _index >= WarmupPeriod;
|
||||
|
||||
@@ -38,7 +38,6 @@ namespace QuanTAlib;
|
||||
///
|
||||
/// Note: Returns annualized volatility as a percentage
|
||||
/// </remarks>
|
||||
|
||||
[SkipLocalsInit]
|
||||
public sealed class Gkv : AbstractBase
|
||||
{
|
||||
@@ -97,7 +96,7 @@ public sealed class Gkv : AbstractBase
|
||||
c = c * c;
|
||||
|
||||
// Combine components with optimal weights
|
||||
double component = 0.5 * u - (2 * _ln2 - 1) * c;
|
||||
double component = (0.5 * u) - (((2 * _ln2) - 1) * c);
|
||||
_components.Add(component);
|
||||
|
||||
// Need enough values for calculation
|
||||
|
||||
@@ -37,7 +37,6 @@ namespace QuanTAlib;
|
||||
///
|
||||
/// Note: Returns annualized volatility as a percentage
|
||||
/// </remarks>
|
||||
|
||||
[SkipLocalsInit]
|
||||
public sealed class Hlv : AbstractBase
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user