pub struct ROC { /* private fields */ }Expand description
A Rate of Change (ROC) indicator.
Implementations§
Source§impl ROC
impl ROC
Sourcepub const DEFAULT_PERIOD: usize = 12usize
pub const DEFAULT_PERIOD: usize = 12usize
The default period for ROC calculation.
Sourcepub const SIGNAL_THRESHOLD: f64 = 2f64
pub const SIGNAL_THRESHOLD: f64 = 2f64
The threshold used to generate trading signals.
Sourcepub fn calculate(&mut self, price: f64) -> Option<ROCResult>
pub fn calculate(&mut self, price: f64) -> Option<ROCResult>
Calculates the current ROC value based on the latest price.
This method updates the sliding window of prices and computes:
- The ROC value (percentage change between the current price and the price from
periodperiods ago). - A normalized momentum value.
- The acceleration (difference between the current and previous ROC).
- A trading signal based on the ROC.
§Arguments
price- The latest price.
§Returns
Some(ROCResult)if there is enough data; otherwise,None.
Auto Trait Implementations§
impl Freeze for ROC
impl RefUnwindSafe for ROC
impl Send for ROC
impl Sync for ROC
impl Unpin for ROC
impl UnwindSafe for ROC
Blanket Implementations§
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
Mutably borrows from an owned value. Read more