Fix potential issue when selecting the fallback candidate and share count is zero.
This commit is contained in:
@@ -393,12 +393,13 @@ namespace MarketData.Generator.Momentum
|
||||
Positions positions = null;
|
||||
positions=BuyPositions(TradeDate,AnalysisDate,CashBalance/((double)HoldingPeriod-(double)ActivePositions.Count),SymbolsHeld(TradeDate));
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, "******************** B U Y ********************");
|
||||
positions.Display();
|
||||
if(CashBalance-positions.Exposure<0.00)
|
||||
{
|
||||
positions.Clear();
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("********** Insufficient funds to make additional purchases.**************"));
|
||||
break;
|
||||
// break;
|
||||
}
|
||||
positions.Display();
|
||||
ActivePositions.Add(slotIndex,positions);
|
||||
CashBalance-=positions.Exposure;
|
||||
DisplayBalance();
|
||||
@@ -590,6 +591,7 @@ namespace MarketData.Generator.Momentum
|
||||
position.PurchasePrice = price.Close;
|
||||
position.CurrentPrice = price.Close;
|
||||
position.Shares = (int)Math.Floor(cash / position.PurchasePrice);
|
||||
if(0 == position.Shares)return positions;
|
||||
positions.Add(position);
|
||||
}
|
||||
return positions;
|
||||
|
||||
Reference in New Issue
Block a user