pub struct VolatilityOfVolatility { /* private fields */ }Expand description
Volatility of Volatility — the standard deviation of a rolling realized- volatility series (“vol-of-vol”).
r_t = ln(price_t / price_{t−1})
vol_t = stddev_sample(r over vol_window) (rolling realized volatility)
VoV = stddev_sample(vol over vov_window) (dispersion of that series)This is a two-stage estimator: the first stage measures the rolling sample
volatility of log returns (the same quantity
HistoricalVolatility annualises), and the
second stage measures how much that volatility itself moves. A high
vol-of-vol means the volatility regime is unstable — turbulent periods
alternate with calm ones — which is exactly the convexity that long-gamma and
volatility-trading strategies care about. Both stages use the unbiased
n − 1 sample standard deviation. Each update is O(1).
Non-finite and non-positive prices are ignored (the log return would be undefined): the tick is dropped, state is left untouched, and the last value is returned.
§Example
use wickra_core::{Indicator, VolatilityOfVolatility};
let mut indicator = VolatilityOfVolatility::new(20, 20).unwrap();
let mut last = None;
for i in 0..120 {
last = indicator.update(100.0 + (f64::from(i) * 0.3).sin() * 5.0);
}
assert!(last.is_some());Implementations§
Source§impl VolatilityOfVolatility
impl VolatilityOfVolatility
Sourcepub fn new(vol_window: usize, vov_window: usize) -> Result<Self>
pub fn new(vol_window: usize, vov_window: usize) -> Result<Self>
Construct a new vol-of-vol indicator.
vol_window is the window for the inner realized-volatility series;
vov_window is the window over which its dispersion is measured.
§Errors
Returns Error::PeriodZero if either window is 0, or
Error::InvalidPeriod if either is 1 (a sample standard deviation
needs at least two observations).
Trait Implementations§
Source§impl Clone for VolatilityOfVolatility
impl Clone for VolatilityOfVolatility
Source§fn clone(&self) -> VolatilityOfVolatility
fn clone(&self) -> VolatilityOfVolatility
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for VolatilityOfVolatility
impl Debug for VolatilityOfVolatility
Source§impl Indicator for VolatilityOfVolatility
impl Indicator for VolatilityOfVolatility
Source§fn update(&mut self, input: f64) -> Option<f64>
fn update(&mut self, input: f64) -> Option<f64>
None if the indicator is still warming up.Source§fn reset(&mut self)
fn reset(&mut self)
Source§fn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
None output can be produced.Auto Trait Implementations§
impl Freeze for VolatilityOfVolatility
impl RefUnwindSafe for VolatilityOfVolatility
impl Send for VolatilityOfVolatility
impl Sync for VolatilityOfVolatility
impl Unpin for VolatilityOfVolatility
impl UnsafeUnpin for VolatilityOfVolatility
impl UnwindSafe for VolatilityOfVolatility
Blanket Implementations§
Source§impl<T> BatchExt for Twhere
T: Indicator,
impl<T> BatchExt for Twhere
T: Indicator,
Source§fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
None during warmup) per input.Source§impl<T> BatchNanExt for T
impl<T> BatchNanExt for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more