Fix MGSHBacktest edit hedge position
This commit is contained in:
@@ -103,10 +103,15 @@ namespace MarketData.Generator.MGSHMomentum
|
||||
if(!BackupSession())return false;
|
||||
MGSHPositions activePositions = ActivePositions.GetPositions();
|
||||
MGSHPosition position = activePositions.Where(x => x.Symbol.Equals(symbol) && x.PurchaseDate.Equals(purchaseDate)).FirstOrDefault();
|
||||
if (null == position)
|
||||
if (null == position) // if it's not in the active positions then look in the hedge positions
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, String.Format("Cannot locate position for symbol '{0}' purchased on {1}.", symbol, purchaseDate.ToShortDateString()));
|
||||
return false;
|
||||
MGSHPositions hedgePositions = HedgePositions;
|
||||
position = hedgePositions.Where(x => x.Symbol.Equals(symbol) && x.PurchaseDate.Equals(purchaseDate)).FirstOrDefault();
|
||||
if (null == position)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, String.Format("Cannot locate position for symbol '{0}' purchased on {1}.", symbol, purchaseDate.ToShortDateString()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!position.PurchaseDate.Equals(purchaseDate)) position.PurchaseDate = purchaseDate;
|
||||
if (!position.TrailingStopLimit.Equals(trailingStop)) position.TrailingStopLimit = trailingStop;
|
||||
|
||||
Reference in New Issue
Block a user