More optimizations and code cleanup

This commit is contained in:
2025-04-08 12:54:22 -04:00
parent 7dafbc3af1
commit d4944607ab
4 changed files with 7 additions and 11 deletions

View File

@@ -24,7 +24,6 @@ namespace MarketData.Generator.GainLoss
if (null == portfolioTrades || 0 == portfolioTrades.Count) return null;
LocalPriceCache.GetInstance().Add(portfolioTrades);
DateTime minTradeDate = portfolioTrades.GetMinTradeDate();
// DateTime maxDate = PricingDA.GetLatestDate();
DateTime maxDate=LocalPriceCache.GetInstance().GetLatestDate();
if(null!=maxDateRef)maxDate=maxDateRef.Value;
Dictionary<DateTime,GainLossItem> gainLoss = new Dictionary<DateTime, GainLossItem>();

View File

@@ -24,7 +24,6 @@ namespace MarketData.Generator.GainLoss
if (null == portfolioTrades || 0 == portfolioTrades.Count) return null;
LocalPriceCache.GetInstance().Add(portfolioTrades);
DateTime minTradeDate = portfolioTrades.GetMinTradeDate();
// DateTime maxDate = PricingDA.GetLatestDate();
DateTime maxDate=LocalPriceCache.GetInstance().GetLatestDate();
if(null!=maxDateRef)maxDate=maxDateRef.Value;
Dictionary<DateTime,TotalGainLossItem> gainLossCollection = new Dictionary<DateTime, TotalGainLossItem>();
@@ -77,7 +76,6 @@ namespace MarketData.Generator.GainLoss
if (null == portfolioTrades || 0 == portfolioTrades.Count) return null;
LocalPriceCache.GetInstance().Add(portfolioTrades);
DateTime minTradeDate = portfolioTrades.GetMinTradeDate();
// DateTime maxDate = PricingDA.GetLatestDate();
DateTime maxDate=LocalPriceCache.GetInstance().GetLatestDate();
if(null!=maxDateRef)maxDate=maxDateRef.Value;
Dictionary<DateTime,TotalGainLossItem> gainLossCollection = new Dictionary<DateTime, TotalGainLossItem>();

View File

@@ -24,7 +24,7 @@ namespace MarketData.Generator.GainLoss
{
if(!ValidatePortfolioTrades(portfolioTrades))return null;
DateTime minDate=portfolioTrades.GetMinTradeDate();
DateTime maxDate=PricingDA.GetLatestDate();
DateTime maxDate = LocalPriceCache.GetInstance().GetLatestDate();
if(null!=maxDateRef) maxDate=maxDateRef.Value;
double prevGainLoss=double.NaN;
List<DateTime> historicalDates=dateGenerator.GenerateHistoricalDates(minDate,maxDate);
@@ -103,9 +103,8 @@ namespace MarketData.Generator.GainLoss
{
if(!ValidatePortfolioTrades(portfolioTrades)) return null;
DateTime minDate=portfolioTrades.Min(x => x.TradeDate);
DateTime maxDate=PricingDA.GetLatestDate();
DateTime maxDate = LocalPriceCache.GetInstance().GetLatestDate();
double prevGainLoss=double.NaN;
// LocalPriceCache.GetInstance().RemoveDate(maxDate);
List<DateTime> historicalDates=dateGenerator.GenerateHistoricalDates(minDate,maxDate);
foreach(DateTime currentDate in historicalDates)
@@ -124,11 +123,6 @@ namespace MarketData.Generator.GainLoss
foreach(PortfolioTrade openPosition in openPositions)
{
exposure+=openPosition.Shares*openPosition.Price;
//if(!LocalPriceCache.GetInstance().ContainsPrice(openPosition.Symbol,currentDate))
//{
// Prices prices=PricingDA.GetPricesForward(openPosition.Symbol,currentDate,90);
// LocalPriceCache.GetInstance().Add(prices);
//}
Price price=LocalPriceCache.GetInstance().GetPrice(openPosition.Symbol,currentDate);
if(null==price)
{

View File

@@ -6,6 +6,11 @@ TO-DO
dotnet add package Microsoft.AspNet.WebApi.SelfHost --version 5.3.0
dotnet add package System.ServiceModel.Primitives --version 4.0.0
Git Delete Remote Branch
git push <remote_name> --delete <branch_name>
git push origin --delete <branch_name>
Please use the Microsoft.AspNet.WebApi.OwinSelfHost package for new projects.
Microsoft.AspNet.WebApi.OwinSelfHost