Expand description
§Relative volume (RVOL)
rvol[i] = volume[i] / mean(volume[i − lookback + 1 ..= i])when the lookback window is full; warm-up bars are None.
§Word problem
Twenty bars printed 1,000 volume, then one bar prints 2,000. What is RVOL(20)?
The lookback includes the current bar, so
mean = (19×1000 + 2000) / 20 = 1050 and RVOL = 2000/1050 ≈ 1.905.
use finance_solution::stocks::ta::{rvol, RvolParams};
let mut vol = vec![1_000.0; 20];
vol.push(2_000.0);
let s = rvol(&vol, RvolParams::days_20()).unwrap();
assert!((s.rvol[20].unwrap() - 2000.0 / 1050.0).abs() < 1e-9);Constant volume → RVOL = 1 after warm-up (useful unit check).
§Quant pattern
use finance_solution::stocks::ta::{RvolParams, ValidatedRvol, RvolState};
const R20: RvolParams = RvolParams::days_20();
let eng = ValidatedRvol::new(R20).unwrap();
let s = eng.compute(&vol).unwrap();
let mut live = RvolState::new(R20).unwrap();
let _ = live.push_bars(&vol).unwrap();
assert_eq!(s.rvol.len(), vol.len());§Sample solution table
period volume rvol
------ ------- ------
18 1180.00 n/a
19 1190.00 1.0820
20 2000.00 1.7540Structs§
- Rvol
Params - RVOL lookback pack.
- Rvol
Series - Rvol
Solution - Validated
Rvol - Validated RVOL config.
Functions§
- rvol
- rvol_
solution - Examples