复用标准rolling的交易日边界索引
This commit is contained in:
@@ -1964,10 +1964,13 @@ impl DataSet {
|
|||||||
volume_lookbacks: &[usize; 5],
|
volume_lookbacks: &[usize; 5],
|
||||||
include_now: bool,
|
include_now: bool,
|
||||||
) -> StandardRollingMeans {
|
) -> StandardRollingMeans {
|
||||||
|
// Both series are built from the same market-date sequence. Reuse the
|
||||||
|
// indexed boundary lookup instead of repeating it for close and volume.
|
||||||
|
let series_end = self.market_series_end_index_by_symbol_id(date, symbol_id, include_now);
|
||||||
let close = if close_lookbacks.iter().any(|lookback| *lookback > 0) {
|
let close = if close_lookbacks.iter().any(|lookback| *lookback > 0) {
|
||||||
self.adjusted_close_series_by_symbol_id(symbol_id)
|
self.adjusted_close_series_by_symbol_id(symbol_id)
|
||||||
.map(|series| {
|
.map(|series| {
|
||||||
self.market_series_end_index_by_symbol_id(date, symbol_id, include_now)
|
series_end
|
||||||
.map(|end| series.moving_averages_at_end(end, close_lookbacks))
|
.map(|end| series.moving_averages_at_end(end, close_lookbacks))
|
||||||
.unwrap_or_else(|| series.moving_averages(date, close_lookbacks, include_now))
|
.unwrap_or_else(|| series.moving_averages(date, close_lookbacks, include_now))
|
||||||
})
|
})
|
||||||
@@ -1978,7 +1981,7 @@ impl DataSet {
|
|||||||
let volume = if volume_lookbacks.iter().any(|lookback| *lookback > 0) {
|
let volume = if volume_lookbacks.iter().any(|lookback| *lookback > 0) {
|
||||||
self.market_series_by_symbol_id(symbol_id)
|
self.market_series_by_symbol_id(symbol_id)
|
||||||
.map(|series| {
|
.map(|series| {
|
||||||
self.market_series_end_index_by_symbol_id(date, symbol_id, include_now)
|
series_end
|
||||||
.map(|end| series.volume_moving_averages_at_end(end, volume_lookbacks))
|
.map(|end| series.volume_moving_averages_at_end(end, volume_lookbacks))
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
series.volume_moving_averages(date, volume_lookbacks, include_now)
|
series.volume_moving_averages(date, volume_lookbacks, include_now)
|
||||||
|
|||||||
Reference in New Issue
Block a user