pub struct BullishPercentIndex { /* private fields */ }Expand description
Bullish Percent Index (BPI) — the percentage of symbols in a universe that are currently on a point-and-figure buy signal.
On each CrossSection tick the value is 100 * on_buy_signal_count / universe size, read from the per-symbol on_buy_signal flag (the caller
evaluates each symbol’s point-and-figure chart when it builds the tick). It is
a bounded 0..=100 gauge of how many issues are in a confirmed uptrend.
Readings above 70 are considered overbought (broad strength, but a crowded
market) and below 30 oversold; reversals from those zones are classic BPI
buy/sell triggers.
Input = CrossSection, Output = f64 (a percentage in 0..=100),
warmup_period == 1. The universe is non-empty by construction, so the share
is always defined.
§Example
use wickra_core::{BullishPercentIndex, CrossSection, Indicator, Member};
let mut bpi = BullishPercentIndex::new();
// 2 of 4 symbols on a buy signal -> 50%.
let tick = CrossSection::new(
vec![
Member::with_signals(1.0, 10.0, false, false, false, true),
Member::with_signals(1.0, 10.0, false, false, false, true),
Member::with_signals(-1.0, 10.0, false, false, false, false),
Member::with_signals(-1.0, 10.0, false, false, false, false),
],
0,
)
.unwrap();
assert_eq!(bpi.update(tick), Some(50.0));Implementations§
Trait Implementations§
Source§impl Clone for BullishPercentIndex
impl Clone for BullishPercentIndex
Source§fn clone(&self) -> BullishPercentIndex
fn clone(&self) -> BullishPercentIndex
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BullishPercentIndex
impl Debug for BullishPercentIndex
Source§impl Default for BullishPercentIndex
impl Default for BullishPercentIndex
Source§fn default() -> BullishPercentIndex
fn default() -> BullishPercentIndex
Returns the “default value” for a type. Read more
Source§impl Indicator for BullishPercentIndex
impl Indicator for BullishPercentIndex
Source§type Input = CrossSection
type Input = CrossSection
Type of one input data point (typically
f64 for a price, or Candle / Tick).Source§fn update(&mut self, section: CrossSection) -> Option<f64>
fn update(&mut self, section: CrossSection) -> Option<f64>
Feed one new data point into the indicator and return the freshly computed
output, or
None if the indicator is still warming up.Source§fn reset(&mut self)
fn reset(&mut self)
Reset all internal state, leaving the indicator equivalent to a freshly
constructed instance with the same parameters.
Source§fn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
Number of inputs required before the first non-
None output can be produced.Auto Trait Implementations§
impl Freeze for BullishPercentIndex
impl RefUnwindSafe for BullishPercentIndex
impl Send for BullishPercentIndex
impl Sync for BullishPercentIndex
impl Unpin for BullishPercentIndex
impl UnsafeUnpin for BullishPercentIndex
impl UnwindSafe for BullishPercentIndex
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>>
Run the indicator over a slice of inputs in order, returning one output (or
None during warmup) per input.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
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>
Converts
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>
Converts
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