VolumeWeightedAveragePriceExecutionModel silently degenerates on daily resolution
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
The relevant files are Algorithm.Framework/Execution/VolumeWeightedAveragePriceExecutionModel.cs, where PriceIsFavorable compares bid and ask against data.VWAP, and Indicators/IntradayVwap.cs, where the sums reset at each date boundary. Start by confirming the daily-resolution reasoning in the issue, then add a <remarks> block to both class documentations stating the model is intraday-only and that daily or coarser resolution degrades the indicator to the bar's typical price. Done when both remarks are present and build cleanly. Behaviour changes such as rejecting daily input need a maintainer decision first.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
VolumeWeightedAveragePriceExecutionModel is an intraday execution model, but it accepts any subscription resolution. On daily data the IntradayVwap indicator resets at every bar, so the "VWAP" it compares against is just that bar's typical price, and the model silently degrades into "buy below the bar midpoint, sell above it".
Nothing warns about it, and the class documentation does not say the model is intraday only, so this is easy to hit by accident.
What happens with daily data
IntradayVwap accumulates within a date only:
// Indicators/IntradayVwap.cs:41-47
// reset vwap on daily boundaries
if (_lastDate != input.EndTime.Date)
{
_sumOfVolume = 0m;
_sumOfPriceTimesVolume = 0m;
_lastDate = input.EndTime.Date;
}
and for a TradeBar it accumulates (High + Low + Close) / 3 (:103).
With Resolution.Daily every bar starts a new date, so the sums are zeroed before each accumulation and the indicator returns exactly that bar's typical price. PriceIsFavorable then reduces to:
// Algorithm.Framework/Execution/VolumeWeightedAveragePriceExecutionModel.cs:147-168
if (unorderedQuantity > 0)
{
if (data.Security.BidPrice < data.VWAP) { return true; } // bid < (H+L+C)/3
}
else
{
if (data.Security.AskPrice > data.VWAP) { return true; } // ask > (H+L+C)/3
}
Both conditions are roughly a coin flip around the bar midpoint, so the model keeps trading at random while paying the spread. Order sizing is capped at 1% of the bar's volume (MaximumOrderQuantityPercentVolume, default 0.01m), so the damage is bounded, but the result has nothing to do with VWAP. Since the model's name promises intraday execution, a user who backtests it on daily data has no way to tell that the premise does not hold.
The indicator behaviour is intended (#9703 / #9705 made Reset() consistent with it), so this is not a bug in IntradayVwap. The gap is that the model does not validate its input, and the docs do not call it out.
StandardDeviationExecutionModel does not have this problem: an SMA and standard deviation over N daily bars are meaningful.
Options
-
Documentation only — add a
<remarks>to the model (and toIntradayVwap) saying it is an intraday model, and that at daily resolution or coarser the indicator degenerates to the bar's typical price. No behaviour change, no risk. -
Reject the input — throw in
OnSecuritiesChangedwhen a security withResolution.Dailyor coarser is added, with a message pointing atImmediateExecutionModel/StandardDeviationExecutionModelfor daily algorithms. This is correct but breaks any existing algorithm that currently does this, so it needs a deliberate decision. -
Warn once —
CONTRIBUTING.mdsays framework modules must stay silent ("production code should be silent unless there is a fatal exception ... logging or debugging is not allowed inside LEAN framework modules"), and the only exceptions left inAlgorithm.FrameworkarePearsonCorrelationPairsTradingAlphaModelandOpenInterestFutureUniverseSelectionModel. So this would need an explicit waiver; mentioning it for completeness.
I would suggest 1 now and consider 2 for a future major release. Happy to open a PR with the documentation change, or with either of the others if you prefer.
Version
Verified against master at 138382568 (2026-11-02).
- Ngôn ngữ chính
- C#
- Star
- 22.4k
- Fork
- 5.4k
- Merge trung bình
- 1 ngày 22 giờ
- Pull request đã merge (30 ngày)
- 55
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của QuantConnect/Lean
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
QuantConnect/Lean#10047 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Library Request: highspyĐang mởlibrary-request
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
QuantConnect/Lean#10034 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`LeanData.TryParsePath` fails on an absolute universe file pathCó thể đã có người làm @FeiyangP đã nhận 8 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
QuantConnect/Lean#10005 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
QuantConnect/Lean#9965 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
QuantConnect/Lean#9955 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của QuantConnect/Lean
Issue tương tự
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 90/100
ShareX/XerahS#316 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
SubtitleEdit/subtitleedit#16825 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ci-flake kind:tests size:S type:bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
elsa-workflows/elsa-foundation#4058 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
games-on-whales/wolf-ui#23 ·
-
SkillsĐang mởwayfinder:grilling
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
DigiBanks99/lopen#37 ·