示例#1
0
 public async Task <PositionVM> GetCalculatedMandates(PositionVM posObj, FundOfMandates fundobj)
 {
     try
     {
         if (posObj.Code == fundobj.InstrumentCode)
         {
             List <MandateVM> MandateListObj = new List <MandateVM>();
             foreach (var mandate in fundobj.Mandates)
             {
                 MandateVM MandateObj = new MandateVM();
                 MandateObj.Name       = mandate.MandateName;
                 MandateObj.Allocation = mandate.Allocation;
                 MandateObj.Value      = Math.Round(posObj.Value * (mandate.Allocation / 100));
                 MandateListObj.Add(MandateObj);
             }
             posObj.Mandates = MandateListObj;
             if (fundobj.LiquidityAllocation > 0)
             {
                 MandateVM Liquidity = new MandateVM();
                 Liquidity.Name       = "Liquidity";
                 Liquidity.Allocation = fundobj.LiquidityAllocation;
                 Liquidity.Value      = Math.Round((posObj.Value - MandateListObj.Select(x => x.Value).Sum()) * (fundobj.LiquidityAllocation));
                 MandateListObj.Add(Liquidity);
             }
         }
         return(await Task.Run(() => { return posObj; }));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.ToString());
     }
 }
示例#2
0
 /// <summary>
 /// Get Calculated Mandates
 /// </summary>
 /// <param name="portfolioVM"></param>
 /// <param name="fundsOfMandates"></param>
 /// <returns></returns>
 public List <PositionVM> GetCalculatedMandates(PortfolioVM portfolioVM, List <FundOfMandates> fundsOfMandates)
 {
     portfolioVM.Positions.ForEach(position => {
         FundOfMandates fund = fundsOfMandates.Where(funds => funds.InstrumentCode == position.Code).FirstOrDefault();
         if (fund != null)
         {
             position.Mandates = new List <MandateVM>();
             fund.Mandates.ToList().ForEach(mandate => {
                 MandateVM mandateVM  = new MandateVM();
                 mandateVM.Name       = mandate.MandateName;
                 mandateVM.Allocation = (mandate.Allocation / 100);
                 mandateVM.Value      = (mandate.Allocation / 100) * position.Value;
                 position.Mandates.Add(mandateVM);
             });
             if (fund.LiquidityAllocation > 0)
             {
                 position.Mandates.Add(new MandateVM
                 {
                     Name       = "Liquidity",
                     Allocation = (fund.LiquidityAllocation / 100),
                     Value      = (fund.LiquidityAllocation / 100) * position.Value
                 });
             }
         }
     });
     return(portfolioVM.Positions);
 }
示例#3
0
        /// <summary>
        ///Method to calculate the Mandates position under the fundofmandates
        /// </summary>
        /// <param name="position"></param>
        /// <param name="fundOfmandates"></param>
        /// <returns></returns>
        public PositionVM GetCalculatedMandates(PositionVM position, FundOfMandates fundOfmandates)
        {
            try
            {
                if (position.Code == fundOfmandates.InstrumentCode && fundOfmandates.Mandates != null && fundOfmandates.Mandates.Length > 0)
                {
                    position.Mandates = new List <MandateVM>();
                    position.Mandates.AddRange
                    (
                        fundOfmandates.Mandates.ToList().Select(x => new MandateVM
                    {
                        Allocation = x.Allocation / 100,
                        Name       = x.MandateName,
                        Value      = Math.Round((position.Value * x.Allocation) / 100)
                    })
                    );

                    if (fundOfmandates.LiquidityAllocation > 0)
                    {
                        var newMandate = new MandateVM
                        {
                            Allocation = fundOfmandates.LiquidityAllocation / 100,
                            Name       = "Liquidity",
                            Value      = Math.Round((position.Value * fundOfmandates.LiquidityAllocation) / 100),
                        };

                        position.Mandates.Add(newMandate);
                    }
                }
                return(position);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }