Skip to main content

Indicator

Enum Indicator 

Source
#[non_exhaustive]
pub enum Indicator {
Show 40 variants Sma(usize), Ema(usize), Rsi(usize), Macd { fast: usize, slow: usize, signal: usize, }, Bollinger { period: usize, std_dev: f64, }, Atr(usize), Obv, Vwap, Wma(usize), Dema(usize), Tema(usize), Hma(usize), Vwma(usize), Alma { period: usize, offset: f64, sigma: f64, }, McginleyDynamic(usize), Stochastic { k_period: usize, k_slow: usize, d_period: usize, }, StochasticRsi { rsi_period: usize, stoch_period: usize, k_period: usize, d_period: usize, }, Cci(usize), WilliamsR(usize), Roc(usize), Momentum(usize), Cmo(usize), AwesomeOscillator { fast: usize, slow: usize, }, CoppockCurve { wma_period: usize, long_roc: usize, short_roc: usize, }, Adx(usize), Aroon(usize), Supertrend { period: usize, multiplier: f64, }, Ichimoku { conversion: usize, base: usize, lagging: usize, displacement: usize, }, ParabolicSar { step: f64, max: f64, }, BullBearPower(usize), ElderRay(usize), KeltnerChannels { period: usize, multiplier: f64, atr_period: usize, }, DonchianChannels(usize), TrueRange, ChoppinessIndex(usize), Mfi(usize), Cmf(usize), ChaikinOscillator, AccumulationDistribution, BalanceOfPower(Option<usize>),
}
Expand description

Enum representing all available technical indicators.

This enum is used with Ticker::indicator() to calculate specific indicators over a given interval and time range.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Sma(usize)

Simple Moving Average with custom period

§

Ema(usize)

Exponential Moving Average with custom period

§

Rsi(usize)

Relative Strength Index with custom period

§

Macd

Moving Average Convergence Divergence (fast, slow, signal periods)

Fields

§fast: usize

Fast EMA period

§slow: usize

Slow EMA period

§signal: usize

Signal line EMA period

§

Bollinger

Bollinger Bands (period, standard deviation multiplier)

Fields

§period: usize

SMA period

§std_dev: f64

Standard deviation multiplier

§

Atr(usize)

Average True Range with custom period

§

Obv

On-Balance Volume

§

Vwap

Volume Weighted Average Price

§

Wma(usize)

Weighted Moving Average

§

Dema(usize)

Double Exponential Moving Average

§

Tema(usize)

Triple Exponential Moving Average

§

Hma(usize)

Hull Moving Average

§

Vwma(usize)

Volume Weighted Moving Average

§

Alma

Arnaud Legoux Moving Average

Fields

§period: usize

Window period

§offset: f64

Offset (typically 0.85)

§sigma: f64

Sigma (typically 6.0)

§

McginleyDynamic(usize)

McGinley Dynamic

§

Stochastic

Stochastic Oscillator

Fields

§k_period: usize

%K period

§k_slow: usize

%K slowing period

§d_period: usize

%D period (SMA of %K)

§

StochasticRsi

Stochastic RSI

Fields

§rsi_period: usize

RSI period

§stoch_period: usize

Stochastic period applied to RSI

§k_period: usize

%K smoothing period

§d_period: usize

%D smoothing period

§

Cci(usize)

Commodity Channel Index

§

WilliamsR(usize)

Williams %R

§

Roc(usize)

Rate of Change

§

Momentum(usize)

Momentum

§

Cmo(usize)

Chande Momentum Oscillator

§

AwesomeOscillator

Awesome Oscillator

Fields

§fast: usize

Fast SMA period

§slow: usize

Slow SMA period

§

CoppockCurve

Coppock Curve

Fields

§wma_period: usize

WMA smoothing period

§long_roc: usize

Long ROC period

§short_roc: usize

Short ROC period

§

Adx(usize)

Average Directional Index

§

Aroon(usize)

Aroon

§

Supertrend

SuperTrend

Fields

§period: usize

ATR period

§multiplier: f64

ATR multiplier

§

Ichimoku

Ichimoku Cloud

Fields

§conversion: usize

Conversion line period (Tenkan-sen)

§base: usize

Base line period (Kijun-sen)

§lagging: usize

Lagging span period (Chikou Span)

§displacement: usize

Displacement for leading spans

§

ParabolicSar

Parabolic SAR

Fields

§step: f64

Acceleration factor step

§max: f64

Maximum acceleration factor

§

BullBearPower(usize)

Bull/Bear Power

§

ElderRay(usize)

Elder Ray Index

§

KeltnerChannels

Keltner Channels

Fields

§period: usize

EMA period for middle line

§multiplier: f64

ATR multiplier for bands

§atr_period: usize

ATR period

§

DonchianChannels(usize)

Donchian Channels

§

TrueRange

True Range

§

ChoppinessIndex(usize)

Choppiness Index

§

Mfi(usize)

Money Flow Index

§

Cmf(usize)

Chaikin Money Flow

§

ChaikinOscillator

Chaikin Oscillator

§

AccumulationDistribution

Accumulation/Distribution

§

BalanceOfPower(Option<usize>)

Balance of Power

Implementations§

Source§

impl Indicator

Source

pub fn with_defaults(self) -> Self

Get a default instance with standard parameters

§Examples
use finance_query::indicators::Indicator;

let rsi = Indicator::Rsi(14);  // 14-period RSI
let macd = Indicator::Macd { fast: 12, slow: 26, signal: 9 };
Source

pub fn name(&self) -> &'static str

Get the human-readable name of the indicator

Source

pub fn warmup_bars(&self) -> usize

Minimum number of data bars required before this indicator produces meaningful output.

Used by the backtesting engine’s CustomStrategy to automatically compute the warmup period instead of parsing key-name suffixes.

§Examples
use finance_query::indicators::Indicator;

assert_eq!(Indicator::Sma(20).warmup_bars(), 20);
assert_eq!(Indicator::Macd { fast: 12, slow: 26, signal: 9 }.warmup_bars(), 35);
assert_eq!(Indicator::Bollinger { period: 20, std_dev: 2.0 }.warmup_bars(), 20);

Trait Implementations§

Source§

impl Clone for Indicator

Source§

fn clone(&self) -> Indicator

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Indicator

Source§

impl Debug for Indicator

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Indicator

Source§

fn eq(&self, other: &Indicator) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Indicator

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Key for T
where T: Clone,

Source§

fn align() -> usize

The alignment necessary for the key. Must return a power of two.
Source§

fn size(&self) -> usize

The size of the key in bytes.
Source§

unsafe fn init(&self, ptr: *mut u8)

Initialize the key in the given memory location. Read more
Source§

unsafe fn get<'a>(ptr: *const u8) -> &'a T

Get a reference to the key from the given memory location. Read more
Source§

unsafe fn drop_in_place(ptr: *mut u8)

Drop the key in place. Read more
Source§

impl<T> PlanCallbackArgs for T

Source§

impl<T> PlanCallbackOut for T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more