Make the RMultiple a numeric value in the Telerik grid.

This commit is contained in:
2025-02-11 19:22:01 -05:00
parent 230d84904a
commit 16a65341e2
2 changed files with 139 additions and 3 deletions

View File

@@ -71,8 +71,10 @@ namespace TradeBlotter.Model
base.OnPropertyChanged("ActiveMarketValue"); base.OnPropertyChanged("ActiveMarketValue");
base.OnPropertyChanged("GainLoss"); base.OnPropertyChanged("GainLoss");
base.OnPropertyChanged("GainLossPcnt"); base.OnPropertyChanged("GainLossPcnt");
base.OnPropertyChanged("RMultipleAsString"); // base.OnPropertyChanged("RMultipleAsString");
base.OnPropertyChanged("RMultiple");
base.OnPropertyChanged("EdgeRatioAsString"); base.OnPropertyChanged("EdgeRatioAsString");
base.OnPropertyChanged("CurrentPriceColor"); base.OnPropertyChanged("CurrentPriceColor");
base.OnPropertyChanged("TrailingStopLimitColor"); base.OnPropertyChanged("TrailingStopLimitColor");
base.OnPropertyChanged("InitialStopLimitColor"); base.OnPropertyChanged("InitialStopLimitColor");
@@ -81,6 +83,7 @@ namespace TradeBlotter.Model
base.OnPropertyChanged("GainLossColor"); base.OnPropertyChanged("GainLossColor");
base.OnPropertyChanged("GainLossPcntColor"); base.OnPropertyChanged("GainLossPcntColor");
base.OnPropertyChanged("EdgeRatioAsStringColor"); base.OnPropertyChanged("EdgeRatioAsStringColor");
base.OnPropertyChanged("RMultipleColor");
} }
public Position Position 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 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 get
{ {

View File

@@ -48,6 +48,7 @@ namespace TradeBlotter.Model
base.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset,null)); base.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset,null));
} }
} }
public class MGSHPositionModel : ModelBase, IPositionModel public class MGSHPositionModel : ModelBase, IPositionModel
{ {
private MGSHPosition position = new MGSHPosition(); private MGSHPosition position = new MGSHPosition();
@@ -61,6 +62,7 @@ namespace TradeBlotter.Model
public MGSHPositionModel() public MGSHPositionModel()
{ {
} }
public MGSHPositionModel(MGSHPosition position, int slot) public MGSHPositionModel(MGSHPosition position, int slot)
{ {
Slot=slot; Slot=slot;
@@ -84,6 +86,7 @@ namespace TradeBlotter.Model
InitialStopLimit=position.InitialStopLimit; InitialStopLimit=position.InitialStopLimit;
TrailingStopLimit=position.TrailingStopLimit; TrailingStopLimit=position.TrailingStopLimit;
LastStopAdjustment=position.LastStopAdjustment; LastStopAdjustment=position.LastStopAdjustment;
PositionRiskPercentDecimal=position.PositionRiskPercentDecimal;
Comment=position.Comment; Comment=position.Comment;
} }
public MGSHPositionModel(MGSHPosition position) public MGSHPositionModel(MGSHPosition position)
@@ -109,6 +112,7 @@ namespace TradeBlotter.Model
InitialStopLimit=position.InitialStopLimit; InitialStopLimit=position.InitialStopLimit;
TrailingStopLimit=position.TrailingStopLimit; TrailingStopLimit=position.TrailingStopLimit;
LastStopAdjustment=position.LastStopAdjustment; LastStopAdjustment=position.LastStopAdjustment;
PositionRiskPercentDecimal=position.PositionRiskPercentDecimal;
Comment=position.Comment; Comment=position.Comment;
} }
@@ -138,6 +142,7 @@ namespace TradeBlotter.Model
InitialStopLimit=position.InitialStopLimit; InitialStopLimit=position.InitialStopLimit;
TrailingStopLimit=position.TrailingStopLimit; TrailingStopLimit=position.TrailingStopLimit;
LastStopAdjustment=position.LastStopAdjustment; LastStopAdjustment=position.LastStopAdjustment;
PositionRiskPercentDecimal=position.PositionRiskPercentDecimal;
Comment=position.Comment; Comment=position.Comment;
this.position.R=position.R; this.position.R=position.R;
} }
@@ -150,13 +155,23 @@ namespace TradeBlotter.Model
base.OnPropertyChanged("ActiveMarketValue"); base.OnPropertyChanged("ActiveMarketValue");
base.OnPropertyChanged("GainLoss"); base.OnPropertyChanged("GainLoss");
base.OnPropertyChanged("GainLossPcnt"); base.OnPropertyChanged("GainLossPcnt");
base.OnPropertyChanged("Comment");
base.OnPropertyChanged("PositionRiskPercentDecimal");
base.OnPropertyChanged("R");
base.OnPropertyChanged("TotalRiskExposure");
base.OnPropertyChanged("RMultiple");
base.OnPropertyChanged("CurrentPriceColor"); base.OnPropertyChanged("CurrentPriceColor");
base.OnPropertyChanged("TrailingStopLimitColor"); base.OnPropertyChanged("TrailingStopLimitColor");
base.OnPropertyChanged("InitialStopLimitColor"); base.OnPropertyChanged("InitialStopLimitColor");
base.OnPropertyChanged("ActiveMarketValueColor"); base.OnPropertyChanged("ActiveMarketValueColor");
base.OnPropertyChanged("GainLossColor"); base.OnPropertyChanged("GainLossColor");
base.OnPropertyChanged("GainLossPcntColor"); base.OnPropertyChanged("GainLossPcntColor");
base.OnPropertyChanged("Comment"); base.OnPropertyChanged("RColor");
base.OnPropertyChanged("TotalRiskExposureColor");
base.OnPropertyChanged("RMultipleColor");
} }
public String Symbol public String Symbol
@@ -170,6 +185,7 @@ namespace TradeBlotter.Model
get{return position.Comment;} get{return position.Comment;}
set{position.Comment=value;base.OnPropertyChanged("Comment");} set{position.Comment=value;base.OnPropertyChanged("Comment");}
} }
public DateTime PurchaseDate public DateTime PurchaseDate
{ {
get{return position.PurchaseDate;} get{return position.PurchaseDate;}
@@ -225,16 +241,99 @@ namespace TradeBlotter.Model
return Slot.ToString(); 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 public double Shares
{ {
get{return position.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");} 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 public double PurchasePrice
{ {
get{return position.PurchasePrice;} get{return position.PurchasePrice;}
set{position.PurchasePrice=value;base.OnPropertyChanged("PurchasePrice");base.OnPropertyChanged("Exposure");base.OnPropertyChanged("ActiveExposure");base.OnPropertyChanged("GainLoss");base.OnPropertyChanged("GainLossPcnt");} set{position.PurchasePrice=value;base.OnPropertyChanged("PurchasePrice");base.OnPropertyChanged("Exposure");base.OnPropertyChanged("ActiveExposure");base.OnPropertyChanged("GainLoss");base.OnPropertyChanged("GainLossPcnt");}
} }
public double CurrentPrice public double CurrentPrice
{ {
get{return position.CurrentPrice;} get{return position.CurrentPrice;}
@@ -250,6 +349,7 @@ namespace TradeBlotter.Model
UpdateProperties(); UpdateProperties();
} }
} }
public double RSI3 public double RSI3
{ {
get{return rsi3;} get{return rsi3;}
@@ -261,11 +361,13 @@ namespace TradeBlotter.Model
base.OnPropertyChanged("RSI3Color"); base.OnPropertyChanged("RSI3Color");
} }
} }
public DateTime LastUpdated public DateTime LastUpdated
{ {
get{return lastUpdated;} get{return lastUpdated;}
set{lastUpdated=value;base.OnPropertyChanged("LastUpdated");} set{lastUpdated=value;base.OnPropertyChanged("LastUpdated");}
} }
public Brush CurrentPriceColor public Brush CurrentPriceColor
{ {
get get
@@ -276,6 +378,7 @@ namespace TradeBlotter.Model
else return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black); else return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black);
} }
} }
public Brush RSI3Color public Brush RSI3Color
{ {
get get
@@ -285,14 +388,17 @@ namespace TradeBlotter.Model
return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black); return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black);
} }
} }
public double Exposure public double Exposure
{ {
get{return Shares*PurchasePrice;} get{return Shares*PurchasePrice;}
} }
public double ActiveExposure public double ActiveExposure
{ {
get{return IsActivePosition?Exposure:0.00;} get{return IsActivePosition?Exposure:0.00;}
} }
public Brush ActiveExposureColor public Brush ActiveExposureColor
{ {
get get
@@ -301,14 +407,17 @@ namespace TradeBlotter.Model
else return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black); else return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black);
} }
} }
public double MarketValue public double MarketValue
{ {
get{return Shares*CurrentPrice;} get{return Shares*CurrentPrice;}
} }
public double ActiveMarketValue public double ActiveMarketValue
{ {
get{return IsActivePosition?MarketValue:0.00;} get{return IsActivePosition?MarketValue:0.00;}
} }
public Brush ActiveMarketValueColor public Brush ActiveMarketValueColor
{ {
get get
@@ -319,20 +428,24 @@ namespace TradeBlotter.Model
else return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black); else return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black);
} }
} }
public long Volume public long Volume
{ {
get{return position.Volume;} get{return position.Volume;}
set{position.Volume=value;base.OnPropertyChanged("Volume");} set{position.Volume=value;base.OnPropertyChanged("Volume");}
} }
public double Return1D public double Return1D
{ {
get{return position.Return1D;} get{return position.Return1D;}
set{position.Return1D=value;base.OnPropertyChanged("Return1D");} set{position.Return1D=value;base.OnPropertyChanged("Return1D");}
} }
public double GainLoss public double GainLoss
{ {
get{return MarketValue-Exposure;} get{return MarketValue-Exposure;}
} }
public Brush GainLossColor public Brush GainLossColor
{ {
get get
@@ -347,6 +460,7 @@ namespace TradeBlotter.Model
{ {
get{return (MarketValue-Exposure)/Exposure;} get{return (MarketValue-Exposure)/Exposure;}
} }
public Brush GainLossPcntColor public Brush GainLossPcntColor
{ {
get get
@@ -357,51 +471,61 @@ namespace TradeBlotter.Model
else return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black); else return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black);
} }
} }
public double CumReturn252 public double CumReturn252
{ {
get{return position.CumReturn252;} get{return position.CumReturn252;}
set{position.CumReturn252=value;base.OnPropertyChanged("CumReturn252");} set{position.CumReturn252=value;base.OnPropertyChanged("CumReturn252");}
} }
public double IDIndicator public double IDIndicator
{ {
get{return position.IDIndicator;} get{return position.IDIndicator;}
set{position.IDIndicator=value;base.OnPropertyChanged("IDIndicator");} set{position.IDIndicator=value;base.OnPropertyChanged("IDIndicator");}
} }
public double Score public double Score
{ {
get { return position.Score; } get { return position.Score; }
set { position.Score=value; base.OnPropertyChanged("Score"); } set { position.Score=value; base.OnPropertyChanged("Score"); }
} }
public double MaxDrawdown public double MaxDrawdown
{ {
get{return position.MaxDrawdown;} get{return position.MaxDrawdown;}
set{position.MaxDrawdown=value;base.OnPropertyChanged("MaxDrawdown");} set{position.MaxDrawdown=value;base.OnPropertyChanged("MaxDrawdown");}
} }
public double MaxUpside public double MaxUpside
{ {
get{return position.MaxUpside;} get{return position.MaxUpside;}
set{position.MaxUpside=value;base.OnPropertyChanged("MaxUpside");} set{position.MaxUpside=value;base.OnPropertyChanged("MaxUpside");}
} }
public double Velocity public double Velocity
{ {
get{return position.Velocity;} get{return position.Velocity;}
set{position.Velocity=value;base.OnPropertyChanged("Velocity");} set{position.Velocity=value;base.OnPropertyChanged("Velocity");}
} }
public double PE public double PE
{ {
get{return position.PE;} get{return position.PE;}
set{position.PE=value;base.OnPropertyChanged("PE");} set{position.PE=value;base.OnPropertyChanged("PE");}
} }
public String ZacksRank public String ZacksRank
{ {
get {return position.ZacksRank;} get {return position.ZacksRank;}
set{position.ZacksRank=value;base.OnPropertyChanged("ZacksRank");} set{position.ZacksRank=value;base.OnPropertyChanged("ZacksRank");}
} }
public double Beta public double Beta
{ {
get{return position.Beta;} get{return position.Beta;}
set{position.Beta=value;base.OnPropertyChanged("Beta");} set{position.Beta=value;base.OnPropertyChanged("Beta");}
} }
public bool IsActivePosition public bool IsActivePosition
{ {
get{return Utility.IsEpoch(SellDate)?true:false;} get{return Utility.IsEpoch(SellDate)?true:false;}
@@ -430,6 +554,7 @@ namespace TradeBlotter.Model
return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black); return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black);
} }
} }
public double TrailingStopLimit public double TrailingStopLimit
{ {
get { return position.TrailingStopLimit; } get { return position.TrailingStopLimit; }
@@ -440,6 +565,7 @@ namespace TradeBlotter.Model
base.OnPropertyChanged("TrailingStopLimitColor"); base.OnPropertyChanged("TrailingStopLimitColor");
} }
} }
public Brush TrailingStopLimitColor public Brush TrailingStopLimitColor
{ {
get get
@@ -457,6 +583,7 @@ namespace TradeBlotter.Model
get { return position.LastStopAdjustment; } get { return position.LastStopAdjustment; }
set { position.LastStopAdjustment=value; base.OnPropertyChanged("LastStopAdjustment"); } set { position.LastStopAdjustment=value; base.OnPropertyChanged("LastStopAdjustment"); }
} }
public Brush LastStopAdjustmentColor public Brush LastStopAdjustmentColor
{ {
get get