diff --git a/Model/CMTPositionModel.cs b/Model/CMTPositionModel.cs index 6a6d20f..4ea17fa 100644 --- a/Model/CMTPositionModel.cs +++ b/Model/CMTPositionModel.cs @@ -71,8 +71,10 @@ namespace TradeBlotter.Model base.OnPropertyChanged("ActiveMarketValue"); base.OnPropertyChanged("GainLoss"); base.OnPropertyChanged("GainLossPcnt"); - base.OnPropertyChanged("RMultipleAsString"); +// base.OnPropertyChanged("RMultipleAsString"); + base.OnPropertyChanged("RMultiple"); base.OnPropertyChanged("EdgeRatioAsString"); + base.OnPropertyChanged("CurrentPriceColor"); base.OnPropertyChanged("TrailingStopLimitColor"); base.OnPropertyChanged("InitialStopLimitColor"); @@ -81,6 +83,7 @@ namespace TradeBlotter.Model base.OnPropertyChanged("GainLossColor"); base.OnPropertyChanged("GainLossPcntColor"); base.OnPropertyChanged("EdgeRatioAsStringColor"); + base.OnPropertyChanged("RMultipleColor"); } public Position Position { @@ -229,7 +232,13 @@ namespace TradeBlotter.Model { get{return Utility.FormatNumber((position.CurrentPrice-position.PurchasePrice)/(position.PurchasePrice-position.InitialStopLimit),2,false)+"R";} // always based on original position risk } - public Brush RMultipleAsStringColor + + public double RMultiple + { + get{return (position.CurrentPrice-position.PurchasePrice)/(position.PurchasePrice-position.InitialStopLimit);} // always based on original position risk + } + + public Brush RMultipleColor { get { diff --git a/Model/MGSHPositionModel.cs b/Model/MGSHPositionModel.cs index b5df854..d86200e 100644 --- a/Model/MGSHPositionModel.cs +++ b/Model/MGSHPositionModel.cs @@ -48,6 +48,7 @@ namespace TradeBlotter.Model base.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset,null)); } } + public class MGSHPositionModel : ModelBase, IPositionModel { private MGSHPosition position = new MGSHPosition(); @@ -61,6 +62,7 @@ namespace TradeBlotter.Model public MGSHPositionModel() { } + public MGSHPositionModel(MGSHPosition position, int slot) { Slot=slot; @@ -84,6 +86,7 @@ namespace TradeBlotter.Model InitialStopLimit=position.InitialStopLimit; TrailingStopLimit=position.TrailingStopLimit; LastStopAdjustment=position.LastStopAdjustment; + PositionRiskPercentDecimal=position.PositionRiskPercentDecimal; Comment=position.Comment; } public MGSHPositionModel(MGSHPosition position) @@ -109,6 +112,7 @@ namespace TradeBlotter.Model InitialStopLimit=position.InitialStopLimit; TrailingStopLimit=position.TrailingStopLimit; LastStopAdjustment=position.LastStopAdjustment; + PositionRiskPercentDecimal=position.PositionRiskPercentDecimal; Comment=position.Comment; } @@ -138,6 +142,7 @@ namespace TradeBlotter.Model InitialStopLimit=position.InitialStopLimit; TrailingStopLimit=position.TrailingStopLimit; LastStopAdjustment=position.LastStopAdjustment; + PositionRiskPercentDecimal=position.PositionRiskPercentDecimal; Comment=position.Comment; this.position.R=position.R; } @@ -150,13 +155,23 @@ namespace TradeBlotter.Model base.OnPropertyChanged("ActiveMarketValue"); base.OnPropertyChanged("GainLoss"); base.OnPropertyChanged("GainLossPcnt"); + base.OnPropertyChanged("Comment"); + base.OnPropertyChanged("PositionRiskPercentDecimal"); + base.OnPropertyChanged("R"); + base.OnPropertyChanged("TotalRiskExposure"); + base.OnPropertyChanged("RMultiple"); + + base.OnPropertyChanged("CurrentPriceColor"); base.OnPropertyChanged("TrailingStopLimitColor"); base.OnPropertyChanged("InitialStopLimitColor"); base.OnPropertyChanged("ActiveMarketValueColor"); base.OnPropertyChanged("GainLossColor"); base.OnPropertyChanged("GainLossPcntColor"); - base.OnPropertyChanged("Comment"); + base.OnPropertyChanged("RColor"); + base.OnPropertyChanged("TotalRiskExposureColor"); + base.OnPropertyChanged("RMultipleColor"); + } public String Symbol @@ -170,6 +185,7 @@ namespace TradeBlotter.Model get{return position.Comment;} set{position.Comment=value;base.OnPropertyChanged("Comment");} } + public DateTime PurchaseDate { get{return position.PurchaseDate;} @@ -225,16 +241,99 @@ namespace TradeBlotter.Model return Slot.ToString(); } } + + public double PositionRiskPercentDecimal + { + get + { + return position.PositionRiskPercentDecimal; + } + set + { + position.PositionRiskPercentDecimal=value; + base.OnPropertyChanged("PositionRiskPercentDecimal"); + } + } + +// ************************************************************************************************************************************ +// ******************************************************************** R I S K ******************************************************* +// ************************************************************************************************************************************ + + public double R + { + get + { + if(position.TrailingStopLimit>position.PurchasePrice)return 0.00; // here we are considering the current risk/share which is based on our stop limit + return position.TrailingStopLimit>position.PurchasePrice?0.00:position.PurchasePrice-position.TrailingStopLimit; + } + } + public Brush RColor + { + get + { + if(!IsActivePosition) return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Blue); + return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black); + } + } + + public String RMultipleAsString + { + get { return Utility.FormatNumber((position.CurrentPrice - position.PurchasePrice) / (position.PurchasePrice - position.InitialStopLimit), 2, false) + "R"; } // always based on original position risk + } + + //public Brush RMultipleAsStringColor + //{ + // get + // { + // if (!IsActivePosition) return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Blue); + // return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black); + // } + //} + + + public double RMultiple + { + get{return (position.CurrentPrice-position.PurchasePrice)/(position.PurchasePrice-position.InitialStopLimit);} // always based on original position risk + } + + public Brush RMultipleColor + { + get + { + if (!IsActivePosition) return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Blue); + return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black); + } + } + + public double TotalRiskExposure + { + get{return R*position.Shares;} + } + + public Brush TotalRiskExposureColor + { + get + { + if(!IsActivePosition) return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Blue); + return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black); + } + } + +// ************************************************************************************************************************************ + + 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;} @@ -250,6 +349,7 @@ namespace TradeBlotter.Model UpdateProperties(); } } + public double RSI3 { get{return rsi3;} @@ -261,11 +361,13 @@ namespace TradeBlotter.Model base.OnPropertyChanged("RSI3Color"); } } + public DateTime LastUpdated { get{return lastUpdated;} set{lastUpdated=value;base.OnPropertyChanged("LastUpdated");} } + public Brush CurrentPriceColor { get @@ -276,6 +378,7 @@ namespace TradeBlotter.Model else return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black); } } + public Brush RSI3Color { get @@ -285,14 +388,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 @@ -301,14 +407,17 @@ namespace TradeBlotter.Model else return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black); } } + public double MarketValue { get{return Shares*CurrentPrice;} } + public double ActiveMarketValue { get{return IsActivePosition?MarketValue:0.00;} } + public Brush ActiveMarketValueColor { get @@ -319,20 +428,24 @@ namespace TradeBlotter.Model else return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black); } } + public long Volume { get{return position.Volume;} set{position.Volume=value;base.OnPropertyChanged("Volume");} } + public double Return1D { get{return position.Return1D;} set{position.Return1D=value;base.OnPropertyChanged("Return1D");} } + public double GainLoss { get{return MarketValue-Exposure;} } + public Brush GainLossColor { get @@ -347,6 +460,7 @@ namespace TradeBlotter.Model { get{return (MarketValue-Exposure)/Exposure;} } + public Brush GainLossPcntColor { get @@ -357,51 +471,61 @@ namespace TradeBlotter.Model else return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black); } } + public double CumReturn252 { get{return position.CumReturn252;} set{position.CumReturn252=value;base.OnPropertyChanged("CumReturn252");} } + public double IDIndicator { get{return position.IDIndicator;} set{position.IDIndicator=value;base.OnPropertyChanged("IDIndicator");} } + public double Score { get { return position.Score; } set { position.Score=value; base.OnPropertyChanged("Score"); } } + public double MaxDrawdown { get{return position.MaxDrawdown;} set{position.MaxDrawdown=value;base.OnPropertyChanged("MaxDrawdown");} } + public double MaxUpside { get{return position.MaxUpside;} set{position.MaxUpside=value;base.OnPropertyChanged("MaxUpside");} } + public double Velocity { get{return position.Velocity;} set{position.Velocity=value;base.OnPropertyChanged("Velocity");} } + public double PE { get{return position.PE;} set{position.PE=value;base.OnPropertyChanged("PE");} } + public String ZacksRank { get {return position.ZacksRank;} set{position.ZacksRank=value;base.OnPropertyChanged("ZacksRank");} } + public double Beta { get{return position.Beta;} set{position.Beta=value;base.OnPropertyChanged("Beta");} } + public bool IsActivePosition { get{return Utility.IsEpoch(SellDate)?true:false;} @@ -430,6 +554,7 @@ namespace TradeBlotter.Model return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black); } } + public double TrailingStopLimit { get { return position.TrailingStopLimit; } @@ -440,6 +565,7 @@ namespace TradeBlotter.Model base.OnPropertyChanged("TrailingStopLimitColor"); } } + public Brush TrailingStopLimitColor { get @@ -457,6 +583,7 @@ namespace TradeBlotter.Model get { return position.LastStopAdjustment; } set { position.LastStopAdjustment=value; base.OnPropertyChanged("LastStopAdjustment"); } } + public Brush LastStopAdjustmentColor { get