Exemplo n.º 1
0
        private void RemoveDividend(Dividend dividend)
        {
            Dividend match = DividendHelper.FindDividend(dividend, this);

            if (match != null)
            {
                base.Remove(match);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Pres the process divs.
        /// </summary>
        /// <param name="today"></param>
        /// <param name="rawDivList">The raw div list.</param>
        /// <returns></returns>
        private List <Dividend> PreProcessDivs(DateTime today, IEnumerable <Dividend> rawDivList)
        {
            // Preprocess divs
            DateTime        expiry = today.AddDays(365.0 * Tau);
            List <Dividend> divs   = rawDivList.Where(div => div.ExDate > today && div.ExDate <= expiry).ToList();

            DividendHelper.Sort(divs);
            return(divs);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds the dividend.
        /// </summary>
        /// <param name="dividend">The dividend.</param>
        private void AddDividend(Dividend dividend)
        {
            Dividend match = DividendHelper.FindDividend(dividend, this);

            if (match == null)
            {
                if (Count == 0)
                {
                    base.Add(dividend);
                }
                else
                {
                    List <Dividend> divsFound = FindAll(
                        dividendItem => (dividendItem.ExDivDate < dividend.ExDivDate)
                        );
                    Insert(divsFound.Count != 0 ? divsFound.Count : 0, dividend);
                }
            }
            else
            {
                throw new DuplicateNotAllowedException(
                          $"A dividend with ExDiv date {dividend.ExDivDate},  already exists in this list");
            }
        }