Skip to content

Commit 4ceee35

Browse files
committed
docs: fix
1 parent 3cd0f3b commit 4ceee35

File tree

7 files changed

+33
-45
lines changed

7 files changed

+33
-45
lines changed

src/core/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub use window::Window;
3232
///
3333
/// ```toml
3434
/// [dependencies]
35-
/// yata = { value_type_f32 = true }
35+
/// yata = { features = [ "value_type_f32" ] }
3636
/// ```
3737
///
3838
/// Read more at [Features section](https://doc.rust-lang.org/cargo/reference/features.html#the-features-section)
@@ -59,7 +59,7 @@ pub type ValueType = f32;
5959
///
6060
/// ```toml
6161
/// [dependencies]
62-
/// yata = { period_type_u16 = true }
62+
/// yata = { features = ["period_type_u16"] }
6363
/// ```
6464
///
6565
/// Read more at [Features section](https://doc.rust-lang.org/cargo/reference/features.html#the-features-section)

src/core/moving_average.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,24 @@ use std::str::FromStr;
22

33
use super::{Error, Method, PeriodType, ValueType};
44

5-
/// A shortcut for dynamically generated moving averages
5+
/// Marker trait for any moving average
66
///
77
/// Moving average is a [`Method`] which has parameters of single [`PeriodType`], input is single [`ValueType`] and output is single [`ValueType`].
88
///
99
/// # See also
1010
///
11-
/// [Default regular methods list](RegularMethods)
11+
/// [Default moving averages methods list](crate::helpers::MA)
1212
///
1313
/// [`Method`]: crate::core::Method
1414
/// [`ValueType`]: crate::core::ValueType
1515
/// [`PeriodType`]: crate::core::PeriodType
16-
17-
/// Marker trait for any moving average
1816
pub trait MovingAverage: Method<Input = ValueType, Output = ValueType> {}
1917

2018
/// Trait for dynamically creation of moving average instances based on it's type and period
2119
///
2220
/// This trait plays the same role for moving averages as [`IndicatorConfig`] plays for indicators.
2321
///
24-
/// [`IndicatorConfig`]: crate::core::indicator::IndicatorConfig
22+
/// [`IndicatorConfig`]: crate::core::IndicatorConfig
2523
pub trait MovingAverageConstructor: Clone + FromStr {
2624
/// Used for comparing MA types
2725
type Type: Eq;

src/helpers/mod.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ pub fn assert_neq_float(value1: ValueType, value2: ValueType) {
125125
}
126126

127127
/// Random Candles iterator for testing purposes
128-
#[derive(Debug, Clone)]
128+
#[derive(Debug, Clone, Default)]
129129
#[allow(missing_copy_implementations)]
130130
pub struct RandomCandles(u16);
131131

@@ -151,12 +151,6 @@ impl RandomCandles {
151151
}
152152
}
153153

