Add Yang-Zhang Volatility (YZV) Indicator Implementation

- Introduced YZV class for calculating Yang-Zhang Volatility, a comprehensive volatility measure that incorporates overnight, open-to-close, and high-low components.
- Implemented calculation methods, including batch processing for TBarSeries and spans.
- Added documentation for YZV, detailing its mathematical foundation, performance profile, and trading applications.
- Updated volume index documentation to reflect changes in file paths.
- Refactored VWMA calculation method to use a more generic source parameter instead of price.
This commit is contained in:
Miha Kralj
2026-02-02 19:47:21 -08:00
parent a03d7aa0ce
commit c034cbd5e5
78 changed files with 16662 additions and 366 deletions
+26 -26
View File
@@ -6,29 +6,29 @@ Volume is market fuel. Price tells what happened; volume tells how hard the mark
| Indicator | Full Name | Description |
| :--- | :--- | :--- |
| [ADL](/lib/volume/adl/Adl.md) | Accumulation/Distribution Line | Correlates price location within range to volume. Grandfather of volume flow analysis. |
| [ADOSC](/lib/volume/adosc/Adosc.md) | Chaikin A/D Oscillator | Momentum indicator for AD Line. Predicts reversals by measuring acceleration of money flow. |
| [AOBV](/lib/volume/aobv/Aobv.md) | Archer On-Balance Volume | Dual EMA smoothing of OBV for cleaner crossover signals. |
| [CMF](/lib/volume/cmf/Cmf.md) | Chaikin Money Flow | Measures money flow volume over set period (typically 20-21 days). |
| [EFI](/lib/volume/efi/Efi.md) | Elder's Force Index | Combines price movement, direction, volume to measure buying/selling power. |
| [EOM](/lib/volume/eom/Eom.md) | Ease of Movement | Relates price change to volume. Highlights periods of effortless price movement. |
| [III](/lib/volume/iii/Iii.md) | Intraday Intensity Index | Measures buying/selling pressure within day's range using close position. |
| [KVO](/lib/volume/kvo/Kvo.md) | Klinger Volume Oscillator | Compares short-term and long-term volume trends to identify potential reversals. |
| [MFI](/lib/volume/mfi/Mfi.md) | Money Flow Index | Volume-weighted RSI. Measures buying/selling pressure using price and volume. |
| [NVI](/lib/volume/nvi/Nvi.md) | Negative Volume Index | Tracks price changes on lower volume days. Assumes smart money acts on quiet days. |
| [OBV](/lib/volume/obv/Obv.md) | On Balance Volume | Fundamental volume indicator. Cumulative volume based on price direction. |
| [PVD](/lib/volume/pvd/Pvd.md) | Price Volume Divergence | Systematic divergence detection between price and volume movements. |
| [PVI](/lib/volume/pvi/Pvi.md) | Positive Volume Index | Tracks price changes on higher volume days. Assumes crowd behavior. |
| [PVO](/lib/volume/pvo/Pvo.md) | Percentage Volume Oscillator | Compares short-term and long-term volume moving averages as percentages. |
| [PVR](/lib/volume/pvr/Pvr.md) | Price Volume Rank | Categorical indicator returning 0-4 based on combined price and volume direction. |
| [PVT](/lib/volume/pvt/Pvt.md) | Price Volume Trend | Cumulative volume adjusted by relative price changes. Similar to OBV but magnitude-weighted. |
| [TVI](/lib/volume/tvi/Tvi.md) | Trade Volume Index | Cumulative volume with sticky direction based on minimum tick threshold. Filters noise from OBV. |
| [TWAP](/lib/volume/twap/Twap.md) | Time Weighted Average Price | Average price weighted equally by time. Used as execution benchmark. |
| [VA](/lib/volume/va/Va.md) | Volume Accumulation | Cumulative volume adjusted by close position relative to range midpoint. |
| [VF](/lib/volume/vf/Vf.md) | Volume Force | Measures force of volume behind price movements using EMA smoothing. |
| [VO](/lib/volume/vo/Vo.md) | Volume Oscillator | Difference between short and long volume moving averages. Shows volume momentum. |
| [VROC](/lib/volume/vroc/Vroc.md) | Volume Rate of Change | Measures speed at which volume is changing over time. |
| [VWAD](/lib/volume/vwad/Vwad.md) | Volume Weighted A/D | Similar to ADL but weights accumulation/distribution by volume. |
| [VWAP](/lib/volume/vwap/Vwap.md) | Volume Weighted Average Price | Average price weighted by volume. Common execution benchmark and intraday reference. |
| [VWMA](/lib/volume/vwma/Vwma.md) | Volume Weighted Moving Average | Moving average where each price point is weighted by its volume over a sliding window. |
| [WAD](/lib/volume/wad/Wad.md) | Williams Accumulation/Distribution | Measures cumulative buying/selling pressure using True Range and volume. |
| [ADL](adl/Adl.md) | Accumulation/Distribution Line | Correlates price location within range to volume. Grandfather of volume flow analysis. |
| [ADOSC](adosc/Adosc.md) | Chaikin A/D Oscillator | Momentum indicator for AD Line. Predicts reversals by measuring acceleration of money flow. |
| [AOBV](aobv/Aobv.md) | Archer On-Balance Volume | Dual EMA smoothing of OBV for cleaner crossover signals. |
| [CMF](cmf/Cmf.md) | Chaikin Money Flow | Measures money flow volume over set period (typically 20-21 days). |
| [EFI](efi/Efi.md) | Elder's Force Index | Combines price movement, direction, volume to measure buying/selling power. |
| [EOM](eom/Eom.md) | Ease of Movement | Relates price change to volume. Highlights periods of effortless price movement. |
| [III](iii/Iii.md) | Intraday Intensity Index | Measures buying/selling pressure within day's range using close position. |
| [KVO](kvo/Kvo.md) | Klinger Volume Oscillator | Compares short-term and long-term volume trends to identify potential reversals. |
| [MFI](mfi/Mfi.md) | Money Flow Index | Volume-weighted RSI. Measures buying/selling pressure using price and volume. |
| [NVI](nvi/Nvi.md) | Negative Volume Index | Tracks price changes on lower volume days. Assumes smart money acts on quiet days. |
| [OBV](obv/Obv.md) | On Balance Volume | Fundamental volume indicator. Cumulative volume based on price direction. |
| [PVD](pvd/Pvd.md) | Price Volume Divergence | Systematic divergence detection between price and volume movements. |
| [PVI](pvi/Pvi.md) | Positive Volume Index | Tracks price changes on higher volume days. Assumes crowd behavior. |
| [PVO](pvo/Pvo.md) | Percentage Volume Oscillator | Compares short-term and long-term volume moving averages as percentages. |
| [PVR](pvr/Pvr.md) | Price Volume Rank | Categorical indicator returning 0-4 based on combined price and volume direction. |
| [PVT](pvt/Pvt.md) | Price Volume Trend | Cumulative volume adjusted by relative price changes. Similar to OBV but magnitude-weighted. |
| [TVI](tvi/Tvi.md) | Trade Volume Index | Cumulative volume with sticky direction based on minimum tick threshold. Filters noise from OBV. |
| [TWAP](twap/Twap.md) | Time Weighted Average Price | Average price weighted equally by time. Used as execution benchmark. |
| [VA](va/Va.md) | Volume Accumulation | Cumulative volume adjusted by close position relative to range midpoint. |
| [VF](vf/Vf.md) | Volume Force | Measures force of volume behind price movements using EMA smoothing. |
| [VO](vo/Vo.md) | Volume Oscillator | Difference between short and long volume moving averages. Shows volume momentum. |
| [VROC](vroc/Vroc.md) | Volume Rate of Change | Measures speed at which volume is changing over time. |
| [VWAD](vwad/Vwad.md) | Volume Weighted A/D | Similar to ADL but weights accumulation/distribution by volume. |
| [VWAP](vwap/Vwap.md) | Volume Weighted Average Price | Average price weighted by volume. Common execution benchmark and intraday reference. |
| [VWMA](vwma/Vwma.md) | Volume Weighted Moving Average | Moving average where each price point is weighted by its volume over a sliding window. |
| [WAD](wad/Wad.md) | Williams Accumulation/Distribution | Measures cumulative buying/selling pressure using True Range and volume. |
+11 -11
View File
@@ -318,19 +318,19 @@ public sealed class Vwma : ITValuePublisher
/// <summary>
/// Zero-allocation span-based calculation.
/// </summary>
/// <param name="price">Price values</param>
/// <param name="source">Source values</param>
/// <param name="volume">Volume values</param>
/// <param name="output">Output span for VWMA values</param>
/// <param name="period">Lookback period for VWMA</param>
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
public static void Calculate(ReadOnlySpan<double> price, ReadOnlySpan<double> volume, Span<double> output, int period = 20)
public static void Calculate(ReadOnlySpan<double> source, ReadOnlySpan<double> volume, Span<double> output, int period = 20)
{
if (price.Length != volume.Length)
if (source.Length != volume.Length)
{
throw new ArgumentException("Price and Volume spans must be of the same length", nameof(volume));
throw new ArgumentException("Source and Volume spans must be of the same length", nameof(volume));
}
if (price.Length != output.Length)
if (source.Length != output.Length)
{
throw new ArgumentException("Output span must be of the same length as input", nameof(output));
}
@@ -340,7 +340,7 @@ public sealed class Vwma : ITValuePublisher
throw new ArgumentException("Period must be >= 1", nameof(period));
}
int len = price.Length;
int len = source.Length;
if (len == 0)
{
return;
@@ -380,9 +380,9 @@ public sealed class Vwma : ITValuePublisher
// Find first valid values
for (int k = 0; k < len; k++)
{
if (double.IsFinite(price[k]))
if (double.IsFinite(source[k]))
{
lastValidPrice = price[k];
lastValidPrice = source[k];
break;
}
}
@@ -400,12 +400,12 @@ public sealed class Vwma : ITValuePublisher
for (int i = 0; i < len; i++)
{
// Get valid values with NaN substitution
double currentPrice = double.IsFinite(price[i]) ? price[i] : lastValidPrice;
double currentPrice = double.IsFinite(source[i]) ? source[i] : lastValidPrice;
double currentVol = double.IsFinite(volume[i]) ? volume[i] : lastValidVolume;
if (double.IsFinite(price[i]))
if (double.IsFinite(source[i]))
{
lastValidPrice = price[i];
lastValidPrice = source[i];
}
if (double.IsFinite(volume[i]))
{