Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

MarketProfile value area loop never ends when valueAreaVolumePercentage is 1

Abierto Apto para principiantes
#9,965 0 comentarios 0 reacciones 0 asignados Ver en GitHub

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
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
csharp
Área
backend

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 master branch
  • 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

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de QuantConnect/Lean

Todos los issues de QuantConnect/Lean

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.