Daily + GLPriceCache optimizations
Some checks failed
Build .NET Project / build (push) Has been cancelled

This commit is contained in:
2026-02-27 20:43:41 -05:00
parent e633235407
commit af499ff037
2 changed files with 23 additions and 22 deletions

View File

@@ -1,15 +1,15 @@
CMTSESSIONv1.00
LastUpdated=2/26/2026 9:54:20PM
TradeDate=2/26/2026
LastUpdated=2/27/2026 8:39:15PM
TradeDate=2/27/2026
StartDate=1/1/0001
AnalysisDate=2/26/2026
AnalysisDate=2/27/2026
CashBalance=4287.320000000001
NonTradeableCash=6456.42
SuspendTrading=False|UsePriceSlopeIndicator=True|UsePriceSlopeIndicatorDays=252|AnalysisDate=2/26/2026|BetaMonths=6|TradeDate=2/26/2026|MarketCapLowerLimit=500000000|SidewaysDetection=False|SidewaysAfterDays=30|PriceTrendDays=20|CheckOutliersInReturnStream=True|DailyReturnLimit=0.25|MaxDailyPositions=3|MaxOpenPositions=3|NoTradeSymbols=CODYY,MARUY,CSTM,CS,NATI,QADA,CRTO,GTBIF,CLCT,PRSC,CMD,STAY,GBTC,YOKU,PNY,RFMD,ASAZY,USMO,VNR,STB,XIV,SYNT,DFP|OnlyTradeSymbols=|MinRSI=70|InitialCash=10000|TotalRiskPercentDecimal=0.05|PositionRiskPercentDecimal=0.12|EquityOnly=False|MinPercentReturnProximityTo52WeekHigh=30|MinPercentReturnOver52WeekLow=80|ProfitMarginCheck=True|EPSCheck=True|MinDaysBetweenReholding=30|LiquidityCheck=True|MinVolume=1000|DMA200Horizon=15|MinDaysBetweenStopAdjustments=30|MinDaysBetweenInitialStopAdjustment=5|MaxPricingExceptions=3|MACDSetup=(12,26,9)|MACDSignalDays=5|MACDRejectStrongSells=True|MACDRejectWeakSells=True|UseMarketIndicator=True|Benchmark=SPY|BenchmarkMovingAverageDays=200|BenchmarkMovingAverageHorizon=5|UseMarketIndicatorVolatility=True|UseMarketIndicatorVolatilityHorizon=60|UseMarketIndicatorVolatilityBenchmark=^VIX|UseStopLimitScaling=True|StopLimitScalingType=AverageTrueRange|StopLimitScalingVolatilityDays=30|SellOnDMABreak=True|DMABreakValues=200|DMABreakForceBreak=False|EntryType=OverExtended,MVP,PriceTrend,VolumeTrend|EntryHorizon=30|CandidateExpiryDays=180|VolumeTrendDays=10|ChannelBreakoutHorizon=40|UseOverExtendedIndicatorDays=45|UseOverExtendedIndicatorViolationThreshhold=1|UseOverExtendedIndicatorMarginPercent=1|MaxBeta=10|UseMaxBeta=False|UseProfitMaximization=True|UseProfitMaximizationExpression=R_THRESSHOLD=4;MAX_ATR=3;MULTIPLIER=MAX_ATR;IF(RMultiple>=R_THRESSHOLD){MULTIPLIER=1.2;}|UseTradeOnlySectors=False|UseTradeOnlySectorsSectors=Healthcare,Technology,Basic Materials,Consumer Defensive,Industrials|EvaluateStopOnUpTrend=False
SuspendTrading=False|UsePriceSlopeIndicator=True|UsePriceSlopeIndicatorDays=252|AnalysisDate=2/27/2026|BetaMonths=6|TradeDate=2/27/2026|MarketCapLowerLimit=500000000|SidewaysDetection=False|SidewaysAfterDays=30|PriceTrendDays=20|CheckOutliersInReturnStream=True|DailyReturnLimit=0.25|MaxDailyPositions=3|MaxOpenPositions=3|NoTradeSymbols=CODYY,MARUY,CSTM,CS,NATI,QADA,CRTO,GTBIF,CLCT,PRSC,CMD,STAY,GBTC,YOKU,PNY,RFMD,ASAZY,USMO,VNR,STB,XIV,SYNT,DFP|OnlyTradeSymbols=|MinRSI=70|InitialCash=10000|TotalRiskPercentDecimal=0.05|PositionRiskPercentDecimal=0.12|EquityOnly=False|MinPercentReturnProximityTo52WeekHigh=30|MinPercentReturnOver52WeekLow=80|ProfitMarginCheck=True|EPSCheck=True|MinDaysBetweenReholding=30|LiquidityCheck=True|MinVolume=1000|DMA200Horizon=15|MinDaysBetweenStopAdjustments=30|MinDaysBetweenInitialStopAdjustment=5|MaxPricingExceptions=3|MACDSetup=(12,26,9)|MACDSignalDays=5|MACDRejectStrongSells=True|MACDRejectWeakSells=True|UseMarketIndicator=True|Benchmark=SPY|BenchmarkMovingAverageDays=200|BenchmarkMovingAverageHorizon=5|UseMarketIndicatorVolatility=True|UseMarketIndicatorVolatilityHorizon=60|UseMarketIndicatorVolatilityBenchmark=^VIX|UseStopLimitScaling=True|StopLimitScalingType=AverageTrueRange|StopLimitScalingVolatilityDays=30|SellOnDMABreak=True|DMABreakValues=200|DMABreakForceBreak=False|EntryType=OverExtended,MVP,PriceTrend,VolumeTrend|EntryHorizon=30|CandidateExpiryDays=180|VolumeTrendDays=10|ChannelBreakoutHorizon=40|UseOverExtendedIndicatorDays=45|UseOverExtendedIndicatorViolationThreshhold=1|UseOverExtendedIndicatorMarginPercent=1|MaxBeta=10|UseMaxBeta=False|UseProfitMaximization=True|UseProfitMaximizationExpression=R_THRESSHOLD=4;MAX_ATR=3;MULTIPLIER=MAX_ATR;IF(RMultiple>=R_THRESSHOLD){MULTIPLIER=1.2;}|UseTradeOnlySectors=False|UseTradeOnlySectorsSectors=Healthcare,Technology,Basic Materials,Consumer Defensive,Industrials|EvaluateStopOnUpTrend=False
PricingExceptions=0
TotalActivePositions=2
Symbol=HWM|PurchaseDate=11/17/2025 12:00:00AM|SellDate=1/1/0001 12:00:00AM|Shares=11|PurchasePrice=200.81|CurrentPrice=260.31|Exposure=2208.91|MarketValue=2863.41|GainLoss=654.5|GainLossPcnt=0.296299985060505|PositionRiskDecimal=0.12|R=24.0336|C=276.15000000000003|P=11.490163770720992|InitialStopLimit=176.71|TrailingStopLimit=235.233001537323|TotalRiskExposure=264.3696|RMultiple=2.48R|Volatility=3.682325839996338|Volume=0|LastStopAdjustment=2/25/2026 12:00:00AM|Comment=Price changed on 11/18/2025 from $200.28 to $200.81
Symbol=FTI|PurchaseDate=11/20/2025 12:00:00AM|SellDate=1/1/0001 12:00:00AM|Shares=41|PurchasePrice=43.23|CurrentPrice=67.29|Exposure=1772.4299999999998|MarketValue=2758.8900000000003|GainLoss=986.4600000000005|GainLossPcnt=0.5565579458709233|PositionRiskDecimal=0.12|R=5.2188|C=218.45950000000005|P=41.86010193914311|InitialStopLimit=38.04|TrailingStopLimit=62.83571408271789|TotalRiskExposure=213.9708|RMultiple=4.61R|Volatility=0.825829267501831|Volume=0|LastStopAdjustment=2/25/2026 12:00:00AM|Comment=Price changed on 11/21/2025 from $43.49 to $43.23
Symbol=HWM|PurchaseDate=11/17/2025 12:00:00AM|SellDate=1/1/0001 12:00:00AM|Shares=11|PurchasePrice=200.81|CurrentPrice=262.53|Exposure=2208.91|MarketValue=2887.83|GainLoss=678.9200000000001|GainLossPcnt=0.30735521139385497|PositionRiskDecimal=0.12|R=24.0336|C=276.15000000000003|P=11.490163770720992|InitialStopLimit=176.71|TrailingStopLimit=235.233001537323|TotalRiskExposure=264.3696|RMultiple=2.57R|Volatility=3.682325839996338|Volume=0|LastStopAdjustment=2/25/2026 12:00:00AM|Comment=Price changed on 11/18/2025 from $200.28 to $200.81
Symbol=FTI|PurchaseDate=11/20/2025 12:00:00AM|SellDate=1/1/0001 12:00:00AM|Shares=41|PurchasePrice=43.23|CurrentPrice=66.31|Exposure=1772.4299999999998|MarketValue=2718.71|GainLoss=946.2800000000002|GainLossPcnt=0.5338885033541524|PositionRiskDecimal=0.12|R=5.2188|C=218.45950000000005|P=41.86010193914311|InitialStopLimit=38.04|TrailingStopLimit=62.83571408271789|TotalRiskExposure=213.9708|RMultiple=4.42R|Volatility=0.825829267501831|Volume=0|LastStopAdjustment=2/25/2026 12:00:00AM|Comment=Price changed on 11/21/2025 from $43.49 to $43.23
TotalPositions=133
Symbol=CDNS|PurchaseDate=8/25/2020 12:00:00AM|SellDate=9/3/2020 12:00:00AM|Shares=16|PurchasePrice=111.82|CurrentPrice=109.57|Exposure=1789.12|MarketValue=1753.12|GainLoss=-36|GainLossPcnt=-0.020121624038633518|PositionRiskDecimal=0.12|R=13.3512|C=225.6365|P=16.900091377554077|InitialStopLimit=97.9088|TrailingStopLimit=109.599856939316|TotalRiskExposure=213.6192|RMultiple=-0.17R|Volatility=2.3209912776947|Volume=1767980|LastStopAdjustment=9/2/2020 12:00:00AM|Comment=Manual close.
Symbol=LULU|PurchaseDate=8/28/2020 12:00:00AM|SellDate=9/4/2020 12:00:00AM|Shares=3|PurchasePrice=377.5|CurrentPrice=370.23|Exposure=1132.5|MarketValue=1110.69|GainLoss=-21.809999999999945|GainLossPcnt=-0.019258278145695317|PositionRiskDecimal=0.12|R=45.2976|C=136.6285|P=3.016241478577231|InitialStopLimit=332.1824|TrailingStopLimit=372.562428512573|TotalRiskExposure=135.89280000000002|RMultiple=-0.16R|Volatility=25.858959197998|Volume=2871665|LastStopAdjustment=9/2/2020 12:00:00AM|Comment=Manual close.

