Exemple #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());
     }
 }
Exemple #2
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;
            }
        }