Initial Commit
This commit is contained in:
45
MarketData/MarketDataLib/MarketDataModel/DividendPayment.cs
Executable file
45
MarketData/MarketDataLib/MarketDataModel/DividendPayment.cs
Executable file
@@ -0,0 +1,45 @@
|
||||
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<DividendPayment>
|
||||
{
|
||||
public DividendPayments()
|
||||
{
|
||||
}
|
||||
public DividendPayments(List<DividendPayment> 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<String> 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<String> 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;}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user