跳过无需求的滚动计算
This commit is contained in:
@@ -1966,14 +1966,20 @@ impl DataSet {
|
|||||||
volume_lookbacks: &[usize; 5],
|
volume_lookbacks: &[usize; 5],
|
||||||
include_now: bool,
|
include_now: bool,
|
||||||
) -> StandardRollingMeans {
|
) -> StandardRollingMeans {
|
||||||
let close = self
|
let close = if close_lookbacks.iter().any(|lookback| *lookback > 0) {
|
||||||
.adjusted_close_series_by_symbol_id(symbol_id)
|
self.adjusted_close_series_by_symbol_id(symbol_id)
|
||||||
.map(|series| series.moving_averages(date, close_lookbacks, include_now))
|
.map(|series| series.moving_averages(date, close_lookbacks, include_now))
|
||||||
.unwrap_or([None; 7]);
|
.unwrap_or([None; 7])
|
||||||
let volume = self
|
} else {
|
||||||
.market_series_by_symbol_id(symbol_id)
|
[None; 7]
|
||||||
|
};
|
||||||
|
let volume = if volume_lookbacks.iter().any(|lookback| *lookback > 0) {
|
||||||
|
self.market_series_by_symbol_id(symbol_id)
|
||||||
.map(|series| series.volume_moving_averages(date, volume_lookbacks, include_now))
|
.map(|series| series.volume_moving_averages(date, volume_lookbacks, include_now))
|
||||||
.unwrap_or([None; 5]);
|
.unwrap_or([None; 5])
|
||||||
|
} else {
|
||||||
|
[None; 5]
|
||||||
|
};
|
||||||
StandardRollingMeans { close, volume }
|
StandardRollingMeans { close, volume }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user