Initial Commit
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using MarketData.Utils;
|
||||
using System.Collections.ObjectModel;
|
||||
using MarketData.Generator.GainLoss;
|
||||
using MarketData.DataAccess;
|
||||
|
||||
namespace MarketData.MarketDataModel.GainLoss
|
||||
{
|
||||
// The GainLossCompoundModelCollection contains both the active gain loss and the total gain loss time series data
|
||||
public class GainLossCompoundModelCollection : List<GainLossCompoundModel>
|
||||
{
|
||||
public GainLossCompoundModelCollection()
|
||||
{
|
||||
}
|
||||
public GainLossCompoundModelCollection(List<GainLossCompoundModel> items)
|
||||
{
|
||||
foreach(GainLossCompoundModel item in items)Add(item);
|
||||
}
|
||||
public GainLossCompoundModelCollection(GainLossCollection activeGainLossCollection,TotalGainLossCollection totalGainLossCollection)
|
||||
{
|
||||
if(null==activeGainLossCollection||null==totalGainLossCollection)return;
|
||||
Dictionary<DateTime,GainLossItem> activeGainLossCollectionByDate=new Dictionary<DateTime,GainLossItem>();
|
||||
Dictionary<DateTime,TotalGainLossItem> totalGainLossCollectionByDate=new Dictionary<DateTime,TotalGainLossItem>();
|
||||
foreach(GainLossItem gainLossItem in activeGainLossCollection)if(!activeGainLossCollectionByDate.ContainsKey(gainLossItem.Date))activeGainLossCollectionByDate.Add(gainLossItem.Date,gainLossItem);
|
||||
foreach(TotalGainLossItem gainLossItem in totalGainLossCollection)if(!totalGainLossCollectionByDate.ContainsKey(gainLossItem.Date))totalGainLossCollectionByDate.Add(gainLossItem.Date,gainLossItem);
|
||||
List<DateTime> dates=new List<DateTime>(activeGainLossCollectionByDate.Keys);
|
||||
dates.Sort();
|
||||
foreach(DateTime date in dates)
|
||||
{
|
||||
GainLossItem activeGainLossItem=activeGainLossCollectionByDate[date];
|
||||
if(!totalGainLossCollectionByDate.ContainsKey(date))continue;
|
||||
TotalGainLossItem totalGainLossItem=totalGainLossCollectionByDate[date];
|
||||
GainLossCompoundModel gainLossModel=new GainLossCompoundModel();
|
||||
gainLossModel.Date=activeGainLossItem.Date;
|
||||
gainLossModel.ActiveExposure=activeGainLossItem.Exposure;
|
||||
gainLossModel.ActiveGainLoss=activeGainLossItem.GainLoss;
|
||||
gainLossModel.ActiveGainLossPercent=activeGainLossItem.GainLossPercent;
|
||||
gainLossModel.TotalGainLoss=totalGainLossItem.TotalGainLoss;
|
||||
gainLossModel.TotalGainLossPercent=totalGainLossItem.TotalGainLossPercent;
|
||||
gainLossModel.TotalDividendsPaid=totalGainLossItem.TotalDividendsPaid;
|
||||
Add(gainLossModel);
|
||||
}
|
||||
}
|
||||
public DMAValues DMAValuesActiveGainLoss
|
||||
{
|
||||
get
|
||||
{
|
||||
DMAValues dmaValues = new DMAValues();
|
||||
foreach (GainLossCompoundModel gainLoss in this)
|
||||
{
|
||||
dmaValues.Add(new DMAValue(gainLoss.Date,gainLoss.ActiveGainLoss));
|
||||
}
|
||||
return dmaValues;
|
||||
}
|
||||
}
|
||||
public DMAValues DMAValuesTotalGainLoss
|
||||
{
|
||||
get
|
||||
{
|
||||
DMAValues dmaValues = new DMAValues();
|
||||
foreach (GainLossCompoundModel gainLoss in this)
|
||||
{
|
||||
dmaValues.Add(new DMAValue(gainLoss.Date,gainLoss.TotalGainLoss));
|
||||
}
|
||||
return dmaValues;
|
||||
}
|
||||
}
|
||||
public DMAValues DMAValuesActiveGainLossPercent
|
||||
{
|
||||
get
|
||||
{
|
||||
DMAValues dmaValues = new DMAValues();
|
||||
foreach (GainLossCompoundModel gainLoss in this)
|
||||
{
|
||||
dmaValues.Add(new DMAValue(gainLoss.Date,gainLoss.ActiveGainLossPercent));
|
||||
}
|
||||
return dmaValues;
|
||||
}
|
||||
}
|
||||
public DMAValues DMAValuesTotalGainLossPercent
|
||||
{
|
||||
get
|
||||
{
|
||||
DMAValues dmaValues = new DMAValues();
|
||||
foreach (GainLossCompoundModel gainLoss in this)
|
||||
{
|
||||
dmaValues.Add(new DMAValue(gainLoss.Date,gainLoss.TotalGainLossPercent));
|
||||
}
|
||||
return dmaValues;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user