Remove Fix purchase date/sell date fall on weekend from the aggregators
This commit is contained in:
@@ -50,6 +50,7 @@ namespace TradeBlotter.Model
|
||||
public CMPositionModel()
|
||||
{
|
||||
}
|
||||
|
||||
public CMPositionModel(Position position, int slot)
|
||||
{
|
||||
Slot = slot;
|
||||
@@ -64,6 +65,7 @@ namespace TradeBlotter.Model
|
||||
SharpeRatio = position.SharpeRatio;
|
||||
CNNPrediction = position.CNNPrediction;
|
||||
}
|
||||
|
||||
public CMPositionModel(Position position)
|
||||
{
|
||||
slot = -1;
|
||||
@@ -78,15 +80,32 @@ namespace TradeBlotter.Model
|
||||
SharpeRatio = position.SharpeRatio;
|
||||
CNNPrediction = position.CNNPrediction;
|
||||
}
|
||||
|
||||
public Position Position
|
||||
{
|
||||
get
|
||||
{
|
||||
return position;
|
||||
}
|
||||
}
|
||||
|
||||
public String Symbol
|
||||
{
|
||||
get { return position.Symbol; }
|
||||
set { position.Symbol = value; base.OnPropertyChanged("Symbol"); }
|
||||
}
|
||||
|
||||
public DateTime PurchaseDate
|
||||
{
|
||||
get { return position.PurchaseDate; }
|
||||
set { position.PurchaseDate = value; base.OnPropertyChanged("PurchaseDate"); }
|
||||
get
|
||||
{
|
||||
return position.PurchaseDate;
|
||||
}
|
||||
set
|
||||
{
|
||||
position.PurchaseDate = value;
|
||||
base.OnPropertyChanged("PurchaseDate");
|
||||
}
|
||||
}
|
||||
|
||||
public Brush PurchaseDateColor
|
||||
@@ -127,11 +146,13 @@ namespace TradeBlotter.Model
|
||||
return dateGenerator.DaysBetween(PurchaseDate, SellDate);
|
||||
}
|
||||
}
|
||||
|
||||
public int Slot
|
||||
{
|
||||
get { return slot; }
|
||||
set { slot = value; base.OnPropertyChanged("Slot"); }
|
||||
}
|
||||
|
||||
public String SlotAsString
|
||||
{
|
||||
get
|
||||
@@ -140,16 +161,19 @@ namespace TradeBlotter.Model
|
||||
return Slot.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public double Shares
|
||||
{
|
||||
get { return position.Shares; }
|
||||
set { position.Shares = value; base.OnPropertyChanged("Shares"); base.OnPropertyChanged("Exposure"); base.OnPropertyChanged("ActiveExposure"); base.OnPropertyChanged("MarketValue"); base.OnPropertyChanged("ActiveMarketValue"); base.OnPropertyChanged("GainLoss"); base.OnPropertyChanged("GainLossPcnt"); }
|
||||
}
|
||||
|
||||
public double PurchasePrice
|
||||
{
|
||||
get { return position.PurchasePrice; }
|
||||
set { position.PurchasePrice = value; base.OnPropertyChanged("PurchasePrice"); base.OnPropertyChanged("Exposure"); base.OnPropertyChanged("ActiveExposure"); base.OnPropertyChanged("GainLoss"); base.OnPropertyChanged("GainLossPcnt"); }
|
||||
}
|
||||
|
||||
public double CurrentPrice
|
||||
{
|
||||
get { return position.CurrentPrice; }
|
||||
@@ -170,6 +194,7 @@ namespace TradeBlotter.Model
|
||||
base.OnPropertyChanged("CurrentPriceColor");
|
||||
}
|
||||
}
|
||||
|
||||
public double RSI3
|
||||
{
|
||||
get { return rsi3; }
|
||||
@@ -181,11 +206,13 @@ namespace TradeBlotter.Model
|
||||
base.OnPropertyChanged("RSI3Color");
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime LastUpdated
|
||||
{
|
||||
get { return lastUpdated; }
|
||||
set { lastUpdated = value; base.OnPropertyChanged("LastUpdated"); }
|
||||
}
|
||||
|
||||
public Brush CurrentPriceColor
|
||||
{
|
||||
get
|
||||
@@ -196,6 +223,7 @@ namespace TradeBlotter.Model
|
||||
else return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black);
|
||||
}
|
||||
}
|
||||
|
||||
public Brush RSI3Color
|
||||
{
|
||||
get
|
||||
@@ -205,14 +233,17 @@ namespace TradeBlotter.Model
|
||||
return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black);
|
||||
}
|
||||
}
|
||||
|
||||
public double Exposure
|
||||
{
|
||||
get { return Shares * PurchasePrice; }
|
||||
}
|
||||
|
||||
public double ActiveExposure
|
||||
{
|
||||
get { return IsActivePosition ? Exposure : 0.00; }
|
||||
}
|
||||
|
||||
public Brush ActiveExposureColor
|
||||
{
|
||||
get
|
||||
@@ -221,19 +252,23 @@ namespace TradeBlotter.Model
|
||||
else return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black);
|
||||
}
|
||||
}
|
||||
|
||||
public bool CNNPrediction
|
||||
{
|
||||
get { return position.CNNPrediction; }
|
||||
set { position.CNNPrediction = value; base.OnPropertyChanged("CNNPrediction"); }
|
||||
}
|
||||
|
||||
public double MarketValue
|
||||
{
|
||||
get { return Shares * CurrentPrice; }
|
||||
}
|
||||
|
||||
public double ActiveMarketValue
|
||||
{
|
||||
get { return IsActivePosition ? MarketValue : 0.00; }
|
||||
}
|
||||
|
||||
public Brush ActiveMarketValueColor
|
||||
{
|
||||
get
|
||||
@@ -244,10 +279,12 @@ namespace TradeBlotter.Model
|
||||
else return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black);
|
||||
}
|
||||
}
|
||||
|
||||
public double GainLoss
|
||||
{
|
||||
get { return MarketValue - Exposure; }
|
||||
}
|
||||
|
||||
public Brush GainLossColor
|
||||
{
|
||||
get
|
||||
@@ -258,10 +295,12 @@ namespace TradeBlotter.Model
|
||||
else return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black);
|
||||
}
|
||||
}
|
||||
|
||||
public double GainLossPcnt
|
||||
{
|
||||
get { return (MarketValue - Exposure) / Exposure; }
|
||||
}
|
||||
|
||||
public Brush GainLossPcntColor
|
||||
{
|
||||
get
|
||||
@@ -272,21 +311,25 @@ namespace TradeBlotter.Model
|
||||
else return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black);
|
||||
}
|
||||
}
|
||||
|
||||
public double Beta
|
||||
{
|
||||
get { return position.Beta; }
|
||||
set { position.Beta = value; base.OnPropertyChanged("Beta"); }
|
||||
}
|
||||
|
||||
public int BetaMonths
|
||||
{
|
||||
get { return position.BetaMonths; }
|
||||
set { position.BetaMonths = value; base.OnPropertyChanged("BetaMonths"); }
|
||||
}
|
||||
|
||||
public double SharpeRatio
|
||||
{
|
||||
get { return position.SharpeRatio; }
|
||||
set { position.SharpeRatio = value; base.OnPropertyChanged("SharpeRatio"); }
|
||||
}
|
||||
|
||||
public bool IsActivePosition
|
||||
{
|
||||
get { return Utility.IsEpoch(SellDate) ? true : false; }
|
||||
|
||||
@@ -40,25 +40,27 @@ namespace TradeBlotter.Model
|
||||
LocalPriceCache.GetInstance().RemoveDate(maxDate);
|
||||
List<DateTime> historicalDates=dateGenerator.GenerateHistoricalDates(minDate,maxDate);
|
||||
|
||||
foreach(CMTPositionModel position in positions)
|
||||
{
|
||||
if(dateGenerator.IsWeekend(position.PurchaseDate))
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
position.PurchaseDate=dateGenerator.GetNextBusinessDay(position.PurchaseDate);
|
||||
if(!HolidayDA.IsMarketHoliday(position.PurchaseDate)) break;
|
||||
}
|
||||
}
|
||||
if(dateGenerator.IsWeekend(position.SellDate))
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
position.SellDate=dateGenerator.GetNextBusinessDay(position.SellDate);
|
||||
if(!HolidayDA.IsMarketHoliday(position.SellDate)) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fix purchase date/sell date fall on weekend
|
||||
//foreach(CMTPositionModel position in positions)
|
||||
//{
|
||||
// if(dateGenerator.IsWeekend(position.PurchaseDate))
|
||||
// {
|
||||
// while(true)
|
||||
// {
|
||||
// position.PurchaseDate=dateGenerator.GetNextBusinessDay(position.PurchaseDate);
|
||||
// if(!HolidayDA.IsMarketHoliday(position.PurchaseDate)) break;
|
||||
// }
|
||||
// }
|
||||
// if(dateGenerator.IsWeekend(position.SellDate))
|
||||
// {
|
||||
// while(true)
|
||||
// {
|
||||
// position.SellDate=dateGenerator.GetNextBusinessDay(position.SellDate);
|
||||
// if(!HolidayDA.IsMarketHoliday(position.SellDate)) break;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
foreach(DateTime currentDate in historicalDates)
|
||||
{
|
||||
IEnumerable<CMTPositionModel> openPositions=positions.Where(x => (x.PurchaseDate<=currentDate&&(!Utility.IsEpoch(x.SellDate)&&x.SellDate>currentDate))||(x.PurchaseDate<=currentDate&&Utility.IsEpoch(x.SellDate))).ToList();
|
||||
@@ -175,25 +177,27 @@ namespace TradeBlotter.Model
|
||||
LocalPriceCache.GetInstance().RemoveDate(maxDate);
|
||||
List<DateTime> historicalDates=dateGenerator.GenerateHistoricalDates(minDate,maxDate);
|
||||
|
||||
foreach(CMPositionModel position in positions)
|
||||
{
|
||||
if(dateGenerator.IsWeekend(position.PurchaseDate))
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
position.PurchaseDate=dateGenerator.GetNextBusinessDay(position.PurchaseDate);
|
||||
if(!HolidayDA.IsMarketHoliday(position.PurchaseDate)) break;
|
||||
}
|
||||
}
|
||||
if(dateGenerator.IsWeekend(position.SellDate))
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
position.SellDate=dateGenerator.GetNextBusinessDay(position.SellDate);
|
||||
if(!HolidayDA.IsMarketHoliday(position.SellDate)) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fix purchase date/sell date fall on weekend
|
||||
//foreach(CMPositionModel position in positions)
|
||||
//{
|
||||
// if(dateGenerator.IsWeekend(position.PurchaseDate))
|
||||
// {
|
||||
// while(true)
|
||||
// {
|
||||
// position.PurchaseDate=dateGenerator.GetNextBusinessDay(position.PurchaseDate);
|
||||
// if(!HolidayDA.IsMarketHoliday(position.PurchaseDate)) break;
|
||||
// }
|
||||
// }
|
||||
// if(dateGenerator.IsWeekend(position.SellDate))
|
||||
// {
|
||||
// while(true)
|
||||
// {
|
||||
// position.SellDate=dateGenerator.GetNextBusinessDay(position.SellDate);
|
||||
// if(!HolidayDA.IsMarketHoliday(position.SellDate)) break;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
foreach(DateTime currentDate in historicalDates)
|
||||
{
|
||||
IEnumerable<CMPositionModel> openPositions=positions.Where(x => (x.PurchaseDate<=currentDate&&(!Utility.IsEpoch(x.SellDate)&&x.SellDate>currentDate))||(x.PurchaseDate<=currentDate&&Utility.IsEpoch(x.SellDate))).ToList();
|
||||
@@ -289,25 +293,27 @@ namespace TradeBlotter.Model
|
||||
LocalPriceCache.GetInstance().RemoveDate(maxDate);
|
||||
List<DateTime> historicalDates=dateGenerator.GenerateHistoricalDates(minDate,maxDate);
|
||||
|
||||
foreach(MGPositionModel position in positions)
|
||||
{
|
||||
if(dateGenerator.IsWeekend(position.PurchaseDate))
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
position.PurchaseDate=dateGenerator.GetNextBusinessDay(position.PurchaseDate);
|
||||
if(!HolidayDA.IsMarketHoliday(position.PurchaseDate)) break;
|
||||
}
|
||||
}
|
||||
if(dateGenerator.IsWeekend(position.SellDate))
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
position.SellDate=dateGenerator.GetNextBusinessDay(position.SellDate);
|
||||
if(!HolidayDA.IsMarketHoliday(position.SellDate)) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fix purchase date/sell date fall on weekend
|
||||
//foreach(MGPositionModel position in positions)
|
||||
//{
|
||||
// if(dateGenerator.IsWeekend(position.PurchaseDate))
|
||||
// {
|
||||
// while(true)
|
||||
// {
|
||||
// position.PurchaseDate=dateGenerator.GetNextBusinessDay(position.PurchaseDate);
|
||||
// if(!HolidayDA.IsMarketHoliday(position.PurchaseDate)) break;
|
||||
// }
|
||||
// }
|
||||
// if(dateGenerator.IsWeekend(position.SellDate))
|
||||
// {
|
||||
// while(true)
|
||||
// {
|
||||
// position.SellDate=dateGenerator.GetNextBusinessDay(position.SellDate);
|
||||
// if(!HolidayDA.IsMarketHoliday(position.SellDate)) break;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
foreach(DateTime currentDate in historicalDates)
|
||||
{
|
||||
IEnumerable<MGPositionModel> openPositions=positions.Where(x => (x.PurchaseDate<=currentDate&&(!Utility.IsEpoch(x.SellDate)&&x.SellDate>currentDate))||(x.PurchaseDate<=currentDate&&Utility.IsEpoch(x.SellDate))).ToList();
|
||||
@@ -401,25 +407,27 @@ namespace TradeBlotter.Model
|
||||
LocalPriceCache.GetInstance().RemoveDate(maxDate);
|
||||
List<DateTime> historicalDates=dateGenerator.GenerateHistoricalDates(minDate,maxDate);
|
||||
|
||||
foreach(MGSHPositionModel position in positions)
|
||||
{
|
||||
if(dateGenerator.IsWeekend(position.PurchaseDate))
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
position.PurchaseDate=dateGenerator.GetNextBusinessDay(position.PurchaseDate);
|
||||
if(!HolidayDA.IsMarketHoliday(position.PurchaseDate)) break;
|
||||
}
|
||||
}
|
||||
if(dateGenerator.IsWeekend(position.SellDate))
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
position.SellDate=dateGenerator.GetNextBusinessDay(position.SellDate);
|
||||
if(!HolidayDA.IsMarketHoliday(position.SellDate)) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fix purchase date/sell date fall on weekend
|
||||
//foreach(MGSHPositionModel position in positions)
|
||||
//{
|
||||
// if(dateGenerator.IsWeekend(position.PurchaseDate))
|
||||
// {
|
||||
// while(true)
|
||||
// {
|
||||
// position.PurchaseDate=dateGenerator.GetNextBusinessDay(position.PurchaseDate);
|
||||
// if(!HolidayDA.IsMarketHoliday(position.PurchaseDate)) break;
|
||||
// }
|
||||
// }
|
||||
// if(dateGenerator.IsWeekend(position.SellDate))
|
||||
// {
|
||||
// while(true)
|
||||
// {
|
||||
// position.SellDate=dateGenerator.GetNextBusinessDay(position.SellDate);
|
||||
// if(!HolidayDA.IsMarketHoliday(position.SellDate)) break;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
foreach(DateTime currentDate in historicalDates)
|
||||
{
|
||||
IEnumerable<MGSHPositionModel> openPositions=positions.Where(x => (x.PurchaseDate<=currentDate&&(!Utility.IsEpoch(x.SellDate)&&x.SellDate>currentDate))||(x.PurchaseDate<=currentDate&&Utility.IsEpoch(x.SellDate))).ToList();
|
||||
|
||||
Reference in New Issue
Block a user