Пример #1
0
        public bool FillBenchDailyReturns(List<AtBenchDailyReturns> lstBDR)
        {
            if (lstBDR.Count == 0)
            {
                m_gcFeedback.LogProgress(
                    m_idSession,
                    LogType.LOG_TYPE_INPUT_DATA_VALIDATION,
                    LogSeverity.LOG_SEVERITY_WARNING,
                    "Warning: No BenchDailyReturns were found", string.Empty, string.Empty, true);
                return false;
            }

            foreach (var entry in lstBDR)
            {
                var iBenchID = entry.Benchmarkid;

                BenchReturns pBenchReturns;
                if (m_pCalc.m_perf_data.m_bench_data.ContainsKey(iBenchID))
                {
                    var pNewBenchReturns = new BenchReturns();
                    m_pCalc.m_perf_data.m_bench_data.Add(iBenchID, pNewBenchReturns);
                    pBenchReturns = pNewBenchReturns;
                }
                else
                {
                    pBenchReturns =  m_pCalc.m_perf_data.m_bench_data[iBenchID];
                }

                var iDailyDate = Utility.getIntFromDate(entry.DailyDate);

                if (!pBenchReturns.m_bench_daily_returns.ContainsKey(iDailyDate))
                {
                    var pNewBenchDayReturns = new BenchDayReturns();

                    if (entry.PriceReturn.HasValue)
                        pNewBenchDayReturns.m_price_return = Convert.ToDouble(entry.PriceReturn.Value);
                    if (entry.TotalReturn.HasValue)
                        pNewBenchDayReturns.m_total_return = Convert.ToDouble(entry.TotalReturn.Value);
                    if (entry.DaysToMthEnd.HasValue)
                        pNewBenchDayReturns.m_days_to_month_end = entry.DaysToMthEnd.Value;
                    if (entry.CmpTotalRetToMthEnd.HasValue)
                        pNewBenchDayReturns.m_total_return_to_month_end = Convert.ToDouble(entry.CmpTotalRetToMthEnd.Value);
                    if (entry.CmpPriceRetToMthEnd.HasValue)
                        pNewBenchDayReturns.m_price_return_to_month_end = Convert.ToDouble(entry.CmpPriceRetToMthEnd.Value);

                    pBenchReturns.m_bench_daily_returns.Add(iDailyDate, pNewBenchDayReturns);
                }
                else
                {
                    Debug.Assert(false, "Expected daily bench data to be unique");
                }
            }
            return true;
        }
Пример #2
0
        private bool calculatePerformanceFromBeginning(
            BenchAllocation benchAllocation,
            BenchReturns benchmarkReturns,
            int yearMonth, ClientModelBench clientModelBench,
            int accountId, Client clientData)
        {
            var benchMonthReturns = benchmarkReturns.m_bench_monthly_returns[yearMonth];
            var benchDayReturns = benchmarkReturns.m_bench_daily_returns[benchAllocation.m_date_to];

            var iLoop = 1;

            clientModelBench.m_totReturn = ((1 + clientModelBench.m_totReturn)*(1 + benchMonthReturns.m_total_return)/
                                            (benchDayReturns.m_price_return_to_month_end)) - 1;

            clientModelBench.m_totPriceReturn = ((1 + clientModelBench.m_totPriceReturn) * (1 + benchMonthReturns.m_price_return) /
                                                (benchDayReturns.m_price_return_to_month_end)) - 1;

            clientModelBench.m_totDivReturn += (benchMonthReturns.m_dividend_return);
        }
Пример #3
0
        public bool FillBenchMonthlyReturns(List<AtBenchMonthlyReturns> lstBMR)
        {
            foreach(var entry in lstBMR)
            {
                var iBenchID = entry.BenchmarkID;
                BenchReturns pBenchReturns;

                if (m_pCalc.m_perf_data.m_bench_data.ContainsKey(iBenchID))
                {
                    pBenchReturns = m_pCalc.m_perf_data.m_bench_data[iBenchID];
                }
                else
                {
                    var pNewBenchReturns = new BenchReturns();
                    m_pCalc.m_perf_data.m_bench_data.Add(iBenchID, pNewBenchReturns);
                    pBenchReturns = pNewBenchReturns;
                }
                var pBenchMonthlyReturns = new BenchMonthlyReturns();

                if (entry.Turnover.HasValue)
                    pBenchMonthlyReturns.m_turnover = Convert.ToDouble(entry.Turnover.Value);

                if (entry.TotalReturn.HasValue)
                    pBenchMonthlyReturns.m_total_return = Convert.ToDouble(entry.TotalReturn.Value);

                if (entry.DividendReturn.HasValue)
                    pBenchMonthlyReturns.m_dividend_return = Convert.ToDouble(entry.DividendReturn.Value);

                if (entry.DividendYield.HasValue)
                    pBenchMonthlyReturns.m_dividend_yield = Convert.ToDouble(entry.DividendYield.Value);

                if (entry.PriceReturn.HasValue)
                    pBenchMonthlyReturns.m_price_return = Convert.ToDouble(entry.PriceReturn.Value);

                var iYearMonth = entry.YearMonth;

                if (!pBenchReturns.m_bench_monthly_returns.ContainsKey(iYearMonth))
                {
                    pBenchReturns.m_bench_monthly_returns.Add(iYearMonth, pBenchMonthlyReturns);
                }
            }
            return true;
        }