diff --git a/ViewModels/CMTTrendViewModel.cs b/ViewModels/CMTTrendViewModel.cs index fcdb05c..432c918 100644 --- a/ViewModels/CMTTrendViewModel.cs +++ b/ViewModels/CMTTrendViewModel.cs @@ -1063,12 +1063,13 @@ namespace TradeBlotter.ViewModels saveParams.Referer=this; WorkspaceInstantiator.Invoke(saveParams); } + public void ClosePositionCommand(CMTPositionModel selectedPosition) { bool deleteStop=false; Position clonedPosition=Position.Clone(selectedPosition.Position); bool hasStopLimit=PortfolioDA.HasStopLimit(clonedPosition.Symbol); - Position changedPosition=CMTTrendModelClosePositionDialog.Prompt("Close Position",clonedPosition,hasStopLimit,ref deleteStop); + IPosition changedPosition=ClosePositionDialog.Prompt("Close Position",clonedPosition,hasStopLimit,ref deleteStop); if(null==changedPosition) return; CMTTrendModel mmTrendModel=new CMTTrendModel(); if(!mmTrendModel.ClosePosition(changedPosition.Symbol,changedPosition.PurchaseDate,changedPosition.SellDate,changedPosition.CurrentPrice,pathFileName)) @@ -1383,6 +1384,7 @@ namespace TradeBlotter.ViewModels { get { + if(null==selectedPosition)return "Please select a position by clicking on a row."; StringBuilder sb=new StringBuilder(); sb.Append("RMultiple is based on original position setup.").Append("\n"); sb.Append("Original Exposure=").Append(Utility.FormatCurrency(selectedPosition.PurchasePrice*selectedPosition.Shares)).Append("\n"); @@ -1400,6 +1402,7 @@ namespace TradeBlotter.ViewModels { get { + if(null==selectedPosition)return "Please select a position by clicking on a row."; StringBuilder sb=new StringBuilder(); sb.Append("Current Risk. See RMultiple for initial risk assumptions.").Append("\n"); sb.Append("[TotalRiskExposure]=([R/Share]*[Shares])").Append("\n"); @@ -1412,8 +1415,8 @@ namespace TradeBlotter.ViewModels { get { - StringBuilder sb=new StringBuilder(); if(null==selectedPosition)return "Please select a position by clicking on a row."; + StringBuilder sb=new StringBuilder(); sb.Append("Current R/Share. See RMultiple for initial risk assumptions.").Append("\n"); sb.Append("R/Share=TrailingStop>PurchasePrice?0.00:PurchasePrice-TrailingStop").Append("\n"); if(selectedPosition.TrailingStopLimit>selectedPosition.PurchasePrice) @@ -1432,8 +1435,8 @@ namespace TradeBlotter.ViewModels { get { - StringBuilder sb=new StringBuilder(); if(null==selectedPosition) return "Please select a position by clicking on a row."; + StringBuilder sb=new StringBuilder(); sb.Append("[Low]=([CurrentLowPrice])").Append("\n"); sb.Append(Utility.FormatCurrency(selectedPosition.CurrentPriceLow)).Append("=").Append(Utility.FormatCurrency(selectedPosition.CurrentPriceLow)); return sb.ToString(); @@ -1443,8 +1446,8 @@ namespace TradeBlotter.ViewModels { get { - StringBuilder sb=new StringBuilder(); if(null==selectedPosition) return "Please select a position by clicking on a row."; + StringBuilder sb=new StringBuilder(); sb.Append("[Price]=([CurrentPrice])").Append("\n"); sb.Append(Utility.FormatCurrency(selectedPosition.CurrentPrice)).Append("=").Append(Utility.FormatCurrency(selectedPosition.CurrentPrice)); return sb.ToString(); @@ -1454,8 +1457,8 @@ namespace TradeBlotter.ViewModels { get { - StringBuilder sb=new StringBuilder(); if(null==selectedPosition) return "Please select a position by clicking on a row."; + StringBuilder sb=new StringBuilder(); sb.Append("[TrailingStop]=([TrailingStopLimit])").Append("\n"); sb.Append(Utility.FormatCurrency(selectedPosition.TrailingStopLimit)).Append("=").Append(Utility.FormatCurrency(selectedPosition.TrailingStopLimit)).Append("\n"); List stopLimits=GetHistoricalStopLimits(); @@ -1484,8 +1487,8 @@ namespace TradeBlotter.ViewModels { get { - StringBuilder sb=new StringBuilder(); if(null==selectedPosition) return "Please select a position by clicking on a row."; + StringBuilder sb=new StringBuilder(); sb.Append("[InitialStop]=([InitialStopLimit])").Append("\n"); sb.Append(Utility.FormatCurrency(selectedPosition.InitialStopLimit)).Append("=").Append(Utility.FormatCurrency(selectedPosition.InitialStopLimit)); return sb.ToString(); @@ -1495,8 +1498,8 @@ namespace TradeBlotter.ViewModels { get { - StringBuilder sb=new StringBuilder(); if(null==selectedPosition) return "Please select a position by clicking on a row."; + StringBuilder sb=new StringBuilder(); sb.Append("[PurchasePrice]=([PurchasePrice])").Append("\n"); sb.Append(Utility.FormatCurrency(selectedPosition.PurchasePrice)).Append("=").Append(Utility.FormatCurrency(selectedPosition.PurchasePrice)); return sb.ToString(); @@ -1506,8 +1509,8 @@ namespace TradeBlotter.ViewModels { get { - StringBuilder sb=new StringBuilder(); if(null==selectedPosition) return "Please select a position by clicking on a row."; + StringBuilder sb=new StringBuilder(); sb.Append("[EdgeRatio]=AVG(SUM(MFE/ATR(14)))/AVG(SUM(MAE/ATR(14)))").Append("\n"); sb.Append("MFE=Maximum Favorable Excursion").Append("\n"); sb.Append("MAE=Maximum Adverse Excursion").Append("\n");