MarketProfile value area loop never ends when valueAreaVolumePercentage is 1
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 72/100
Línea de trabajo
Empieza con Indicators/MarketProfile.cs e inspecciona CalculateValueArea, especialmente cómo se comporta el bucle después de que ambos índices de nivel de precio alcanzan los límites del perfil. Comprueba las rutas de actualización de VolumeProfile y TimeProfile usando un porcentaje de área de valor de 1. La tarea estará terminada cuando ambas actualizaciones retornen y el área de valor abarque desde el nivel de precio más bajo hasta el más alto.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- C#
- Estrellas
- 22.3k
- Forks
- 5.4k
- Merge medio
- 1 d 5 h
- PR fusionados (30 d)
- 56
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de QuantConnect/Lean
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
QuantConnect/Lean#9955 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
QuantConnect/Lean#9953 ·
Los mantenedores suelen responder en 1 día
-
WebullFeeModel charges SPXW options the SPX exchange feePosiblemente ocupada @Amadeus-22 la tomó hace 10 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
QuantConnect/Lean#9922 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
AlpacaBrokerageModel refuses extended-hours limit orders with the GTC time in force, which Alpaca acceptsPosiblemente ocupada @AlexCatarino la tomó hace 18 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
QuantConnect/Lean#9892 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
library-request
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
QuantConnect/Lean#9879 ·
Los mantenedores suelen responder en 1 día
Todos los issues de QuantConnect/Lean
Issues similares
-
Add dependency list in documentsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
Los mantenedores suelen responder en 3 días
-
Add 'upm' tag on githubAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
bug mac アプリ: コード アプリ: チャット 優先: 中 要トリアージ
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
yksr-melt/Meltype#1346 · 2 comentarios ·
Los mantenedores suelen responder en 1 día