View File

@@ -17,9 +17,25 @@ namespace MarketData.Cache
private static GLPriceCache instance = null;
// -- Disposal -------------------------------------------------------------
private volatile bool disposed = false;
private int refreshInProgress = 0;
// -- State ----------------------------------------------------------------
private readonly Dictionary<string, PricesByDate> priceCache = new Dictionary<string, PricesByDate>();
private readonly ConcurrentDictionary<string, object> symbolFetchLocks = new ConcurrentDictionary<string, object>();
private readonly object cacheLock = new object();
private DateTime latestDate = Utility.Epoch;
// -- Background refresh ---------------------------------------------------
private readonly TimeSpan cacheCycle = TimeSpan.FromMinutes(5);
private Timer refreshTimer = null;
private int tickCount = 0;
// private const int evictionTickInterval = 12; // every 12 ticks x 5 min = 1 hour
private const int evictionTickInterval = 144; // every 144 ticks x 5 min interval length = 12 hour. (144 intervals *5 minutes )/60 minutes = 12 hours
// -- Parallelism ----------------------------------------------------------
private static readonly int maxParallelDbCalls = ResolveMaxParallelDbCalls();
/// <summary>
///
/// </summary>
@@ -33,21 +49,6 @@ namespace MarketData.Cache
}
}
// -- State ----------------------------------------------------------------
private readonly Dictionary<string, PricesByDate> priceCache = new Dictionary<string, PricesByDate>();
private readonly ConcurrentDictionary<string, object> symbolFetchLocks = new ConcurrentDictionary<string, object>();
private readonly object cacheLock = new object();
private DateTime latestDate = Utility.Epoch;
// -- Background refresh ---------------------------------------------------
private readonly TimeSpan cacheCycle = TimeSpan.FromMinutes(5);
private Timer refreshTimer = null;
private int tickCount = 0;
private const int evictionTickInterval = 12; // every 12 ticks x 5 min = 1 hour
// -- Parallelism ----------------------------------------------------------
private static readonly int maxParallelDbCalls = ResolveMaxParallelDbCalls();
private static int ResolveMaxParallelDbCalls()
{
return Math.Min(Math.Max(1, Environment.ProcessorCount) * 3, 32);