Fix Stop Limits in all models.

This commit is contained in:
2026-02-18 19:42:37 -05:00
parent a510a63772
commit 02315ab6ac
5 changed files with 12 additions and 12 deletions

View File

@@ -1057,7 +1057,7 @@ namespace TradeBlotter.ViewModels
{
bool deleteStop=false;
MGSHPosition clonedPosition=MGSHPosition.Clone(selectedPosition.Position);
bool hasStopLimit=StopLimitDA.HasStopLimit(clonedPosition.Symbol);
bool hasStopLimit=StopLimitDA.HasStopLimit(clonedPosition.Symbol,clonedPosition.Shares);
IPosition changedPosition=ClosePositionDialog.Prompt("Close Position",clonedPosition,hasStopLimit,ref deleteStop);
if(null==changedPosition) return;
MGSHMomentumBacktest mgshMomentumBacktest = new MGSHMomentumBacktest();
@@ -1066,7 +1066,7 @@ namespace TradeBlotter.ViewModels
MessageBox.Show("Failed to close the position, check log for details.","Close Position");
return;
}
if(deleteStop) StopLimitDA.DeleteStopLimit(changedPosition.Symbol);
if(deleteStop) StopLimitDA.DeleteStopLimit(changedPosition.Symbol,changedPosition.Shares);
String strMessage=String.Format("Closed position for {0}, Purchase Date:{1}, Sell Date{2}, Current Price:{3}, Delete Stop:{4} to {5}. A backup was created.",
changedPosition.Symbol,changedPosition.PurchaseDate.ToShortDateString(),changedPosition.SellDate.ToShortDateString(),Utility.FormatCurrency(changedPosition.CurrentPrice),deleteStop,pathFileName);
MessageBox.Show(strMessage,"Close Position");
@@ -1088,7 +1088,7 @@ namespace TradeBlotter.ViewModels
{
selectedPosition.TrailingStopLimit = changedPosition.TrailingStopLimit;
selectedPosition.LastStopAdjustment = DateTime.Now.Date;
StopLimit stopLimit = StopLimitDA.GetStopLimit(changedPosition.Symbol);
StopLimit stopLimit = StopLimitDA.GetStopLimit(changedPosition.Symbol,changedPosition.Shares);
if (null == stopLimit)
{
stopLimit = new StopLimit();