Add changes to all models to eliminate selling and immediately buying back the same security as this is considered a Wash Trade and is illegal.
Some checks failed
Build .NET Project / build (push) Has been cancelled

This commit is contained in:
2026-03-19 19:49:09 -04:00
parent 230e2b931f
commit e48588c13a
5 changed files with 22 additions and 13 deletions

View File

@@ -378,6 +378,7 @@ namespace MarketData.Generator.Momentum
else
{
Positions slotPositions=ActivePositions[slotIndex];
List<String> closedSymbols = slotPositions.ConvertAll(x => x.Symbol); // capture the sell symbols to avoid buying straight back (wash trades)
SellPositions(slotPositions,TradeDate);
MDTrace.WriteLine(LogLevel.DEBUG,"********************* S E L L *********************");
slotPositions.Display();
@@ -390,7 +391,7 @@ namespace MarketData.Generator.Momentum
cashAllocation = Math.Min(CashBalance, (ActivePositions.GetExposure() + CashBalance) / (double)HoldingPeriod);
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("CASH ALLOCATION:{0}",Utility.FormatCurrency(cashAllocation)));
Positions positions = null;
positions=BuyPositions(TradeDate,AnalysisDate,cashAllocation,SymbolsHeld(TradeDate));
positions=BuyPositions(TradeDate,AnalysisDate,cashAllocation,new List<String>(SymbolsHeld(TradeDate).Concat(closedSymbols)));
MDTrace.WriteLine(LogLevel.DEBUG,"********************** B U Y ********************");
positions.Display();
if(CashBalance-positions.Exposure<=0.00)