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
Some checks failed
Build .NET Project / build (push) Has been cancelled
This commit is contained in:
@@ -219,10 +219,8 @@ namespace MarketData.Generator.MGSHMomentum
|
||||
double losingTrades=sessionParams.AllPositions.Where(x => x.GainLoss<0.00).Count();
|
||||
MGSHPositions winningTradeList = new MGSHPositions(sessionParams.AllPositions.Where(x => x.GainLoss>=0.00).ToList());
|
||||
double averageWinningTrade = winningTradeList.Count>0?winningTradeList.Average(x => x.GainLossPcnt)*100.00:0.00;
|
||||
// double averageWinningTrade=sessionParams.AllPositions.Where(x => x.GainLoss>=0.00).Average(x => x.GainLossPcnt)*100.00;
|
||||
MGSHPositions losingTradeList = new MGSHPositions(sessionParams.AllPositions.Where(x => x.GainLoss<0.00).ToList());
|
||||
double averageLosingTrade = losingTradeList.Count>0?losingTradeList.Average(x => x.GainLossPcnt)*100.00:0.00;
|
||||
// double averageLosingTrade=sessionParams.AllPositions.Where(x => x.GainLoss<0.00).Average(x => x.GainLossPcnt)*100.00;
|
||||
|
||||
double percentWinningTrades=(winningTrades/(double)sessionParams.AllPositions.Count)*100.00;
|
||||
double percentLosingTrades=(losingTrades/(double)sessionParams.AllPositions.Count)*100.00;
|
||||
@@ -520,8 +518,10 @@ namespace MarketData.Generator.MGSHMomentum
|
||||
public void SellAndBuySlotPositions(int slotIndex)
|
||||
{
|
||||
MGSHPositions slotPositions=ActivePositions[slotIndex];
|
||||
List<String> closedSymbols = new List<String>();
|
||||
if(!Configuration.KeepSlotPositions) // if we are not configured to KeepSlotPositions then don't sell anything just buy to the max positions allowed for the slot
|
||||
{
|
||||
closedSymbols = slotPositions.ConvertAll(x => x.Symbol); // capture the closed symbols so we can avoid buying right back (wash trades)
|
||||
SellPositions(slotPositions,TradeDate);
|
||||
DisplaySales(slotPositions, TradeDate);
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,"********************* S E L L *********************");
|
||||
@@ -535,7 +535,7 @@ namespace MarketData.Generator.MGSHMomentum
|
||||
int positionsToFill = MaxPositions-slotPositions.Count;
|
||||
double cashAllocation = (CashBalance / ((HoldingPeriod * MaxPositions) - ActivePositions.GetCount()))*positionsToFill; // split the cash between the total positions we can own less the number of positions we have
|
||||
MGSHPositions positions = null;
|
||||
positions=BuyPositions(slotIndex, TradeDate,AnalysisDate,cashAllocation,SymbolsHeld(TradeDate), positionsToFill);
|
||||
positions=BuyPositions(slotIndex, TradeDate,AnalysisDate,cashAllocation,new List<String>(SymbolsHeld(TradeDate).Concat(closedSymbols)), positionsToFill);
|
||||
if(CashBalance-positions.Exposure<=0.00)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("********** Insufficient funds to make additional purchases.**************"));
|
||||
|
||||
Reference in New Issue
Block a user