/// <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> /// /// Unit Test Supporting verson /// /// Calculate the vintage in portfolio market value for a given month. /// /// </summary> /// <param name="customerId"></param> /// <param name="vintageCashInvestment"></param> /// <param name="vintageYearMonthStr"></param> /// <param name="sellOnThisYearMonth"></param> /// <param name="vintageSharesDto"></param> /// <param name="fees"></param> /// <returns></returns> private decimal GetVintageValuePricedOn( int customerId, decimal vintageCashInvestment, string vintageYearMonthStr, string sellOnThisYearMonth, out VintageSharesDto vintageSharesDto, out FeesDto fees) { vintageSharesDto = userPortfolioSharesRepo.GetVintageSharesMarketValueOn( customerId, vintageYearMonthStr, sellOnThisYearMonth); fees = gzTransactionRepo.GetWithdrawnFees(vintageCashInvestment, vintageYearMonthStr, vintageSharesDto.PresentMarketPrice); return(vintageSharesDto.PresentMarketPrice); }
/// <summary> /// /// ** Unit Test Helper ** /// /// Calculate the latest portfolio prices of the In parameter shares collection. /// /// To be used for selling shares not for calculating balances. /// /// </summary> /// <param name="vintageShares"></param> /// <param name="sellOnThisYearMonth"></param> private void SetPortfolioSharesValueOn(VintageSharesDto vintageShares, string sellOnThisYearMonth) { var latestPortfoliosPrices = GetPortfolioSharePriceOn(sellOnThisYearMonth); SetVintageMarketPricing(vintageShares, latestPortfoliosPrices); }