SecurityExchangeHours.GetNextMarketClose returns midnight when the next day has an early close (GetNextOrPreviousSegment)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 66/100
Línea de trabajo
Start in Common/Securities/SecurityExchangeHours.cs at GetNextOrPreviousSegment, then trace how GetNextMarketClose uses its result for a session crossing midnight. The issue provides a synthetic exchange-hours reproduction with an early close at 12:00; use it to check the behavior. Done means the reproduced call returns the next day's 12:00 close while existing market-hours behavior remains correct.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Expected Behavior
For a market that trades continuously across midnight, GetNextMarketClose(t, extendedMarketHours: true) should return the end of the continuous session. If the next day has an early close at 12:00, the session that starts at 17:00 the day before should close at 12:00 of the next day.
Actual Behavior
It returns 00:00 (midnight) of the next day, as if the market closed at midnight.
Potential Solution
In Common/Securities/SecurityExchangeHours.cs, GetNextOrPreviousSegment returns null whenever _earlyCloses contains the adjacent date, without checking whether that day's first segment starts at 00:00. GetNextMarketClose then loses the continuity information and returns the end of the current day's segment (midnight). GetMarketHours itself returns the correct segments for that day (00:00–12:00 and, with a late open, 17:00–24:00), so returning the effective first segment from GetMarketHours(nextDay) instead of null seems to fix it.
Reproducing the Problem
Synthetic exchange hours only (no data, no subscription):
var day = new DateTime(2023, 11, 23);
MarketHoursSegment Seg(int s, int e) => new(MarketHoursState.Market, TimeSpan.FromHours(s), TimeSpan.FromHours(e));
var weekly = new Dictionary<DayOfWeek, LocalMarketHours>();
foreach (var d in Enum.GetValues<DayOfWeek>())
weekly[d] = new LocalMarketHours(d, d switch
{
DayOfWeek.Saturday => Array.Empty<MarketHoursSegment>(),
DayOfWeek.Sunday => new[] { Seg(17, 24) },
DayOfWeek.Friday => new[] { Seg(0, 16) },
_ => new[] { Seg(0, 16), Seg(17, 24) }
});
var hours = new SecurityExchangeHours(TimeZones.Chicago, Array.Empty<DateTime>(), weekly,
new Dictionary<DateTime, TimeSpan> { [day] = TimeSpan.FromHours(12) }, // early close
new Dictionary<DateTime, TimeSpan>());
var close = hours.GetNextMarketClose(day.AddDays(-1).AddHours(17), true);
Console.WriteLine(close); // expected 2023-11-23 12:00, actual 2023-11-23 00:00
Without the early close the same call returns 2023-11-23 16:00, as expected. Adding a late open at 17:00 on the same day does not change the result. IsOpen(2023-11-23 00:00) is true, so the market is open on both sides of midnight.
This affects any logic built on GetNextMarketClose around early-close days (Thanksgiving, Christmas Eve, etc.) for futures trading across midnight. For example, a scheduled "before market close" event or a daily consolidator would see an artificial close at midnight.
System Information
LEAN master at commit 22404ea28 (26-10-2026), QuantConnect.Common 2.5.0.0, .NET 10.0.14, Linux.
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 14 h
- PR fusionados (30 d)
- 53
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 78/100
QuantConnect/Lean#10005 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
QuantConnect/Lean#9965 ·
Los mantenedores suelen responder en 1 día
-
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 feeQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. 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
Todos los issues de QuantConnect/Lean
Issues similares
-
[Format]: .dartAbiertoformats
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
KnifeLemon/Filee#980 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
bug effort:S P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
nightscout/nocturne#3219 ·
Los mantenedores suelen responder en 1 día
-
good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
bug P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día