示例#1
0
        private PortfolioTypes.PortfoliosPrices createMonthlyPortfolioPrices(string currentYearMonthStr, double stockPrice)
        {
            var lowPortfolioPrice = new PortfolioTypes.PortfolioSharePrice((int)RiskToleranceEnum.Low, stockPrice,
                                                                           DbExpressions.GetDtYearMonthStrToEndOfMonth(currentYearMonthStr));
            var mediumPortfolioPrice = new PortfolioTypes.PortfolioSharePrice((int)RiskToleranceEnum.Medium, stockPrice,
                                                                              DbExpressions.GetDtYearMonthStrToEndOfMonth(currentYearMonthStr));
            var highPortfolioPrice = new PortfolioTypes.PortfolioSharePrice((int)RiskToleranceEnum.High, stockPrice,
                                                                            DbExpressions.GetDtYearMonthStrToEndOfMonth(currentYearMonthStr));
            var portfolioPricesEoM = new PortfolioTypes.PortfoliosPrices(lowPortfolioPrice, mediumPortfolioPrice,
                                                                         highPortfolioPrice);

            return(portfolioPricesEoM);
        }
示例#2
0
        private PortfolioTypes.PortfoliosPrices GetPortfoliosPrices(string startYearMonthStr, int monthCnt)
        {
            var stockPrice = 1 + (monthCnt / 10.0);

            var lowPortfolioPrice = new PortfolioTypes.PortfolioSharePrice((int)RiskToleranceEnum.Low, stockPrice,
                                                                           DbExpressions.GetDtYearMonthStrToEndOfMonth(startYearMonthStr));
            var mediumPortfolioPrice = new PortfolioTypes.PortfolioSharePrice((int)RiskToleranceEnum.Medium, stockPrice,
                                                                              DbExpressions.GetDtYearMonthStrToEndOfMonth(startYearMonthStr));
            var highPortfolioPrice = new PortfolioTypes.PortfolioSharePrice((int)RiskToleranceEnum.High, stockPrice,
                                                                            DbExpressions.GetDtYearMonthStrToEndOfMonth(startYearMonthStr));
            var portfolioPricesEoM = new PortfolioTypes.PortfoliosPrices(lowPortfolioPrice, mediumPortfolioPrice,
                                                                         highPortfolioPrice);

            return(portfolioPricesEoM);
        }
示例#3
0
        private FSharpMap <string, PortfolioTypes.PortfoliosPrices> GetPortfoliosPrices(string currentYearMonthStr)
        {
            double stockPrice = -1;

            PortfolioTypes.PortfoliosPrices monthlyPortfolioPrices = null;
            switch (currentYearMonthStr)
            {
            case "201611":
            case "201703":
                stockPrice = 1;
                break;

            case "201612":
                stockPrice = 2;
                break;

            case "201701":
                stockPrice = 3;
                break;

            case "201702":
                stockPrice = 5;
                break;

            default:
                Assert.Fail("Not Agreed Month: " + currentYearMonthStr);
                break;
            }
            monthlyPortfolioPrices = createMonthlyPortfolioPrices(currentYearMonthStr, stockPrice);

            var portfoliosPriceDict = new Dictionary <string, PortfolioTypes.PortfoliosPrices>()
            {
                {
                    DbExpressions.GetDtYearMonthStrToEndOfMonth(currentYearMonthStr).ToStringYearMonthDay(),
                    monthlyPortfolioPrices
                }
            };
            // Convert .net dictinary to F# map
            var portfoliosPriceMap = PortfolioTypes.toMap(portfoliosPriceDict);

            return(portfoliosPriceMap);
        }
示例#4
0
        private void ProcessInvBalances_1_through_4(int caseNo, List <int> usersFound, int monthsCnt, string currentYearMonthStr)
        {
            PortfolioTypes.PortfoliosPrices monthPortfoliosPrices = null;

            DbUtil.DbSchema.GzRunTimeDb sqlProviderCtx;
            using (sqlProviderCtx = DbUtil.getOpenDb(devDbConnString))
            {
                foreach (var email in userEmails)
                {
                    int userId = db.Users
                                 .Where(u => u.Email == email)
                                 .Select(u => u.Id)
                                 .SingleOrDefault();

                    if (userId != 0)
                    {
                        usersFound.Add(userId);

                        SetDbMonthlyPortfolioSelection(monthsCnt, userId, currentYearMonthStr);

                        SetDbMonthlyPlayerLossTrx_3_4(currentYearMonthStr, userId);

                        var userVintages = AssertUserVintagesCount(userId, monthsCnt);

                        monthPortfoliosPrices = GetPortfoliosPrices(currentYearMonthStr, monthsCnt);

                        SellVintages(caseNo, currentYearMonthStr, userVintages, userId);
                    }
                }

                // Process losses -> invbalance
                UserTrx.processGzTrx(sqlProviderCtx, currentYearMonthStr, monthPortfoliosPrices, FSharpOption <string> .None);
            }

            AssertAllUsersVintagesCountAfterMonthClearance(usersFound, monthsCnt + 1);
        }