154-
impl Default for RandomCandles {
155-
fn default() -> Self {
156-
Self(0)
157-
}
158-
}
159-
160154
impl Iterator for RandomCandles {
161155
type Item = Candle;
162156

src/indicators/coppock_curve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub struct CoppockCurve<M: MovingAverageConstructor = MA> {
3737
/// Period range in \[`2`; [`PeriodType::MAX`](crate::core::PeriodType)\).
3838
pub ma1: M,
3939

40-
/// Signal line MA type .
40+
/// Signal line MA type .
4141
///
4242
/// Default is [`EMA(5)`](crate::methods::EMA)
4343
///

src/indicators/example.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,23 +115,19 @@ impl IndicatorInstance for ExampleInstance {
115115
fn next<T: OHLCV>(&mut self, candle: &T) -> IndicatorResult {
116116
let new_signal = self.cross.next(&(candle.close(), self.cfg.price));
117117

118-
let signal = match new_signal {
119-
Action::None => {
120-
self.last_signal = new_signal;
121-
self.last_signal_position = 0;
122-
new_signal
123-
}
124-
_ => {
125-
if let Action::None = self.last_signal {
126-
self.last_signal
127-
} else {
128-
self.last_signal_position += 1;
129-
if self.last_signal_position > self.cfg.period {
130-
self.last_signal = Action::None;
131-
}
132-
self.last_signal
118+
let signal = if new_signal == Action::None {
119+
self.last_signal = new_signal;
120+
self.last_signal_position = 0;
121+
new_signal
122+
} else {
123+
if Action::None != self.last_signal {
124+
self.last_signal_position += 1;
125+
if self.last_signal_position > self.cfg.period {
126+
self.last_signal = Action::None;
133127
}
134128
}
129+
130+
self.last_signal
135131
};
136132

137133
let some_other_signal = Action::from(0.5);

src/methods/highest_lowest_index.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ impl Method for HighestIndex {
9797
self.value = value;
9898
self.index = 0;
9999
} else if self.index == self.window.len() {
100-
let (index, value) =
101-
self.window
102-
.iter()
103-
.copied()
104-
.enumerate()
105-
.fold((0, value), |a, b| if b.1 > a.1 { b } else { a });
100+
let (index, value) = self
101+
.window
102+
.iter()
103+
.copied()
104+
.enumerate()
105+
.fold((0, value), |a, b| if b.1 > a.1 { b } else { a });
106106

107107
self.index = index as PeriodType; // self.window.len() - index as PeriodType - 1;
108108
self.value = value;
@@ -205,12 +205,12 @@ impl Method for LowestIndex {
205205
self.value = value;
206206
self.index = 0;
207207
} else if self.index == self.window.len() {
208-
let (index, value) =
209-
self.window
210-
.iter()
211-
.copied()
212-
.enumerate()
213-
.fold((0, value), |a, b| if b.1 < a.1 { b } else { a });
208+
let (index, value) = self
209+
.window
210+
.iter()
211+
.copied()
212+
.enumerate()
213+
.fold((0, value), |a, b| if b.1 < a.1 { b } else { a });
214214

215215
self.index = index as PeriodType; // self.window.len() - index as PeriodType - 1;
216216
self.value = value;

src/methods/reversal.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize};
1212
///
1313
/// `left` should be > `0` and `right` should be > `0`
1414
///
15-
/// There is an additional restriction on parameters: `left`+`right`+1 should be <= [`PeriodType`]::MAX.
15+
/// There is an additional restriction on parameters: `left`+`right`+1 should be <= [`PeriodType`]`::MAX`.
1616
/// So if your [`PeriodType`] is default `u8`, then `left`+`right`+1 should be <= `255`
1717
///
1818
/// [Read more about `PeriodType`][`PeriodType`]
@@ -93,7 +93,7 @@ impl Method for ReversalSignal {
9393
///
9494
/// `left` should be > 0 and `right` should be > 0
9595
///
96-
/// There is an additional restriction on parameters: `left`+`right`+1 should be <= [`PeriodType`]::MAX.
96+
/// There is an additional restriction on parameters: `left`+`right`+1 should be <= [`PeriodType`]`::MAX`.
9797
/// So if your [`PeriodType`] is default `u8`, then `left`+`right`+1 should be <= 255
9898
///
9999
/// [Read more about `PeriodType`][`PeriodType`]
@@ -224,7 +224,7 @@ impl Method for UpperReversalSignal {
224224
///
225225
/// `left` should be > 0 and `right` should be > 0
226226
///
227-
/// There is an additional restriction on parameters: `left`+`right`+1 should be <= [`PeriodType`]::MAX.
227+
/// There is an additional restriction on parameters: `left`+`right`+1 should be <= [`PeriodType`]`::MAX`.
228228
/// So if your [`PeriodType`] is default `u8`, then `left`+`right`+1 should be <= 255
229229
///
230230
/// [Read more about `PeriodType`][`PeriodType`]

0 commit comments

Comments
 (0)