Histogram successfully pulls data from database when data exists.

This commit is contained in:
caspar 2026-03-19 06:01:54 -04:00
parent 9c8d563aef
commit f9ba5369bd

View File

@ -90,7 +90,18 @@ Console.WriteLine(raw);
_ => throw new ArgumentOutOfRangeException(nameof(barSize))
};
return Math.Max(1, (int)Math.Floor(duration.TotalSeconds / secondsPerBar));
// Markets trade ~6.5 hours/day, 5 days/week — not 24/7 calendar time.
// Intraday fraction: (6.5h × 5 days) / (24h × 7 days) ≈ 0.194
// Daily/weekly fraction (weekdays only): 5 / 7 ≈ 0.714
// Monthly bars already map 1:1 to calendar months, no adjustment needed.
double marketFraction = barSize switch
{
HistoricalBarSize.OneMonth => 1.0,
HistoricalBarSize.OneDay or HistoricalBarSize.FiveDays => 5.0 / 7.0,
_ => (6.5 * 5.0) / (24.0 * 7.0)
};
return Math.Max(1, (int)Math.Floor(duration.TotalSeconds * marketFraction / secondsPerBar));
}
}
}