示例#1
0
        /// <summary>
        /// Phase 1 Implementation
        /// Save the month's full portfolio mix for a customer.
        /// For phase I you can only select 1 portfolio in 100%
        /// V2 will accept a collection of portfolios for example, 30% for Low, 50% Medium, 20% High
        /// </summary>
        /// <param name="customerId"></param>
        /// <param name="riskType"></param>
        /// <param name="portfYear">i.e. 2015 the year this portfolio weight applies</param>
        /// <param name="portfMonth">1..12 the month this portfolio weTight applies</param>
        /// <param name="UpdatedOnUTC"></param>
        /// <returns></returns>
        public void SetDbUserMonthsPortfolioMix(int customerId, RiskToleranceEnum riskType, int portfYear, int portfMonth, DateTime UpdatedOnUTC)
        {
            if (customerId <= 0)
            {
                _logger.Error("SaveDbCustMonthsPortfolioMix(): Invalid Customer Id: {0}", customerId);
            }

            this.SetDbUserMonthsPortfolioMix(customerId, riskType, 100, portfYear, portfMonth, UpdatedOnUTC);
        }
示例#2
0
        /// <summary>
        /// Phase 2 Implementation allowing multiple portfolios linked to a *single* customer with a weight mix.
        /// Note Does not impose present month restriciton. Can set a portfolio mix for the past.
        /// Used internally by Phase 1 method for 100% single customer portfolio selection and for Seeding outside of the current month.
        /// Use overloaded SetCustMonthsPortfolioMix instead for phase I
        /// Though it's use is internal it's declared Public to unit test it.
        /// Save the month's portfolio mix for a customer.
        /// For example, 30% for Low, 50% Medium, 20% High
        /// </summary>
        /// <param name="customerId"></param>
        /// <param name="riskType"></param>
        /// <param name="weight">Percentage weight for example 33.3 for 1/3 of the balance</param>
        /// <param name="portfYear">i.e. 2015 the year this portfolio weight applies</param>
        /// <param name="portfMonth">1..12 the month this portfolio weight applies</param>
        /// <param name="UpdatedOnUTC"></param>
        /// <returns></returns>
        private void SetDbUserMonthsPortfolioMix(int customerId, RiskToleranceEnum riskType, float weight, int portfYear, int portfMonth, DateTime UpdatedOnUTC)
        {
            if (weight < 0 || weight > 100)
            {
                throw new Exception("Invalid percentage not within range 0..100: " + weight);
            }

            SetDbUserMonthsPortfolioMixAddOrUpdateInternalUse(customerId, riskType, weight, portfYear, portfMonth, UpdatedOnUTC);
            db.SaveChanges();
        }
示例#3
0
 /// <summary>
 ///
 /// ** Support Seed() only **
 ///
 /// Upsert an investment balance monthly row
 /// </summary>
 /// <param name="customerId"></param>
 /// <param name="userPortfolioRiskSelection"></param>
 /// <param name="yearCurrent"></param>
 /// <param name="monthCurrent"></param>
 /// <param name="cashToInvest"></param>
 /// <param name="monthlyBalance"></param>
 /// <param name="invGainLoss"></param>
 /// <param name="lowRiskShares"></param>
 /// <param name="mediumRiskShares"></param>
 /// <param name="highRiskShares"></param>
 /// <param name="begGmBalance"></param>
 /// <param name="deposits"></param>
 /// <param name="withdrawals"></param>
 /// <param name="gamingGainLoss"></param>
 /// <param name="endGmBalance"></param>
 /// <param name="totalCashInvInHold"></param>
 /// <param name="totalCashInvestments"></param>
 /// <param name="totalSoldVintagesValue"></param>
 /// <param name="updatedOnUtc"></param>
 public void UpsInvBalance(
     int customerId,
     RiskToleranceEnum userPortfolioRiskSelection,
     int yearCurrent,
     int monthCurrent,
     decimal cashToInvest,
     decimal monthlyBalance,
     decimal invGainLoss,
     decimal lowRiskShares,
     decimal mediumRiskShares,
     decimal highRiskShares,
     decimal begGmBalance,
     decimal deposits,
     decimal withdrawals,
     decimal gamingGainLoss,
     decimal endGmBalance,
     decimal totalCashInvInHold,
     decimal totalCashInvestments,
     decimal totalSoldVintagesValue,
     DateTime updatedOnUtc)
 {
     db.InvBalances.AddOrUpdate(i => new { i.CustomerId, i.YearMonth },
                                new InvBalance
     {
         YearMonth              = DbExpressions.GetStrYearMonth(yearCurrent, monthCurrent),
         CustomerId             = customerId,
         PortfolioId            = (int)userPortfolioRiskSelection,
         Balance                = monthlyBalance,
         InvGainLoss            = invGainLoss,
         CashInvestment         = cashToInvest,
         LowRiskShares          = lowRiskShares,
         MediumRiskShares       = mediumRiskShares,
         HighRiskShares         = highRiskShares,
         BegGmBalance           = begGmBalance,
         Deposits               = deposits,
         Withdrawals            = withdrawals,
         GmGainLoss             = gamingGainLoss,
         EndGmBalance           = endGmBalance,
         TotalCashInvInHold     = totalCashInvInHold,
         TotalCashInvestments   = totalCashInvestments,
         TotalSoldVintagesValue = totalSoldVintagesValue,
         UpdatedOnUtc           = updatedOnUtc
     });
 }
示例#4
0
 private void SetDbUserMonthsPortfolioMixAddOrUpdateInternalUse(int customerId, RiskToleranceEnum riskType, float weight,
                                                                int portfYear, int portfMonth, DateTime updatedOnUtc)
 {
     db.CustPortfolios.AddOrUpdate(
         cp => new { cp.CustomerId, cp.YearMonth },
         new CustPortfolio
     {
         CustomerId = customerId,
         // Get the most recent active portfolio for the risk type
         PortfolioId = db.Portfolios
                       .Where(p => p.RiskTolerance == riskType && p.IsActive)
                       .Select(p => p.Id)
                       .Single(),
         YearMonth    = DbExpressions.GetStrYearMonth(portfYear, portfMonth),
         UpdatedOnUTC = updatedOnUtc,
         Weight       = weight
     }
         );
 }
示例#5
0
        /// <summary>
        ///
        /// UI Simplified Wrapper for setting the portfolio for the present month (UtcNow).
        ///
        /// </summary>
        /// <param name="customerId"></param>
        /// <param name="riskType"></param>
        public void SetDbDefaultPortfolio(int customerId, RiskToleranceEnum riskType)
        {
            var nextMonth = DateTime.UtcNow;

            SetDbUserMonthsPortfolioMix(customerId, riskType, nextMonth.Year, nextMonth.Month, DateTime.UtcNow);
        }