/// <summary> /// /// Set vintage market pricing by in argument portfoliosPrices /// /// </summary> /// <param name="vintageShares"></param> /// <param name="portfoliosPricesDto"></param> private void SetVintageMarketPricing(VintageSharesDto vintageShares, PortfolioPricesDto portfoliosPricesDto) { vintageShares.PresentMarketPrice = vintageShares.LowRiskShares * (decimal)portfoliosPricesDto.ConservativePortfolioPrice + vintageShares.MediumRiskShares * (decimal)portfoliosPricesDto.MediumPortfolioPrice + vintageShares.HighRiskShares * (decimal)portfoliosPricesDto.HighPortfolioPrice; vintageShares.TradingDay = DbExpressions.GetDtYearMonthDay(portfoliosPricesDto.YearMonthDay); }
/// <summary> /// /// Calculate the vintage in latest portfolio market value /// /// </summary> /// <param name="customerId"></param> /// <param name="vintageToBeLiquidated"></param> /// <param name="portfolioPrices"></param> /// <param name="vintageSharesDto"></param> /// <param name="fees"></param> /// <returns></returns> private decimal GetVintageValuePricedNow( int customerId, VintageDto vintageToBeLiquidated, PortfolioPricesDto portfolioPrices, out VintageSharesDto vintageSharesDto, out FeesDto fees) { var presentMonth = DateTime.UtcNow.ToStringYearMonth(); // Sales after the completion of one month only, have earned no interest var sellingInFollowingMonth = DbExpressions.AddMonth(vintageToBeLiquidated.YearMonthStr); if (sellingInFollowingMonth == presentMonth) { vintageSharesDto = new VintageSharesDto() { HighRiskShares = 0m, MediumRiskShares = 0m, LowRiskShares = 0m, PresentMarketPrice = vintageToBeLiquidated.MarketPrice = vintageToBeLiquidated.InvestmentAmount }; } // Sales post 2 or more months else { vintageSharesDto = userPortfolioSharesRepo.GetVintageSharesMarketValue( customerId, vintageToBeLiquidated.YearMonthStr, portfolioPrices); } // Obsolete Special case: SALE within same month (ref alaa) // if vintageToBeSold month = current month (early cashout in same month) // value of vintage is what's not withdrawn from the month's investment cash if (vintageToBeLiquidated.YearMonthStr == DateTime.UtcNow.ToStringYearMonth()) { vintageSharesDto.PresentMarketPrice = vintageToBeLiquidated.InvestmentAmount - vintageToBeLiquidated.SellingValue - vintageToBeLiquidated.SoldFees; } fees = gzTransactionRepo.GetWithdrawnFees( vintageToBeLiquidated.InvestmentAmount, vintageToBeLiquidated.YearMonthStr, vintageSharesDto.PresentMarketPrice); return(vintageSharesDto.PresentMarketPrice); }
/// <summary> /// /// Calculate the present value of a vintage shares. /// /// </summary> /// <param name="customerId"></param> /// <param name="vintageYearMonthStr"></param> /// <param name="latestPortfoliosPrices"></param> /// <returns></returns> public VintageSharesDto GetVintageSharesMarketValue(int customerId, string vintageYearMonthStr, PortfolioPricesDto latestPortfoliosPrices) { var vintageShares = GetVintagePortfolioSharesDto(customerId, vintageYearMonthStr); SetVintageMarketPricing(vintageShares, latestPortfoliosPrices); return(vintageShares); }