RelativeDailyVolume returns zero after the final historical time slot

Open Beginner friendly
#10,198 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
data, testing

Research direction

Read Indicators/RelativeDailyVolume.cs around lines 111–138 and trace how it selects the historical cumulative volume for a requested time. Find the existing RelativeDailyVolume tests and add a case where the current time is after the final historical slot; verify the result uses the latest available cumulative volume and preserves the interior-gap behavior covered by #9629.

Written by the indexing model from the issue text.

Description

priority:p2

Problem

When the current time-of-day is later than every historical time slot, RelativeDailyVolume leaves its fallback denominator at zero and returns zero despite having a nonzero historical cumulative volume.

Source: Indicators/RelativeDailyVolume.cs, lines 111–138.

This is a boundary case distinct from #9629: the existing break fixes selection between historical slots, but no loop iteration assigns a denominator after the final slot. A historical early close followed by a longer trading session can reach this path.

Reproduction

using System;
using QuantConnect;
using QuantConnect.Data.Market;
using QuantConnect.Indicators;

var symbol = new Symbol(SecurityIdentifier.GenerateEquity("SPY", Market.USA, false), "SPY");
var start = new DateTime(2024, 1, 2, 9, 30, 0);
TradeBar Bar(DateTime time, decimal volume) =>
    new TradeBar(time, symbol, 9, 10, 9, 10, volume, TimeSpan.FromMinutes(1));
var rdv = new RelativeDailyVolume(1);
rdv.Update(Bar(start, 100));
rdv.Update(Bar(start.AddMinutes(1), 100));
rdv.Update(Bar(start.AddDays(1).AddMinutes(2), 50));
Console.WriteLine($"{rdv.IsReady}: {rdv.Current.Value}");

Executed result: True: 0. Expected: True: 0.25.

The completed historical day has cumulative volumes 100 at 09:30 and 200 at 09:31. At 09:32, the latest historical cumulative volume is still 200, so the ratio is 50 / 200 = 0.25. No historical key is greater than 09:32, and the fallback never assigns that value.

Required result

Use the most recent available historical cumulative volume when the requested time is after the final historical slot. Add a regression test for this boundary without changing the interior-gap behavior covered by #9629.

Priority is low pending evidence of broader impact; this is limited to unmatched times beyond the historical range.

Dominant language
C#
Stars
22.6k
Forks
5.4k
Avg merge
11h 39m
Merged PRs (30d)
104

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from QuantConnect/Lean

All issues in QuantConnect/Lean

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.