pub struct EfficiencyRatio {
pub period: usize,
pub price_type: PriceType,
pub value: f64,
pub inputs: Vec<f64>,
pub initialized: bool,
/* private fields */
}Expand description
Calculates Kaufman’s Efficiency Ratio (ER) across a rolling window.
The period must be at least 2.
For period n, the ratio is:
ER(t) = |P(t) - P(t - n)| / sum(|P(i) - P(i - 1)|, i = t - n + 1 to t)
A full n-period window requires n + 1 prices for n price changes. For
finite inputs within the model price range, values range from 0.0 to 1.0:
lower values indicate more noise, while 1.0 indicates directional price
movement without reversals.
For compatibility, initialized becomes true after n inputs, so the first
initialized value covers the n - 1 available price changes.
§References
- Kaufman, P. J. (1995). Smarter Trading. McGraw-Hill.
Fields§
§period: usizeThe rolling window period for the indicator (>= 2).
price_type: PriceType§value: f64§inputs: Vec<f64>§initialized: boolImplementations§
Source§impl EfficiencyRatio
impl EfficiencyRatio
Sourcepub fn new(period: usize, price_type: Option<PriceType>) -> Self
pub fn new(period: usize, price_type: Option<PriceType>) -> Self
Creates a new EfficiencyRatio instance.
§Panics
Panics if period is less than 2 or storage for its rolling windows cannot be reserved.
pub fn update_raw(&mut self, value: f64)
Trait Implementations§
Source§impl Debug for EfficiencyRatio
impl Debug for EfficiencyRatio
impl DerefToPyAny for EfficiencyRatio
Source§impl Display for EfficiencyRatio
impl Display for EfficiencyRatio
impl ExtractPyClassWithClone for EfficiencyRatio
Source§impl Indicator for EfficiencyRatio
impl Indicator for EfficiencyRatio
fn name(&self) -> String
fn has_inputs(&self) -> bool
fn initialized(&self) -> bool
Source§fn handle_quote(&mut self, quote: &QuoteTick) -> Result<()>
fn handle_quote(&mut self, quote: &QuoteTick) -> Result<()>
fn handle_trade(&mut self, trade: &TradeTick)
fn handle_bar(&mut self, bar: &Bar)
fn reset(&mut self)
fn handle_delta(&mut self, delta: &OrderBookDelta)
fn handle_deltas(&mut self, deltas: &OrderBookDeltas)
fn handle_depth(&mut self, depth: &OrderBookDepth10)
fn handle_book(&mut self, book: &OrderBook)
Source§impl<'py> IntoPyObject<'py> for EfficiencyRatio
impl<'py> IntoPyObject<'py> for EfficiencyRatio
Source§type Target = EfficiencyRatio
type Target = EfficiencyRatio
Source§type Output = Bound<'py, <EfficiencyRatio as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <EfficiencyRatio as IntoPyObject<'py>>::Target>
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
Source§impl PyClass for EfficiencyRatio
impl PyClass for EfficiencyRatio
Source§impl PyClassImpl for EfficiencyRatio
impl PyClassImpl for EfficiencyRatio
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§const RAW_DOC: &'static CStr = /// Calculates Kaufman's Efficiency Ratio (ER) across a rolling window.
///
/// The period must be at least `2`.
///
/// For period `n`, the ratio is:
///
/// `ER(t) = |P(t) - P(t - n)| / sum(|P(i) - P(i - 1)|, i = t - n + 1 to t)`
///
/// A full `n`-period window requires `n + 1` prices for `n` price changes. For
/// finite inputs within the model price range, values range from `0.0` to `1.0`:
/// lower values indicate more noise, while `1.0` indicates directional price
/// movement without reversals.
///
/// For compatibility, `initialized` becomes true after `n` inputs, so the first
/// initialized value covers the `n - 1` available price changes.
///
/// # References
///
/// - Kaufman, P. J. (1995). *Smarter Trading*. McGraw-Hill.
const RAW_DOC: &'static CStr = /// Calculates Kaufman's Efficiency Ratio (ER) across a rolling window. /// /// The period must be at least `2`. /// /// For period `n`, the ratio is: /// /// `ER(t) = |P(t) - P(t - n)| / sum(|P(i) - P(i - 1)|, i = t - n + 1 to t)` /// /// A full `n`-period window requires `n + 1` prices for `n` price changes. For /// finite inputs within the model price range, values range from `0.0` to `1.0`: /// lower values indicate more noise, while `1.0` indicates directional price /// movement without reversals. /// /// For compatibility, `initialized` becomes true after `n` inputs, so the first /// initialized value covers the `n - 1` available price changes. /// /// # References /// /// - Kaufman, P. J. (1995). *Smarter Trading*. McGraw-Hill.
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature if a constructor is defined. Read moreSource§type Layout = <<EfficiencyRatio as PyClassImpl>::BaseNativeType as PyClassBaseType>::Layout<EfficiencyRatio>
type Layout = <<EfficiencyRatio as PyClassImpl>::BaseNativeType as PyClassBaseType>::Layout<EfficiencyRatio>
Source§type ThreadChecker = NoopThreadChecker
type ThreadChecker = NoopThreadChecker
type Inventory = Pyo3MethodsInventoryForEfficiencyRatio
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
§fn dict_offset() -> Option<PyObjectOffset>
fn dict_offset() -> Option<PyObjectOffset>
§fn weaklist_offset() -> Option<PyObjectOffset>
fn weaklist_offset() -> Option<PyObjectOffset>
Source§impl PyClassNewTextSignature for EfficiencyRatio
impl PyClassNewTextSignature for EfficiencyRatio
const TEXT_SIGNATURE: &'static str = "(period, price_type=None)"
Source§impl PyStubType for EfficiencyRatio
impl PyStubType for EfficiencyRatio
Source§fn type_output() -> TypeInfo
fn type_output() -> TypeInfo
§fn type_input() -> TypeInfo
fn type_input() -> TypeInfo
Source§impl PyTypeInfo for EfficiencyRatio
impl PyTypeInfo for EfficiencyRatio
Source§const NAME: &str = <Self as ::pyo3::PyClass>::NAME
const NAME: &str = <Self as ::pyo3::PyClass>::NAME
prefer using ::type_object(py).name() to get the correct runtime value
Source§const MODULE: Option<&str> = <Self as ::pyo3::impl_::pyclass::PyClassImpl>::MODULE
const MODULE: Option<&str> = <Self as ::pyo3::impl_::pyclass::PyClassImpl>::MODULE
prefer using ::type_object(py).module() to get the correct runtime value
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
§fn is_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type or a subclass of this type.§fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type.Auto Trait Implementations§
impl Freeze for EfficiencyRatio
impl RefUnwindSafe for EfficiencyRatio
impl Send for EfficiencyRatio
impl Sync for EfficiencyRatio
impl Unpin for EfficiencyRatio
impl UnsafeUnpin for EfficiencyRatio
impl UnwindSafe for EfficiencyRatio
Blanket Implementations§
impl<T> Allocation 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self into an owned Python object, dropping type information.§fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
self into an owned Python object, dropping type information and unbinding it
from the 'py lifetime.§fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
self into a Python object. Read more§impl<'py, T> IntoPyObjectNautilusExt<'py> for Twhere
T: IntoPyObjectExt<'py>,
impl<'py, T> IntoPyObjectNautilusExt<'py> for Twhere
T: IntoPyObjectExt<'py>,
§fn into_py_any_unwrap(self, py: Python<'py>) -> Py<PyAny>where
Self: IntoPyObject<'py, Error = !>,
fn into_py_any_unwrap(self, py: Python<'py>) -> Py<PyAny>where
Self: IntoPyObject<'py, Error = !>,
self into a [Py<PyAny>] when the underlying conversion is infallible.§impl<T> PyErrArguments for T
impl<T> PyErrArguments for T
§impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
§fn type_check(object: &Bound<'_, PyAny>) -> bool
fn type_check(object: &Bound<'_, PyAny>) -> bool
§fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
isinstance and issubclass function. Read more