MarketProfile value area loop never ends when valueAreaVolumePercentage is 1
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Indicators/MarketProfile.csから始めてCalculateValueAreaを調べ、特に価格レベルの両方のインデックスがプロファイルの端に達した後のループの動作を確認してください。VolumeProfileとTimeProfileの更新経路を、バリューエリアの割合を1にして確認してください。両方の更新が戻り、バリューエリアが最低価格レベルから最高価格レベルまでを含めば完了です。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- C#
- スター
- 22.3k
- フォーク
- 5.4k
- 平均マージ
- 1日 6時間
- マージ済み PR(30日)
- 37
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
QuantConnect/Lean のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
QuantConnect/Lean#9957 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
QuantConnect/Lean#9955 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
QuantConnect/Lean#9953 ·
メンテナーはふだん 1 日以内に返信
-
WebullFeeModel charges SPXW options the SPX exchange fee対応中かも @Amadeus-22 が 10 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
QuantConnect/Lean#9922 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
TradeStationBrokerageModel rejects extended-hours limit orders on equity options対応中かも @AlexCatarino が 9 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
QuantConnect/Lean#9920 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
QuantConnect/Lean の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Street address filter matches across line breaks and reads "Dr." in a greeting as a street suffixオープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
philterd/phileas-dotnet#185 ·
-
bug 優先: 低
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100