File tree Expand file tree Collapse file tree 2 files changed +242
-51
lines changed
crates/indicators/src/average Expand file tree Collapse file tree 2 files changed +242
-51
lines changed Original file line number Diff line number Diff line change @@ -56,12 +56,14 @@ impl Indicator for WilderMovingAverage {
56
56
self . initialized
57
57
}
58
58
59
- fn handle_quote ( & mut self , q : & QuoteTick ) {
60
- self . update_raw ( q . extract_price ( self . price_type ) . into ( ) ) ;
59
+ fn handle_quote ( & mut self , quote : & QuoteTick ) {
60
+ self . update_raw ( quote . extract_price ( self . price_type ) . into ( ) ) ;
61
61
}
62
+
62
63
fn handle_trade ( & mut self , t : & TradeTick ) {
63
64
self . update_raw ( ( & t. price ) . into ( ) ) ;
64
65
}
66
+
65
67
fn handle_bar ( & mut self , b : & Bar ) {
66
68
self . update_raw ( ( & b. close ) . into ( ) ) ;
67
69
}
@@ -85,7 +87,10 @@ impl WilderMovingAverage {
85
87
// The Wilder Moving Average is The Wilder's Moving Average is simply
86
88
// an Exponential Moving Average (EMA) with a modified alpha.
87
89
// alpha = 1 / period
88
- assert ! ( period > 0 , "WilderMovingAverage: period must be > 0" ) ;
90
+ assert ! (
91
+ period > 0 ,
92
+ "WilderMovingAverage: period must be > 0 (received {period})"
93
+ ) ;
89
94
Self {
90
95
period,
91
96
price_type : price_type. unwrap_or ( PriceType :: Last ) ,
You can’t perform that action at this time.
0 commit comments