using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using MarketData.Utils; namespace MarketData.MarketDataModel { public class DividendPayments : List { public DividendPayments() { } public DividendPayments(List dividendPayments) { foreach(DividendPayment dividendPayment in dividendPayments)Add(dividendPayment); } public double GetDividendPaymentsToDate(DateTime date) { return (from DividendPayment dividendPayment in this where dividendPayment.PaymentDate<=date select dividendPayment.Amount).Sum(); } public DividendPayments FilterAccounts(String filterAccounts) { if(null==filterAccounts)return this; List accountsToInclude=Utility.ToList(filterAccounts); DividendPayments dividendPayments=new DividendPayments((from DividendPayment dividendPayment in this where accountsToInclude.Any(x=>x.Equals(dividendPayment.Account)) select dividendPayment).ToList()); return dividendPayments; } public DividendPayments FilterSymbols(String filterSymbols) { if(null==filterSymbols) return this; List symbolsToInclude=Utility.ToList(filterSymbols); DividendPayments dividendPayments=new DividendPayments((from DividendPayment dividendPayment in this where symbolsToInclude.Any(x => x.Equals(dividendPayment.Symbol)) select dividendPayment).ToList()); return dividendPayments; } } public class DividendPayment { public String Account{get;set;} public String Symbol{get;set;} public DateTime PaymentDate{get;set;} public double Amount{get;set;} } }