@@ -2,13 +2,17 @@ use polars::prelude::*;
22use pyo3_polars:: derive:: polars_expr;
33use serde:: Deserialize ;
44use techr:: {
5- bband as techr_bband, disparity as techr_disparity, ema as techr_ema,
5+ bband_lower as techr_bband_lower, bband_middle as techr_bband_middle,
6+ bband_upper as techr_bband_upper, disparity as techr_disparity, ema as techr_ema,
67 ichimoku_base_line as techr_ichimoku_base_line,
78 ichimoku_conversion_line as techr_ichimoku_conversion_line,
89 ichimoku_lagging_span as techr_ichimoku_lagging_span,
910 ichimoku_leading_span_a as techr_ichimoku_leading_span_a,
10- ichimoku_leading_span_b as techr_ichimoku_leading_span_b, macd as techr_macd, sma as techr_sma,
11- stochf as techr_stochf, stochs as techr_stochs, wma as techr_wma,
11+ ichimoku_leading_span_b as techr_ichimoku_leading_span_b,
12+ macd_histogram as techr_macd_histogram, macd_line as techr_macd_line,
13+ macd_signal as techr_macd_signal, sma as techr_sma, stoch_percent_d as techr_stoch_percent_d,
14+ stoch_percent_k as techr_stoch_percent_k, stochf_percent_d as techr_stochf_percent_d,
15+ stochf_percent_k as techr_stochf_percent_k, wma as techr_wma,
1216} ;
1317
1418#[ derive( Deserialize ) ]
@@ -116,19 +120,18 @@ fn disparity(inputs: &[Series], kwargs: PeriodKwargs) -> PolarsResult<Series> {
116120#[ polars_expr( output_type=Float64 ) ]
117121fn macd ( inputs : & [ Series ] , kwargs : FastSlowKwargs ) -> PolarsResult < Series > {
118122 let input = series_to_f64_vec ( & inputs[ 0 ] ) ?;
119- let ( macd_line, _ , _ ) = techr_macd (
123+ let macd_line = techr_macd_line (
120124 & input,
121125 kwargs. fast_period as usize ,
122126 kwargs. slow_period as usize ,
123- 9 ,
124127 ) ;
125128 Ok ( option_vec_to_series ( macd_line) )
126129}
127130
128131#[ polars_expr( output_type=Float64 ) ]
129132fn macd_signal ( inputs : & [ Series ] , kwargs : FastSlowSignalKwargs ) -> PolarsResult < Series > {
130133 let input = series_to_f64_vec ( & inputs[ 0 ] ) ?;
131- let ( _ , signal_line, _ ) = techr_macd (
134+ let signal_line = techr_macd_signal (
132135 & input,
133136 kwargs. fast_period as usize ,
134137 kwargs. slow_period as usize ,
@@ -140,7 +143,7 @@ fn macd_signal(inputs: &[Series], kwargs: FastSlowSignalKwargs) -> PolarsResult<
140143#[ polars_expr( output_type=Float64 ) ]
141144fn macd_hist ( inputs : & [ Series ] , kwargs : FastSlowSignalKwargs ) -> PolarsResult < Series > {
142145 let input = series_to_f64_vec ( & inputs[ 0 ] ) ?;
143- let ( _ , _ , histogram) = techr_macd (
146+ let histogram = techr_macd_histogram (
144147 & input,
145148 kwargs. fast_period as usize ,
146149 kwargs. slow_period as usize ,
@@ -152,21 +155,21 @@ fn macd_hist(inputs: &[Series], kwargs: FastSlowSignalKwargs) -> PolarsResult<Se
152155#[ polars_expr( output_type=Float64 ) ]
153156fn bband_middle ( inputs : & [ Series ] , kwargs : PeriodKwargs ) -> PolarsResult < Series > {
154157 let input = series_to_f64_vec ( & inputs[ 0 ] ) ?;
155- let ( _ , middle, _ ) = techr_bband ( & input, kwargs. period as usize , None ) ;
158+ let middle = techr_bband_middle ( & input, kwargs. period as usize ) ;
156159 Ok ( option_vec_to_series ( middle) )
157160}
158161
159162#[ polars_expr( output_type=Float64 ) ]
160163fn bband_lower ( inputs : & [ Series ] , kwargs : BBandKwargs ) -> PolarsResult < Series > {
161164 let input = series_to_f64_vec ( & inputs[ 0 ] ) ?;
162- let ( _ , _ , lower) = techr_bband ( & input, kwargs. period as usize , Some ( kwargs. sigma ) ) ;
165+ let lower = techr_bband_lower ( & input, kwargs. period as usize , Some ( kwargs. sigma ) ) ;
163166 Ok ( option_vec_to_series ( lower) )
164167}
165168
166169#[ polars_expr( output_type=Float64 ) ]
167170fn bband_upper ( inputs : & [ Series ] , kwargs : BBandKwargs ) -> PolarsResult < Series > {
168171 let input = series_to_f64_vec ( & inputs[ 0 ] ) ?;
169- let ( upper, _ , _ ) = techr_bband ( & input, kwargs. period as usize , Some ( kwargs. sigma ) ) ;
172+ let upper = techr_bband_upper ( & input, kwargs. period as usize , Some ( kwargs. sigma ) ) ;
170173 Ok ( option_vec_to_series ( upper) )
171174}
172175
@@ -175,13 +178,7 @@ fn stochf_percent_k(inputs: &[Series], kwargs: StochFKwargs) -> PolarsResult<Ser
175178 let highs = series_to_f64_vec ( & inputs[ 0 ] ) ?;
176179 let lows = series_to_f64_vec ( & inputs[ 1 ] ) ?;
177180 let closes = series_to_f64_vec ( & inputs[ 2 ] ) ?;
178- let ( percent_k, _) = techr_stochf (
179- & highs,
180- & lows,
181- & closes,
182- kwargs. fastk_period as usize ,
183- kwargs. fastd_period as usize ,
184- ) ;
181+ let percent_k = techr_stochf_percent_k ( & highs, & lows, & closes, kwargs. fastk_period as usize ) ;
185182 Ok ( option_vec_to_series ( percent_k) )
186183}
187184
@@ -190,10 +187,9 @@ fn stochf_percent_d(inputs: &[Series], kwargs: StochFKwargs) -> PolarsResult<Ser
190187 let highs = series_to_f64_vec ( & inputs[ 0 ] ) ?;
191188 let lows = series_to_f64_vec ( & inputs[ 1 ] ) ?;
192189 let closes = series_to_f64_vec ( & inputs[ 2 ] ) ?;
193- let ( _, percent_d) = techr_stochf (
194- & highs,
195- & lows,
196- & closes,
190+ let percent_k = techr_stochf_percent_k ( & highs, & lows, & closes, kwargs. fastk_period as usize ) ;
191+ let percent_d = techr_stochf_percent_d (
192+ & percent_k,
197193 kwargs. fastk_period as usize ,
198194 kwargs. fastd_period as usize ,
199195 ) ;
@@ -205,13 +201,12 @@ fn stoch_percent_k(inputs: &[Series], kwargs: StochKwargs) -> PolarsResult<Serie
205201 let highs = series_to_f64_vec ( & inputs[ 0 ] ) ?;
206202 let lows = series_to_f64_vec ( & inputs[ 1 ] ) ?;
207203 let closes = series_to_f64_vec ( & inputs[ 2 ] ) ?;
208- let ( percent_k, _ ) = techr_stochs (
204+ let percent_k = techr_stoch_percent_k (
209205 & highs,
210206 & lows,
211207 & closes,
212208 kwargs. fastk_period as usize ,
213209 kwargs. slowk_period as usize ,
214- kwargs. slowd_period as usize ,
215210 ) ;
216211 Ok ( option_vec_to_series ( percent_k) )
217212}
@@ -221,7 +216,7 @@ fn stoch_percent_d(inputs: &[Series], kwargs: StochKwargs) -> PolarsResult<Serie
221216 let highs = series_to_f64_vec ( & inputs[ 0 ] ) ?;
222217 let lows = series_to_f64_vec ( & inputs[ 1 ] ) ?;
223218 let closes = series_to_f64_vec ( & inputs[ 2 ] ) ?;
224- let ( _ , percent_d) = techr_stochs (
219+ let percent_d = techr_stoch_percent_d (
225220 & highs,
226221 & lows,
227222 & closes,
0 commit comments