Optimize GainLossController
This commit is contained in:
@@ -157,11 +157,10 @@ namespace MarketDataServer.Controllers
|
||||
gainLossSummaryItemDetail.DividendYield = weightAdjustedDividendYield;
|
||||
gainLossSummaryItemDetail.AnnualDividend = exposure * weightAdjustedDividendYield;
|
||||
}
|
||||
DateGenerator dateGenerator = new DateGenerator();
|
||||
DateTime priorDate = dateGenerator.FindPrevBusinessDay(currentDate);
|
||||
Price p1 = PricingDA.GetPrice(gainLossSummaryItem.Symbol, currentDate);
|
||||
Price p2 = PricingDA.GetPrice(gainLossSummaryItem.Symbol, priorDate);
|
||||
|
||||
Prices prices = LocalPriceCache.GetInstance().GetPrices(gainLossSummaryItem.Symbol, currentDate, 3); // cache should be refreshed after GainLossSummaryItemCollection
|
||||
// Prices prices = PricingDA.GetPrices(gainLossSummaryItem.Symbol, currentDate, 2);
|
||||
Price p1 = prices.Count>0?prices[0]:default;
|
||||
Price p2 = prices.Count>1?prices[1]:default;
|
||||
PortfolioTrades symbolTrades = new PortfolioTrades(portfolioTrades.Where(x=>x.Symbol.Equals(gainLossSummaryItem.Symbol)).ToList());
|
||||
ParityElement parityElement = ParityGenerator.GenerateBreakEven(symbolTrades, p1);
|
||||
gainLossSummaryItemDetail.ParityElement = parityElement;
|
||||
@@ -170,11 +169,6 @@ namespace MarketDataServer.Controllers
|
||||
gainLossSummaryItemDetail.AllTimeGainLossPercent = gainLossItem.GainLossPercent;
|
||||
gainLossSummaryItemDetail.PercentDistanceFromAllTimeGainLossPercent = parityElement.ParityOffsetPercent - (gainLossItem.GainLossPercent / 100);
|
||||
}
|
||||
if (null == p2 && null != p1)
|
||||
{
|
||||
priorDate = dateGenerator.FindPrevBusinessDay(priorDate);
|
||||
p2 = PricingDA.GetPrice(gainLossSummaryItem.Symbol, priorDate);
|
||||
}
|
||||
if (null != p1 && null != p2)
|
||||
{
|
||||
double change = (p1.Close - p2.Close) / p2.Close;
|
||||
|
||||
Reference in New Issue
Block a user