RelativeDailyVolume merges sparse sessions sharing a day-of-month

Open Beginner friendly
#10,199 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
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
data

Research direction

Read Indicators/RelativeDailyVolume.cs around lines 85–104 and find the session-change comparison that uses input.Time.Day. Then locate the existing RelativeDailyVolume tests and add a regression case that readies the indicator before sparse updates on distinct calendar dates with the same day-of-month. Done when the later update rolls the session over and the reported ratio is 0.5.

Written by the indexing model from the issue text.

Description

priority:p2

Problem

RelativeDailyVolume detects a session change by comparing only input.Time.Day. If sparse updates skip to the same day-of-month in a later month, it treats the new session as the old one, keeps the old volume in the numerator and fails to advance its historical state.

Source: Indicators/RelativeDailyVolume.cs, lines 85–104.

Reproduction

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

var symbol = new Symbol(SecurityIdentifier.GenerateEquity("SPY", Market.USA, false), "SPY");
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(new DateTime(2024, 1, 14, 9, 30, 0), 100));
rdv.Update(Bar(new DateTime(2024, 1, 15, 9, 30, 0), 100));
rdv.Update(Bar(new DateTime(2024, 2, 15, 9, 30, 0), 50));
Console.WriteLine($"{rdv.IsReady}: {rdv.Current.Value}");

Executed result: True: 1.5. Expected: True: 0.5.

The January 15 update makes the period-1 indicator ready. February 15 has the same .Day value, so January's volume 100 remains in _currentData; the ratio becomes (100 + 50) / 100 instead of 50 / 100.

Required result

Distinct calendar dates must trigger session rollover even when their day-of-month values match. Add a regression test with an already-ready indicator and sparse updates across a month-long gap. This does not ask to invent data for dates with no updates.

Priority is low: the demonstrated case needs a long gap in input, rather than ordinary consecutive-session updates.

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.