diff --git a/MarketData/MarketData/Models/MGSH20250331.TXT b/MarketData/MarketData/Models/MGSH20250331.TXT index 951ed2e..dd70dcb 100644 --- a/MarketData/MarketData/Models/MGSH20250331.TXT +++ b/MarketData/MarketData/Models/MGSH20250331.TXT @@ -1,10 +1,10 @@ MGSHSESSIONv2.00 -LastUpdated=8/1/2025 10:23:06 PM +LastUpdated=8/4/2025 11:52:37 AM TradeDate=8/4/2025 StartDate=3/31/2025 AnalysisDate=8/1/2025 Cycle=5 -CashBalance=3934.57 +CashBalance=6880.57 NonTradeableCash=0 HedgeCashBalance=9.75 Verbose=True|KeepSlotPositions=True|BenchmarkMode=False|BenchmarkModeSymbol=SPY|HoldingPeriod=3|MaxPositions=3|NoTradeSymbols=OSB,IBDRY,GBTC,YOKU,PNY,RFMD,ASAZY|NoTradeFinancialSymbols=U.S. Private Equity,U.S. Financials,U.S. Financial Services,U.S. Banking and Investment Services,Trading-Miscellaneous,Trading--Miscellaneous,Trading--Leveraged Equity,Trading--Leveraged Debt,Trading--Leveraged Commodities,Trading--Inverse Equity,Trading--Inverse Commodities,Tactical Allocation,Specialty Finance,Japan Financials,Savings & Cooperative Banks,Option Writing,Insurance Brokers,Insurance - Specialty,Insurance - Reinsurance,Insurance - Property & Casualty,Insurance - Life,Insurance - Diversified,Global Private Equity,Global Financials,Financial Services,Financial Exchanges,Financial,China Financials,Banks - Regional - US,Banks - Regional - Latin America,Banks - Global,Asset Management,Credit Services|Benchmark=SPY|MarketCapLowerLimit=1000000000|UsePEScreen=False|UseEBITDAScreen=True|UseRevenuePerShareScreen=True|UseLowSlopeBetaCheck=True|LowSlopeBetaDays=15|LowSlopeBetaThreshhold=1|UseMACD=True|MACDSetup=(12,26,9)|MACDSignalDays=12|MACDRejectStrongSellSignals=False|MACDRejectWeakSellSignals=True|UseStochastics=True|StochasticsSignalDays=3|StochasticsRejectStrongSells=True|StochasticsRejectWeakSells=True|UseFallbackCandidate=True|FallbackCandidate=SHV|FallbackCandidateBestOf=SHV,NEAR,BIL,GSY,AGG,ACWX,GSY,SCHF,IXUS,DBEF,IEFA,TLT|UseMaxPEScreen=True|MaxPE=40|StrictMaxPE=False|QualityIndicatorType=IDINDICATOR|IncludeTradeMasterForSymbolsHeld=True|UseStopLimits=True|StopLimitRiskPercentDecimal=0.2|StopLimitScalingVolatilityDays=30|MinDaysBetweenInitialStopAdjustment=30|MinDaysBetweenStopAdjustments=30|StopLimitPriceTrendDays=20|StopLimitATRMultiplier=3|UseHedging=True|HedgeBenchmarkSymbol=SPY|HedgeShortSymbol=SH|HedgeRiskPercentDecimal=0.12|HedgeMinDaysBetweenStopAdjustments=1|HedgeInitialCash=3000|HedgeCloseAboveSMANDays=10|HedgeBandBreakCheckDays=3|HedgeATRMultiplier=1|MaxPricingExceptions=3|UseBetaGenerator=True|UseBetaGeneratorMonths=24 @@ -16,12 +16,13 @@ Slot=1|Symbol=PSO|PurchaseDate=4/30/2025 12:00:00 AM|SellDate=1/1/0001 12:00:0 Slot=1|Symbol=TSCDY|PurchaseDate=4/30/2025 12:00:00 AM|SellDate=1/1/0001 12:00:00 AM|Shares=75|PurchasePrice=15|CurrentPrice=16.92|Volume=78408|Return1D=0|CumReturn252=0|IDIndicator=-11.1553784860558|Score=1.03524480157762|Velocity=1|PE=12.79|Beta=0.388852470354317|InitialStopLimit=12|TrailingStopLimit=15.951357085704803|LastStopAdjustment=7/30/2025 12:00:00 AM|PositionRiskPercentDecimal=0.2|R=2.996|Comment=Price changed on 5/1/2025 from $14.98 to $15.00 Slot=1|Symbol=CALM|PurchaseDate=7/31/2025 12:00:00 AM|SellDate=1/1/0001 12:00:00 AM|Shares=4|PurchasePrice=110.11|CurrentPrice=107.88|Volume=857309|Return1D=0|CumReturn252=0|IDIndicator=-17.13147410358566|Score=1.0630320928929793|Velocity=0.8662045060658579|PE=5.04|Beta=0.5151822665856635|InitialStopLimit=88.09|TrailingStopLimit=88.09|LastStopAdjustment=1/1/0001 12:00:00 AM|PositionRiskPercentDecimal=0.2|R=22.228|Comment=Price changed on 8/1/2025 from $111.14 to $110.11 Slot=2|Symbol=DBX|PurchaseDate=5/30/2025 12:00:00 AM|SellDate=1/1/0001 12:00:00 AM|Shares=61|PurchasePrice=28.81|CurrentPrice=26.46|Volume=3236382|Return1D=0|CumReturn252=0|IDIndicator=-11.952191235059757|Score=0.8554367778634994|Velocity=0.6487138263665596|PE=19.45|Beta=0.5485758772503743|InitialStopLimit=23.05|TrailingStopLimit=23.05|LastStopAdjustment=1/1/0001 12:00:00 AM|PositionRiskPercentDecimal=0.2|R=5.772|Comment=Price changed on 6/2/2025 from $28.86 to $28.81 -TotalPositions=5 +TotalPositions=6 Symbol=MO|PurchaseDate=3/31/2025 12:00:00 AM|SellDate=5/14/2025 12:00:00 AM|Shares=18|PurchasePrice=59.91|CurrentPrice=56.15|Volume=17335180|Return1D=0|CumReturn252=0|IDIndicator=-15.9362549800797|Score=1.14749269300042|Velocity=0.967136150234742|PE=9|Beta=0.572465642401382|InitialStopLimit=47.93|TrailingStopLimit=56.15650033473968|LastStopAdjustment=5/7/2025 12:00:00 AM|PositionRiskPercentDecimal=0.2|R=12.004|Comment=Closed due to trailing stop. Symbol=EXC|PurchaseDate=3/31/2025 12:00:00 AM|SellDate=5/14/2025 12:00:00 AM|Shares=24|PurchasePrice=45.76|CurrentPrice=42.6|Volume=14993121|Return1D=0|CumReturn252=0|IDIndicator=-8.76494023904382|Score=0.405636492837393|Velocity=1|PE=18.02|Beta=0.248374476251328|InitialStopLimit=36.61|TrailingStopLimit=42.7107857322693|LastStopAdjustment=4/30/2025 12:00:00 AM|PositionRiskPercentDecimal=0.2|R=9.216|Comment=Closed due to trailing stop. Symbol=RGLD|PurchaseDate=4/30/2025 12:00:00 AM|SellDate=7/7/2025 4:16:11 PM|Shares=6|PurchasePrice=179.06|CurrentPrice=162|Volume=872755|Return1D=0|CumReturn252=0|IDIndicator=-12.3505976095618|Score=0.879340632979787|Velocity=0.8398891966759|PE=36.94|Beta=0.672718546494456|InitialStopLimit=143.25|TrailingStopLimit=162.60321449279786|LastStopAdjustment=6/2/2025 12:00:00 AM|PositionRiskPercentDecimal=0.2|R=36.542|Comment=Manual close. Symbol=NRG|PurchaseDate=5/30/2025 12:00:00 AM|SellDate=7/16/2025 8:02:48 PM|Shares=11|PurchasePrice=156.54|CurrentPrice=144.91|Volume=3799318|Return1D=0|CumReturn252=0|IDIndicator=-5.5776892430278835|Score=1.1152297855435784|Velocity=0.9311485909479076|PE=24.22|Beta=1.1133261039922626|InitialStopLimit=125.23|TrailingStopLimit=144.98235696792602|LastStopAdjustment=6/30/2025 12:00:00 AM|PositionRiskPercentDecimal=0.2|R=31.180000000000003|Comment=Manual close. Symbol=OPRA|PurchaseDate=5/30/2025 12:00:00 AM|SellDate=7/16/2025 8:07:28 PM|Shares=97|PurchasePrice=18.31|CurrentPrice=18.02|Volume=415071|Return1D=0|CumReturn252=0|IDIndicator=-4.382470119521905|Score=0.8751364490743774|Velocity=0.6148705096073518|PE=25.43|Beta=2.3432255715230057|InitialStopLimit=14.65|TrailingStopLimit=18.002285492420196|LastStopAdjustment=7/2/2025 12:00:00 AM|PositionRiskPercentDecimal=0.2|R=3.6700000000000004|Comment=Manual close. +Symbol=SH|PurchaseDate=6/27/2025 12:00:00 AM|SellDate=8/4/2025 11:52:29 AM|Shares=75|PurchasePrice=39.71|CurrentPrice=39.28|Volume=0|Return1D=0|CumReturn252=0|IDIndicator=0|Score=0|Velocity=0|PE=0|Beta=0|InitialStopLimit=34.94|TrailingStopLimit=39.29447616100312|LastStopAdjustment=8/1/2025 12:00:00 AM|PositionRiskPercentDecimal=0.12|R=4.7844|Comment=Manual close. TotalStopLimits=13 Symbol=EXC|AnalysisDate=4/30/2025 12:00:00 AM|PreviousStop=36.61|NewStop=42.7107857322693|CurrentPriceLow=42.6|CurrentPriceClose=46.9|PriceTrendIndicatorSlope=0.0870828032493591|StopLimitId=EXC20250331120000AM Symbol=SXT|AnalysisDate=4/30/2025 12:00:00 AM|PreviousStop=59.18|NewStop=85.4177850723267|CurrentPriceLow=92.4|CurrentPriceClose=93.95|PriceTrendIndicatorSlope=0.931879639625549|StopLimitId=SXT20250331120000AM @@ -36,6 +37,5 @@ Symbol=SXT|AnalysisDate=7/7/2025 12:00:00 AM|PreviousStop=88.18778513908386|Ne Symbol=DOLE|AnalysisDate=7/30/2025 12:00:00 AM|PreviousStop=11.14|NewStop=13.686428616046905|CurrentPriceLow=14.51|CurrentPriceClose=14.61|PriceTrendIndicatorSlope=0.021195480599999428|StopLimitId=DOLE20250630120000AM Symbol=TSCDY|AnalysisDate=7/30/2025 12:00:00 AM|PreviousStop=15.663142839670183|NewStop=15.951357085704803|CurrentPriceLow=16.77|CurrentPriceClose=16.83|PriceTrendIndicatorSlope=0.047902267426252365|StopLimitId=TSCDY20250430120000AM Symbol=SH|AnalysisDate=8/1/2025 12:00:00 AM|PreviousStop=34.94|NewStop=39.29447616100312|CurrentPriceLow=39.42|CurrentPriceClose=39.7|PriceTrendIndicatorSlope=0|StopLimitId=SH20250627120000AM -TotalHedgePositions=1 -Symbol=SH|PurchaseDate=6/27/2025 12:00:00 AM|SellDate=1/1/0001 12:00:00 AM|Shares=75|PurchasePrice=39.71|CurrentPrice=39.7|Volume=0|Return1D=0|CumReturn252=0|IDIndicator=0|Score=0|Velocity=0|PE=0|Beta=0|InitialStopLimit=34.94|TrailingStopLimit=39.29447616100312|LastStopAdjustment=8/1/2025 12:00:00 AM|PositionRiskPercentDecimal=0.12|R=4.7844|Comment=Price changed on 6/30/2025 from $39.87 to $39.71 +TotalHedgePositions=0 TotalPricingExceptions=0 diff --git a/MarketData/MarketDataLib/Generator/MGSHMomentum/MGSHBacktest.cs b/MarketData/MarketDataLib/Generator/MGSHMomentum/MGSHBacktest.cs index 920544c..fd7394a 100755 --- a/MarketData/MarketDataLib/Generator/MGSHMomentum/MGSHBacktest.cs +++ b/MarketData/MarketDataLib/Generator/MGSHMomentum/MGSHBacktest.cs @@ -160,7 +160,14 @@ namespace MarketData.Generator.MGSHMomentum MGSHPositions activePositions = ActivePositions.GetPositions(); MGSHPosition position=activePositions.Where(x => x.Symbol.Equals(symbol) && x.PurchaseDate.Equals(purchaseDate)).FirstOrDefault(); - if(null==position) // if it is not in the active positions then the position is already closed and we are modifying either the sell date or the sell price + bool isHedgePosition=false; + if(null==position) // It could be an open hedge position that we are closing + { + MGSHPositions hedgePositions = HedgePositions; + position = hedgePositions.Where(x => x.Symbol.Equals(symbol) && x.PurchaseDate.Equals(purchaseDate)).FirstOrDefault(); + isHedgePosition=true; + } + if(null==position) // if it is not in the active positions or hedge positions then the position is already closed and we are modifying either the sell date or the sell price { position=AllPositions.Where(x => x.Symbol.Equals(symbol)&&x.PurchaseDate.Equals(purchaseDate)).FirstOrDefault(); if(null==position) @@ -179,7 +186,8 @@ namespace MarketData.Generator.MGSHMomentum position.CurrentPrice=price; position.Comment="Manual close."; CashBalance+=position.MarketValue; - ActivePositions.Remove(position); + if(!isHedgePosition)ActivePositions.Remove(position); + else HedgePositions.Remove(position); AllPositions.Add(position); MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Position for symbol '{0}' purchased on {1} is now closed.",symbol,purchaseDate.ToShortDateString())); SaveSession();