MarketProfile value area loop never ends when valueAreaVolumePercentage is 1
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
- 72/100
Hướng nghiên cứu
Bắt đầu với Indicators/MarketProfile.cs và kiểm tra CalculateValueArea, đặc biệt là cách vòng lặp hoạt động sau khi cả hai chỉ số mức giá chạm đến rìa của profile. Kiểm tra các đường cập nhật VolumeProfile và TimeProfile với tỷ lệ vùng giá trị là 1. Hoàn thành khi cả hai lần cập nhật đều trả về và vùng giá trị trải dài từ mức giá thấp nhất đến mức giá cao nhất.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Expected Behavior
VolumeProfile and TimeProfile accept a valueAreaVolumePercentage of 1 in their constructors. With that value the value area should cover the whole profile: after each update ValueAreaLow is the lowest price level, ValueAreaHigh is the highest, and the indicator returns like it does for any other percentage.
Actual Behavior
With valueAreaVolumePercentage = 1 the first Update never returns. MarketProfile.CalculateValueArea spins forever, so any algorithm using VP(period, 1) or TP(period, 1) hangs on its first bar.
Potential Solution
CalculateValueArea (Indicators/MarketProfile.cs) loops with
while (currentVolume <= ValueAreaVolume && ValueAreaVolume != 0)
where ValueAreaVolume = totalVolume * _valueAreaVolumePercentage. With a percentage of 1 the target is the total volume, so currentVolume <= ValueAreaVolume is still true once the area covers every price level. At that point nextMinIndex == lastMin and nextMaxIndex == lastMax, so lowVolume and highVolume are both 0. The first branch (highVolume == 0) is taken, adds 0 to currentVolume, and leaves minIndex unchanged. The final else { break; } is unreachable, so the loop never exits.
Fix: stop the loop when the area can't grow any further, i.e. when both nextMinIndex == lastMin and nextMaxIndex == lastMax (or equivalently when lowVolume == 0 && highVolume == 0). Results for percentages below 1 are unaffected since the loop already terminates before the edges in those cases. PR #9958 implements this.
Reproducing the Problem
var vp = new VolumeProfile(period: 3, valueAreaVolumePercentage: 1m);
var time = new DateTime(2024, 1, 1);
vp.Update(new TradeBar(time, Symbols.SPY, 100m, 100m, 100m, 100m, 1000m)); // never returns
Multiple price levels also hang:
var vp = new VolumeProfile(period: 3, valueAreaVolumePercentage: 1m);
vp.Update(new TradeBar(time, Symbols.SPY, 100m, 100m, 100m, 100m, 1000m));
vp.Update(new TradeBar(time.AddMinutes(1), Symbols.SPY, 101m, 101m, 101m, 101m, 500m));
vp.Update(new TradeBar(time.AddMinutes(2), Symbols.SPY, 102m, 102m, 102m, 102m, 200m));
Running either in a task with a 10 second timeout times out on master. The same applies to TimeProfile, which shares CalculateValueArea.
System Information
Reproducible on current master (2e55894c8), any OS. Reported from Ubuntu with .NET SDK 10.0.403.
Checklist
- I have completely filled out this template
- I have confirmed that this issue exists on the current
masterbranch - I have confirmed that this is not a duplicate issue by searching issues
- I have provided detailed steps to reproduce the issue
- Ngôn ngữ chính
- C#
- Star
- 22.3k
- Fork
- 5.4k
- Merge trung bình
- 1 ngày 5 giờ
- Pull request đã merge (30 ngày)
- 56
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 82/100
QuantConnect/Lean#9955 ·
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 85/100
QuantConnect/Lean#9953 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
WebullFeeModel charges SPXW options the SPX exchange feeCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
QuantConnect/Lean#9922 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
library-request
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
QuantConnect/Lean#9879 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Library Upgrade] autogluonĐang mởlibrary-request
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
QuantConnect/Lean#9743 ·
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ó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
possible bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
Include host.wslc.internal in the HTTPS development certificateCó thể đã có người làm @afscrome đã nhận hôm nay. Đang mởarea-commandlinetools
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
dotnet/aspnetcore#70122 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
:1st_place_medal: good first issue :cowboy_hat_face: refactor :roller_coaster: enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ApplETS/Backend-Hello#78 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 2 ngày