Fix GetMonthlyPrices in Prices. It was not correctly returning monthly prices.

This was causing an issue in the SharpeRatioGenerator whereby the SharpeRatio was not being calculated correctly where the asof date would
fall on a weekend of holiday.
Also, added a ReasonCategory to the CMCanidate as well as a Violation summary line in the model output to show where violations occur.
Had I implemented this previously I might have detected the SharpeRatio issue sooner.
Also added GetFundamentalMaxDateTop in the FundamentalDA which I used during debugging but is not currently being used anywhere.
This commit is contained in:
2025-02-02 14:59:14 -05:00
parent 4b9be6bc12
commit 2882559651
7 changed files with 183 additions and 34 deletions

View File

@@ -281,7 +281,7 @@ namespace MarketData.MarketDataModel
DateTime minPricingDate = PricingDA.GetEarliestDate(symbol);
Dictionary<DateTime, Price> symbolPricesByDate = new Dictionary<DateTime, Price>();
List<DateTime> historicalDates = new List<DateTime>();
while (historicalDates.Count < (months + 1))
while (historicalDates.Count < (months + 5)) // pad the months by 5
{
historicalDates.Add(startDate);
startDate = dateGenerator.GetPrevMonthStart(startDate);
@@ -290,10 +290,11 @@ namespace MarketData.MarketDataModel
Prices symbolPrices = PricingDA.GetPrices(symbol, requestStartDate, historicalDates[historicalDates.Count - 1]);
foreach (Price price in symbolPrices) symbolPricesByDate.Add(price.Date, price);
startDate = dateGenerator.GetCurrMonthStart(asof);
if(startDate>asof)startDate = dateGenerator.GetPrevMonthStart(asof); // if start date winds up > asof on account of a weekend or holiday then fall back a further month
while (prices.Count < (months + 1))
{
Price price = GetPrice(symbol, startDate, symbolPricesByDate);
if (null == price) return null;
if(null == price)return null;
prices.Add(price);
startDate = dateGenerator.GetPrevMonthStart(startDate);
if (startDate < minPricingDate) break;