using Xunit; using QuantEngine.Core.Domain; namespace QuantEngine.Core.Tests { public class ProfitLockCalculatorTests { [Theory] [InlineData(-5.0, "NORMAL")] [InlineData(5.0, "BREAKEVEN_RATCHET")] [InlineData(15.0, "PROFIT_LOCK_10")] [InlineData(25.0, "PROFIT_LOCK_20")] [InlineData(35.0, "PROFIT_LOCK_30")] [InlineData(45.0, "APEX_TRAILING")] [InlineData(65.0, "APEX_SUPER")] public void ClassifyProfitLockStage_ProfitPcts_ReturnExpectedStage(double profitPct, string expectedStage) { string res = ProfitLockCalculator.ClassifyProfitLockStage(profitPct); Assert.Equal(expectedStage, res); } [Fact] public void ComputeTrailingStop_ApexSuper_AppliesCorrectMultiplierAndTpAction() { var res = ProfitLockCalculator.ComputeTrailingStop( profitPct: 65.0, highestClose: 100000, atr20: 3000, ratchetStop: 90000, averageCost: 80000 ); Assert.Equal("APEX_SUPER", res.RatchetStage); Assert.Equal("강제 10% 익절 권고", res.TpLadderAction); Assert.True(res.ApexSuperActive); // 100000 - 1.2 * 3000 = 100000 - 3600 = 96400 // NormalizeTick(96400) = 96400 (tick = 100) Assert.Equal(96400, res.AutoTrailingStop); } } }