示例#1
0
        public Profile BuildProfileForProjections(Profile profile, Data.PIMS3Context ctx)
        {
            profileToBeInitialized = profile;
            ProfileDataProcessing profileDataAccessComponent = new ProfileDataProcessing(ctx);

            // try-catch here, or done in data access component?
            profileToBeInitialized = profileDataAccessComponent.BuildProfile(profile.TickerSymbol.Trim());

            // Fetched dividend rate via 3rd party service is unreliable. Reinitializing frequency; needed.
            profileToBeInitialized.DividendFreq = profile.DividendFreq;
            CalculateDividendYield();

            return(profileToBeInitialized);
        }
示例#2
0
        public Dictionary <string, string> CalculateDivFreqAndDivMonths(string tickerSymbol, Data.PIMS3Context ctx)
        {
            StringBuilder oneYearDivPayMonths_1 = new StringBuilder();
            string        oneYearDivPayMonths_2 = string.Empty;
            int           divFreqCounter        = 0;
            string        tempDate = "";

            var    profileDataAccessComponent = new ProfileDataProcessing(ctx);
            JArray orderedJsonTickerPriceData = profileDataAccessComponent.FetchDividendSpecsForTicker(tickerSymbol);

            if (orderedJsonTickerPriceData == null)
            {
                Log.Warning("ProfileProcessing.CalculateDivFreqAndDivMonths() - found unresolved ticker in Tiingo service, unable to update Profile price data for {0}: ", tickerSymbol);
                return(null);
            }

            List <int> divPayoutDays = new List <int>();

            foreach (JObject objChild in orderedJsonTickerPriceData.Children <JObject>())
            {
                // Loop will key in on "divCash" for gathering needed freq & month specs.
                foreach (var property in objChild.Properties())
                {
                    if (property.Name == "date")
                    {
                        tempDate = property.Value.ToString();
                    }

                    if (property.Name == "divCash")
                    {
                        if (decimal.Parse(property.Value.ToString()) > 0)
                        {
                            divFreqCounter += 1;
                            oneYearDivPayMonths_1.Append(ExtractMonthFromDivPayDate(tempDate));
                            divPayoutDays.Add(ExtractDivPayDay(tempDate));
                            oneYearDivPayMonths_1.Append(",");
                        }
                    }
                }
            }

            int medianDivPayoutDay = CommonSvc.CalculateMedianValue(divPayoutDays);

            if (oneYearDivPayMonths_1.Length == 0)
            {
                return(null);
            }

            // Strip trailing comma.
            oneYearDivPayMonths_2 = oneYearDivPayMonths_1.ToString().Substring(0, oneYearDivPayMonths_1.Length - 1);
            string[] oneYearDivPayMonths_3 = oneYearDivPayMonths_2.Split(',');

            Dictionary <string, string> finalProfileSpecs = new Dictionary <string, string>();
            int monthsCount = oneYearDivPayMonths_3.Length;

            /* == finalProfileSpecs Keys legend: ==
             *       "DF"(dividend frequency)
             *       "DM"(dividend months)
             *       "DPD"(dividend payout day)
             */

            if (monthsCount >= 3 && monthsCount <= 5)
            {
                // Due to possible inconsistent number of income receipts made within the last 12 month price history obtained
                // from our 3rd party service (Tiingo), we'll account for this by designating as (Q)uarterly dividend frequency.
                finalProfileSpecs.Add("DF", "Q");
                finalProfileSpecs.Add("DM", oneYearDivPayMonths_2);
            }
            else if (monthsCount >= 5)
            {
                finalProfileSpecs.Add("DF", "M");
                finalProfileSpecs.Add("DM", "-");
            }
            else if (monthsCount == 2)
            {
                finalProfileSpecs.Add("DF", "S");
                finalProfileSpecs.Add("DM", oneYearDivPayMonths_2);
            }
            else
            {
                finalProfileSpecs.Add("DF", "A");
                finalProfileSpecs.Add("DM", oneYearDivPayMonths_2);
            }

            if (medianDivPayoutDay > 0)
            {
                finalProfileSpecs.Add("DPD", medianDivPayoutDay.ToString());
            }

            return(finalProfileSpecs);
        }
示例#3
0
 public PositionProcessing(Data.PIMS3Context ctx)
 {
     _ctx = ctx;
 }
示例#4
0
 public IncomeDataProcessing(Data.PIMS3Context ctx)
 {
     _ctx = ctx;
 }