pub struct Stochastics {
pub period_k: usize,
pub period_d: usize,
pub slowing: usize,
pub ma_type: MovingAverageType,
pub d_method: StochasticsDMethod,
pub value_k: f64,
pub value_d: f64,
pub initialized: bool,
/* private fields */
}Fields§
§period_k: usizeThe lookback period for %K calculation (highest high / lowest low).
period_d: usizeThe smoothing period for %D calculation.
slowing: usizeThe slowing period for %K smoothing (1 = no slowing (Nautilus original).
ma_type: MovingAverageTypeThe moving average type used for slowing and MA-based %D.
d_method: StochasticsDMethodThe method for calculating %D (Ratio = Nautilus original method, MovingAverage = MA Smoothed).
value_k: f64The current %K value (slowed if slowing > 1).
value_d: f64The current %D value.
initialized: boolWhether the indicator has received sufficient inputs to produce valid values.
Implementations§
Source§impl Stochastics
impl Stochastics
Sourcepub fn new(period_k: usize, period_d: usize) -> Self
pub fn new(period_k: usize, period_d: usize) -> Self
Creates a new Stochastics instance with default parameters.
This is the backward-compatible constructor that produces identical output to the original Nautilus implementation, setting the following to:
slowing = 1(no slowing applied to %K)ma_type = Exponential(unused when slowing = 1 or with Ratio method)d_method = Ratio(Nautilus native %D calculation)
§Panics
This function panics if:
period_korperiod_dis less than 1 or greater thanMAX_PERIOD.
Sourcepub fn new_with_params(
period_k: usize,
period_d: usize,
slowing: usize,
ma_type: MovingAverageType,
d_method: StochasticsDMethod,
) -> Self
pub fn new_with_params( period_k: usize, period_d: usize, slowing: usize, ma_type: MovingAverageType, d_method: StochasticsDMethod, ) -> Self
Creates a new Stochastics instance with full parameter control.
§Parameters
period_k: The lookback period for %K (highest high / lowest low).period_d: The smoothing period for %D.slowing: MA smoothing period for raw %K (1 = no slowing, > 1 = smoothed).ma_type: MA type for slowing and MA-based %D (EMA, SMA, Wilder, etc.).d_method: %D calculation method (Ratio = Nautilus original, MovingAverage = MA smoothed).
§Panics
This function panics if:
period_k,period_d, orslowingis less than 1 or greater thanMAX_PERIOD.
Source§impl Stochastics
impl Stochastics
Sourcepub fn py_new(
period_k: usize,
period_d: usize,
slowing: Option<usize>,
ma_type: Option<MovingAverageType>,
d_method: Option<StochasticsDMethod>,
) -> Self
pub fn py_new( period_k: usize, period_d: usize, slowing: Option<usize>, ma_type: Option<MovingAverageType>, d_method: Option<StochasticsDMethod>, ) -> Self
Creates a new Stochastics indicator.
§Parameters
period_k : int The lookback period for %K calculation (highest high / lowest low). period_d : int The smoothing period for %D calculation. slowing : int, optional The slowing period for %K smoothing. Default is 1 (no slowing). Use >1 for MA smoothed %K. ma_type : MovingAverageType, optional The MA type for slowing and MA-based %D. Default is Exponential. d_method : StochasticsDMethod, optional The %D calculation method. Default is Ratio (Nautilus original). Use MovingAverage for MA smoothed %D.
Trait Implementations§
Source§impl Debug for Stochastics
impl Debug for Stochastics
Source§impl Display for Stochastics
impl Display for Stochastics
Source§impl Indicator for Stochastics
impl Indicator for Stochastics
fn name(&self) -> String
fn has_inputs(&self) -> bool
fn initialized(&self) -> bool
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)
fn handle_quote(&mut self, quote: &QuoteTick)
fn handle_trade(&mut self, trade: &TradeTick)
Source§impl<'py> IntoPyObject<'py> for Stochastics
impl<'py> IntoPyObject<'py> for Stochastics
Source§type Target = Stochastics
type Target = Stochastics
Source§type Output = Bound<'py, <Stochastics as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <Stochastics 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 Stochastics
impl PyClass for Stochastics
Source§impl PyClassImpl for Stochastics
impl PyClassImpl for Stochastics
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 = c"\x00"
const RAW_DOC: &'static CStr = c"\x00"
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature if a constructor is defined. Read moreSource§type ThreadChecker = SendablePyClass<Stochastics>
type ThreadChecker = SendablePyClass<Stochastics>
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<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyClassNewTextSignature for Stochastics
impl PyClassNewTextSignature for Stochastics
const TEXT_SIGNATURE: &'static str = "(period_k, period_d, slowing=None, ma_type=None, d_method=None)"
Source§impl PyMethods<Stochastics> for PyClassImplCollector<Stochastics>
impl PyMethods<Stochastics> for PyClassImplCollector<Stochastics>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for Stochastics
impl PyTypeInfo for Stochastics
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.impl DerefToPyAny for Stochastics
impl ExtractPyClassWithClone for Stochastics
Auto Trait Implementations§
impl Freeze for Stochastics
impl !RefUnwindSafe for Stochastics
impl Send for Stochastics
impl Sync for Stochastics
impl Unpin for Stochastics
impl !UnwindSafe for Stochastics
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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§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 moreSource§impl<'py, T> IntoPyObjectNautilusExt<'py> for Twhere
T: IntoPyObjectExt<'py>,
impl<'py, T> IntoPyObjectNautilusExt<'py> for Twhere
T: IntoPyObjectExt<'py>,
Source§fn into_py_any_unwrap(self, py: Python<'py>) -> Py<PyAny>
fn into_py_any_unwrap(self, py: Python<'py>) -> Py<PyAny>
§impl<T> PyErrArguments for T
impl<T> PyErrArguments for T
§impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
§const NAME: &'static str = T::NAME
const NAME: &'static str = T::NAME
§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 moreSource§impl<T> Separable for Twhere
T: Display,
impl<T> Separable for Twhere
T: Display,
Source§fn separate_by_policy(&self, policy: SeparatorPolicy<'_>) -> String
fn separate_by_policy(&self, policy: SeparatorPolicy<'_>) -> String
SeparatorPolicy. Read more