Example #1
0
        public bool FillModelMonthlyReturns(List<AtModelMonthlyReturns> lst)
        {
            foreach (var entry in lst)
            {
                var iModelId = entry.ModelTknId;
                ModelReturns pModelReturns;
                if (m_pCalc.m_perf_data.m_model_data.ContainsKey(iModelId))
                {
                    pModelReturns = m_pCalc.m_perf_data.m_model_data[iModelId];
                }
                else
                {
                    pModelReturns = new ModelReturns();
                    m_pCalc.m_perf_data.m_model_data.Add(iModelId, pModelReturns);
                }

                var iYearMonth = entry.Yearmonth;
                var pModelMonthlyReturns = new ModelMonthlyReturns();

                if (entry.Turnover.HasValue)
                    pModelMonthlyReturns.m_turnover = Convert.ToDouble(entry.Turnover.Value);
                if (entry.Totalreturn.HasValue)
                    pModelMonthlyReturns.m_total_return = Convert.ToDouble(entry.Totalreturn.Value);
                if (entry.Dividendreturn.HasValue)
                    pModelMonthlyReturns.m_dividend_return = Convert.ToDouble(entry.Dividendreturn.Value);
                if (entry.Pricereturn.HasValue)
                    pModelMonthlyReturns.m_price_return = Convert.ToDouble(entry.Pricereturn.Value);

                pModelMonthlyReturns.m_dividend_yield = entry.Dividendyield.HasValue ? Convert.ToDouble(entry.Dividendyield.Value) : 0.0;

                if (!pModelReturns.m_model_monthly_returns.ContainsKey(iYearMonth))
                {
                    pModelReturns.m_model_monthly_returns.Add(iYearMonth, pModelMonthlyReturns);
                }
            }
            return true;
        }
Example #2
0
        public bool FillModelDailyReturns(List<AtModelDailyReturns> lst)
        {
            foreach (var entry in lst)
            {
                var iModelId = entry.ModelTknId;
                ModelReturns pModelReturns;
                if (m_pCalc.m_perf_data.m_model_data.ContainsKey(iModelId))
                {
                    pModelReturns = m_pCalc.m_perf_data.m_model_data[iModelId];
                }
                else
                {
                    pModelReturns = new ModelReturns();
                    m_pCalc.m_perf_data.m_model_data.Add(iModelId, pModelReturns);
                }

                var iDailyDate = Utility.getIntFromDate(entry.DailyDate);
                var pModelDayReturns = new ModelDayReturns();

                if (entry.PriceReturn.HasValue)
                    pModelDayReturns.m_price_return = Convert.ToDouble(entry.PriceReturn.Value);
                if (entry.TotalReturn.HasValue)
                    pModelDayReturns.m_total_return = Convert.ToDouble(entry.TotalReturn.Value);

                if (entry.DaysToMthEnd.HasValue)
                    pModelDayReturns.m_days_to_month_end = entry.DaysToMthEnd.Value;
                if (entry.CmpTotalRetToMthEnd.HasValue)
                    pModelDayReturns.m_total_return_to_month_end = Convert.ToDouble(entry.CmpTotalRetToMthEnd.Value);
                if (entry.CmpPriceRetToMthEnd.HasValue)
                    pModelDayReturns.m_price_return_to_month_end = Convert.ToDouble(entry.CmpPriceRetToMthEnd.Value);

                if (!pModelReturns.m_model_daily_returns.ContainsKey(iDailyDate))
                {
                    pModelReturns.m_model_daily_returns.Add(iDailyDate, pModelDayReturns);
                }
            }
            return true;
        }