diff --git a/Algorithm.CSharp/InteractiveBrokersBrokerageDisablesIndexOptionsExerciseRegressionAlgorithm.cs b/Algorithm.CSharp/InteractiveBrokersBrokerageDisablesIndexOptionsExerciseRegressionAlgorithm.cs index dda965ef0cee..e077e03eb454 100644 --- a/Algorithm.CSharp/InteractiveBrokersBrokerageDisablesIndexOptionsExerciseRegressionAlgorithm.cs +++ b/Algorithm.CSharp/InteractiveBrokersBrokerageDisablesIndexOptionsExerciseRegressionAlgorithm.cs @@ -81,7 +81,7 @@ public override void OnData(Slice slice) { if (MarketOrder(_contract.Symbol, 1).Status != OrderStatus.Filled) { - throw new Exception("Expected market order to fill immediately"); + throw new RegressionTestException("Expected market order to fill immediately"); } _marketOrderDone = true; @@ -93,7 +93,7 @@ public override void OnData(Slice slice) { if (ExerciseOption(_contract.Symbol, 1).Status == OrderStatus.Filled) { - throw new Exception($"Expected index option to not be exercisable on its expiration date. " + + throw new RegressionTestException($"Expected index option to not be exercisable on its expiration date. " + $"Time: {UtcTime}. Expiry: {_contract.Expiry.ConvertToUtc(_option.Exchange.TimeZone)}"); } @@ -112,7 +112,7 @@ public override void OnOrderEvent(OrderEvent orderEvent) var profit = Portfolio.TotalPortfolioValue - _initialCash; if (profit < 0) { - throw new Exception($"Expected profit to be positive. Actual: {profit}"); + throw new RegressionTestException($"Expected profit to be positive. Actual: {profit}"); } _automaticallyExercised = true; @@ -123,12 +123,12 @@ public override void OnEndOfAlgorithm() { if (!_triedExercise) { - throw new Exception("Expected to try to exercise index option before and on expiry"); + throw new RegressionTestException("Expected to try to exercise index option before and on expiry"); } if (!_automaticallyExercised || Portfolio.Cash <= _initialCash) { - throw new Exception("Expected index option to have ben automatically exercised on expiry and to have received cash"); + throw new RegressionTestException("Expected index option to have ben automatically exercised on expiry and to have received cash"); } } diff --git a/Algorithm.CSharp/InternalSubscriptionHistoryRequestAlgorithm.cs b/Algorithm.CSharp/InternalSubscriptionHistoryRequestAlgorithm.cs index 2b2502dc245d..04165fc8a230 100644 --- a/Algorithm.CSharp/InternalSubscriptionHistoryRequestAlgorithm.cs +++ b/Algorithm.CSharp/InternalSubscriptionHistoryRequestAlgorithm.cs @@ -53,7 +53,7 @@ public override void OnData(Slice data) var history = History(new[] { spy }, TimeSpan.FromDays(10)); if (!history.Any() || !history.All(slice => slice.Bars.All(pair => pair.Value.Period == TimeSpan.FromHours(1)))) { - throw new Exception("Unexpected history result for internal subscription"); + throw new RegressionTestException("Unexpected history result for internal subscription"); } // we add SPY using Daily > default benchmark using hourly @@ -62,7 +62,7 @@ public override void OnData(Slice data) history = History(new[] { spy }, TimeSpan.FromDays(10)); if (!history.Any() || !history.All(slice => slice.Bars.All(pair => pair.Value.Period == TimeSpan.FromDays(1)))) { - throw new Exception("Unexpected history result for user subscription"); + throw new RegressionTestException("Unexpected history result for user subscription"); } } } diff --git a/Algorithm.CSharp/IronCondorStrategyAlgorithm.cs b/Algorithm.CSharp/IronCondorStrategyAlgorithm.cs index a8da5779d2cf..bc924607dc93 100644 --- a/Algorithm.CSharp/IronCondorStrategyAlgorithm.cs +++ b/Algorithm.CSharp/IronCondorStrategyAlgorithm.cs @@ -62,7 +62,7 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup { if (positionGroup.Positions.Count() != 4) { - throw new Exception($"Expected position group to have 4 positions. Actual: {positionGroup.Positions.Count()}"); + throw new RegressionTestException($"Expected position group to have 4 positions. Actual: {positionGroup.Positions.Count()}"); } var orderedStrikes = _ironCondor.OptionLegs.Select(leg => leg.Strike).OrderBy(x => x).ToArray(); @@ -72,7 +72,7 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup .Single(x => x.Symbol.ID.OptionRight == OptionRight.Put && x.Symbol.ID.StrikePrice == longPutStrike); if (longPutPosition.Quantity != 2) { - throw new Exception($"Expected long put position quantity to be 2. Actual: {longPutPosition.Quantity}"); + throw new RegressionTestException($"Expected long put position quantity to be 2. Actual: {longPutPosition.Quantity}"); } var shortPutStrike = orderedStrikes[1]; @@ -80,7 +80,7 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup .Single(x => x.Symbol.ID.OptionRight == OptionRight.Put && x.Symbol.ID.StrikePrice == shortPutStrike); if (shortPutPosition.Quantity != -2) { - throw new Exception($"Expected short put position quantity to be -2. Actual: {shortPutPosition.Quantity}"); + throw new RegressionTestException($"Expected short put position quantity to be -2. Actual: {shortPutPosition.Quantity}"); } var shortCallStrike = orderedStrikes[2]; @@ -88,7 +88,7 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup .Single(x => x.Symbol.ID.OptionRight == OptionRight.Call && x.Symbol.ID.StrikePrice == shortCallStrike); if (shortCallPosition.Quantity != -2) { - throw new Exception($"Expected short call position quantity to be -2. Actual: {shortCallPosition.Quantity}"); + throw new RegressionTestException($"Expected short call position quantity to be -2. Actual: {shortCallPosition.Quantity}"); } var longCallStrike = orderedStrikes[3]; @@ -96,7 +96,7 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup .Single(x => x.Symbol.ID.OptionRight == OptionRight.Call && x.Symbol.ID.StrikePrice == longCallStrike); if (longCallPosition.Quantity != 2) { - throw new Exception($"Expected long call position quantity to be 2. Actual: {longCallPosition.Quantity}"); + throw new RegressionTestException($"Expected long call position quantity to be 2. Actual: {longCallPosition.Quantity}"); } } diff --git a/Algorithm.CSharp/IsMarketOpenCheckAlgorithm.cs b/Algorithm.CSharp/IsMarketOpenCheckAlgorithm.cs index 4bfe03bc6383..7d84208e6d18 100644 --- a/Algorithm.CSharp/IsMarketOpenCheckAlgorithm.cs +++ b/Algorithm.CSharp/IsMarketOpenCheckAlgorithm.cs @@ -43,7 +43,7 @@ protected void AssertIsMarketOpen(bool expected) Log($"IsMarketOpen at {Time}?: {isMarketOpen}"); if (isMarketOpen != expected) { - throw new Exception($"Expected IsMarketOpen to be {expected} at {Time}."); + throw new RegressionTestException($"Expected IsMarketOpen to be {expected} at {Time}."); } } diff --git a/Algorithm.CSharp/LargeQuantityOptionStrategyAlgorithm.cs b/Algorithm.CSharp/LargeQuantityOptionStrategyAlgorithm.cs index 592854d7a1c0..c39c403b8883 100644 --- a/Algorithm.CSharp/LargeQuantityOptionStrategyAlgorithm.cs +++ b/Algorithm.CSharp/LargeQuantityOptionStrategyAlgorithm.cs @@ -89,7 +89,7 @@ public override void OnEndOfAlgorithm() if (filledOrders.Count != 2) { - throw new Exception($"Expected 2 filled orders but found {filledOrders.Count}"); + throw new RegressionTestException($"Expected 2 filled orders but found {filledOrders.Count}"); } } diff --git a/Algorithm.CSharp/LeveragePrecedenceRegressionAlgorithm.cs b/Algorithm.CSharp/LeveragePrecedenceRegressionAlgorithm.cs index db9abdc34986..4cbf654a8dbe 100644 --- a/Algorithm.CSharp/LeveragePrecedenceRegressionAlgorithm.cs +++ b/Algorithm.CSharp/LeveragePrecedenceRegressionAlgorithm.cs @@ -63,7 +63,7 @@ public override void OnData(Slice data) if (Securities[_spy].Leverage != 10) { - throw new Exception($"Expecting leverage to be 10, was {Securities[_spy].Leverage}"); + throw new RegressionTestException($"Expecting leverage to be 10, was {Securities[_spy].Leverage}"); } } diff --git a/Algorithm.CSharp/LimitIfTouchedRegressionAlgorithm.cs b/Algorithm.CSharp/LimitIfTouchedRegressionAlgorithm.cs index 06528b622f56..fb8532741d36 100644 --- a/Algorithm.CSharp/LimitIfTouchedRegressionAlgorithm.cs +++ b/Algorithm.CSharp/LimitIfTouchedRegressionAlgorithm.cs @@ -105,7 +105,7 @@ public override void OnOrderEvent(OrderEvent orderEvent) if (orderEvent.ToString() != expected) { - throw new Exception($"orderEvent {orderEvent.Id} differed from {expected}. Actual {orderEvent}"); + throw new RegressionTestException($"orderEvent {orderEvent.Id} differed from {expected}. Actual {orderEvent}"); } } } diff --git a/Algorithm.CSharp/LimitOrdersAreFilledAfterHoursForFuturesRegressionAlgorithm.cs b/Algorithm.CSharp/LimitOrdersAreFilledAfterHoursForFuturesRegressionAlgorithm.cs index 6034026065de..a9a38c537fdb 100644 --- a/Algorithm.CSharp/LimitOrdersAreFilledAfterHoursForFuturesRegressionAlgorithm.cs +++ b/Algorithm.CSharp/LimitOrdersAreFilledAfterHoursForFuturesRegressionAlgorithm.cs @@ -56,14 +56,14 @@ public override void OnWarmupFinished() // Right after warm up we should be outside regular market hours if (_futureContract.Exchange.ExchangeOpen) { - throw new Exception("We should be outside regular market hours"); + throw new RegressionTestException("We should be outside regular market hours"); } // Market on open order should not be allowed for futures outside of regular market hours var futureContractMarketOnOpenOrder = MarketOnOpenOrder(_futureContract.Symbol, 1); if (futureContractMarketOnOpenOrder.Status != OrderStatus.Invalid) { - throw new Exception($"Market on open order should not be allowed for futures outside of regular market hours"); + throw new RegressionTestException($"Market on open order should not be allowed for futures outside of regular market hours"); } } @@ -77,7 +77,7 @@ public override void OnData(Slice slice) var continuousContractLimitOrder = LimitOrder(_continuousContract.Mapped, 1, _continuousContract.Price * 2m); if (futureContractLimitOrder.Status == OrderStatus.Invalid || continuousContractLimitOrder.Status == OrderStatus.Invalid) { - throw new Exception($"Limit order should be allowed for futures outside of regular market hours"); + throw new RegressionTestException($"Limit order should be allowed for futures outside of regular market hours"); } } } @@ -86,7 +86,7 @@ public override void OnEndOfAlgorithm() { if (Transactions.GetOrders().Any(order => order.Status != OrderStatus.Filled )) { - throw new Exception("Not all orders were filled"); + throw new RegressionTestException("Not all orders were filled"); } } @@ -96,7 +96,7 @@ public override void OnOrderEvent(OrderEvent orderEvent) if (orderEvent.Status == OrderStatus.Filled && !Securities[orderEvent.Symbol].Exchange.DateTimeIsOpen(orderEvent.UtcTime) && (orderEvent.UtcTime.TimeOfDay >= new TimeSpan(13, 30, 0) && orderEvent.UtcTime.TimeOfDay < new TimeSpan(21, 0, 0))) { - throw new Exception($"Order should have been filled during extended market hours"); + throw new RegressionTestException($"Order should have been filled during extended market hours"); } } diff --git a/Algorithm.CSharp/LiquidatingMultipleOptionStrategiesRegressionAlgorithm.cs b/Algorithm.CSharp/LiquidatingMultipleOptionStrategiesRegressionAlgorithm.cs index 0551d58fcaba..fe3245353315 100644 --- a/Algorithm.CSharp/LiquidatingMultipleOptionStrategiesRegressionAlgorithm.cs +++ b/Algorithm.CSharp/LiquidatingMultipleOptionStrategiesRegressionAlgorithm.cs @@ -95,7 +95,7 @@ public override void OnData(Slice slice) var positionGroups = Portfolio.Positions.Groups; if (positionGroups.Count != 2) { - throw new Exception($"Expected 2 position groups, one for each spread, but found {positionGroups.Count}"); + throw new RegressionTestException($"Expected 2 position groups, one for each spread, but found {positionGroups.Count}"); } var positionGroupMatchesSpreadStrategy = (IPositionGroup positionGroup, OptionStrategy strategy) => @@ -110,7 +110,7 @@ public override void OnData(Slice slice) if (!positionGroups.All(group => positionGroupMatchesSpreadStrategy(group, _bullCallSpread) || positionGroupMatchesSpreadStrategy(group, _bearPutSpread))) { - throw new Exception("Expected both spreads to have a matching position group in the portfolio."); + throw new RegressionTestException("Expected both spreads to have a matching position group in the portfolio."); } // Step 2: liquidate spreads @@ -125,12 +125,12 @@ public override void OnEndOfAlgorithm() { if (!_done) { - throw new Exception("Expected the algorithm to have bought and sold a Bull Call Spread and a Bear Put Spread."); + throw new RegressionTestException("Expected the algorithm to have bought and sold a Bull Call Spread and a Bear Put Spread."); } if (Portfolio.Invested) { - throw new Exception("The spreads should have been liquidated by the end of the algorithm"); + throw new RegressionTestException("The spreads should have been liquidated by the end of the algorithm"); } } diff --git a/Algorithm.CSharp/LongAndShortButterflyCallStrategiesAlgorithm.cs b/Algorithm.CSharp/LongAndShortButterflyCallStrategiesAlgorithm.cs index 00401958f064..5b25c5164be3 100644 --- a/Algorithm.CSharp/LongAndShortButterflyCallStrategiesAlgorithm.cs +++ b/Algorithm.CSharp/LongAndShortButterflyCallStrategiesAlgorithm.cs @@ -69,7 +69,7 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup { if (positionGroup.Positions.Count() != 3) { - throw new Exception($"Expected position group to have 3 positions. Actual: {positionGroup.Positions.Count()}"); + throw new RegressionTestException($"Expected position group to have 3 positions. Actual: {positionGroup.Positions.Count()}"); } var higherStrike = _butterflyCall.OptionLegs.Max(leg => leg.Strike); @@ -78,7 +78,7 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup if (higherStrikePosition.Quantity != 2) { - throw new Exception($"Expected higher strike position quantity to be 2. Actual: {higherStrikePosition.Quantity}"); + throw new RegressionTestException($"Expected higher strike position quantity to be 2. Actual: {higherStrikePosition.Quantity}"); } var lowerStrike = _butterflyCall.OptionLegs.Min(leg => leg.Strike); @@ -87,7 +87,7 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup if (lowerStrikePosition.Quantity != 2) { - throw new Exception($"Expected lower strike position quantity to be 2. Actual: {lowerStrikePosition.Quantity}"); + throw new RegressionTestException($"Expected lower strike position quantity to be 2. Actual: {lowerStrikePosition.Quantity}"); } var middleStrike = _butterflyCall.OptionLegs.Single(leg => leg.Strike < higherStrike && leg.Strike > lowerStrike).Strike; @@ -96,7 +96,7 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup if (middleStrikePosition.Quantity != -4) { - throw new Exception($"Expected middle strike position quantity to be -4. Actual: {middleStrikePosition.Quantity}"); + throw new RegressionTestException($"Expected middle strike position quantity to be -4. Actual: {middleStrikePosition.Quantity}"); } } diff --git a/Algorithm.CSharp/LongAndShortButterflyPutStrategiesAlgorithm.cs b/Algorithm.CSharp/LongAndShortButterflyPutStrategiesAlgorithm.cs index af8395638fb8..bfaa210f9bba 100644 --- a/Algorithm.CSharp/LongAndShortButterflyPutStrategiesAlgorithm.cs +++ b/Algorithm.CSharp/LongAndShortButterflyPutStrategiesAlgorithm.cs @@ -69,7 +69,7 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup { if (positionGroup.Positions.Count() != 3) { - throw new Exception($"Expected position group to have 3 positions. Actual: {positionGroup.Positions.Count()}"); + throw new RegressionTestException($"Expected position group to have 3 positions. Actual: {positionGroup.Positions.Count()}"); } var higherStrike = _butterflyPut.OptionLegs.Max(leg => leg.Strike); @@ -78,7 +78,7 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup if (higherStrikePosition.Quantity != 2) { - throw new Exception($"Expected higher strike position quantity to be 2. Actual: {higherStrikePosition.Quantity}"); + throw new RegressionTestException($"Expected higher strike position quantity to be 2. Actual: {higherStrikePosition.Quantity}"); } var lowerStrike = _butterflyPut.OptionLegs.Min(leg => leg.Strike); @@ -87,7 +87,7 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup if (lowerStrikePosition.Quantity != 2) { - throw new Exception($"Expected lower strike position quantity to be 2. Actual: {lowerStrikePosition.Quantity}"); + throw new RegressionTestException($"Expected lower strike position quantity to be 2. Actual: {lowerStrikePosition.Quantity}"); } var middleStrike = _butterflyPut.OptionLegs.Single(leg => leg.Strike < higherStrike && leg.Strike > lowerStrike).Strike; @@ -96,7 +96,7 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup if (middleStrikePosition.Quantity != -4) { - throw new Exception($"Expected middle strike position quantity to be -4. Actual: {middleStrikePosition.Quantity}"); + throw new RegressionTestException($"Expected middle strike position quantity to be -4. Actual: {middleStrikePosition.Quantity}"); } } diff --git a/Algorithm.CSharp/LongAndShortCallCalendarSpreadStrategiesAlgorithm.cs b/Algorithm.CSharp/LongAndShortCallCalendarSpreadStrategiesAlgorithm.cs index c909113bbb1b..48dda1a5c20e 100644 --- a/Algorithm.CSharp/LongAndShortCallCalendarSpreadStrategiesAlgorithm.cs +++ b/Algorithm.CSharp/LongAndShortCallCalendarSpreadStrategiesAlgorithm.cs @@ -61,7 +61,7 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup { if (positionGroup.Positions.Count() != 2) { - throw new Exception($"Expected position group to have 2 positions. Actual: {positionGroup.Positions.Count()}"); + throw new RegressionTestException($"Expected position group to have 2 positions. Actual: {positionGroup.Positions.Count()}"); } var nearExpiration = _callCalendarSpread.OptionLegs.Min(leg => leg.Expiration); @@ -70,7 +70,7 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup if (nearExpirationPosition.Quantity != -2) { - throw new Exception($"Expected near expiration position quantity to be -2. Actual: {nearExpirationPosition.Quantity}"); + throw new RegressionTestException($"Expected near expiration position quantity to be -2. Actual: {nearExpirationPosition.Quantity}"); } var farExpiration = _callCalendarSpread.OptionLegs.Max(leg => leg.Expiration); @@ -79,7 +79,7 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup if (farExpirationPosition.Quantity != 2) { - throw new Exception($"Expected far expiration position quantity to be 2. Actual: {farExpirationPosition.Quantity}"); + throw new RegressionTestException($"Expected far expiration position quantity to be 2. Actual: {farExpirationPosition.Quantity}"); } } diff --git a/Algorithm.CSharp/LongAndShortPutCalendarSpreadStrategiesAlgorithm.cs b/Algorithm.CSharp/LongAndShortPutCalendarSpreadStrategiesAlgorithm.cs index 0f0f6a5b6b0c..bb53ded1ffbe 100644 --- a/Algorithm.CSharp/LongAndShortPutCalendarSpreadStrategiesAlgorithm.cs +++ b/Algorithm.CSharp/LongAndShortPutCalendarSpreadStrategiesAlgorithm.cs @@ -61,7 +61,7 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup { if (positionGroup.Positions.Count() != 2) { - throw new Exception($"Expected position group to have 2 positions. Actual: {positionGroup.Positions.Count()}"); + throw new RegressionTestException($"Expected position group to have 2 positions. Actual: {positionGroup.Positions.Count()}"); } var nearExpiration = _putCalendarSpread.OptionLegs.Min(leg => leg.Expiration); @@ -70,7 +70,7 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup if (nearExpirationPosition.Quantity != -2) { - throw new Exception($"Expected near expiration position quantity to be -2. Actual: {nearExpirationPosition.Quantity}"); + throw new RegressionTestException($"Expected near expiration position quantity to be -2. Actual: {nearExpirationPosition.Quantity}"); } var farExpiration = _putCalendarSpread.OptionLegs.Max(leg => leg.Expiration); @@ -79,7 +79,7 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup if (farExpirationPosition.Quantity != 2) { - throw new Exception($"Expected far expiration position quantity to be 2. Actual: {farExpirationPosition.Quantity}"); + throw new RegressionTestException($"Expected far expiration position quantity to be 2. Actual: {farExpirationPosition.Quantity}"); } } diff --git a/Algorithm.CSharp/LongAndShortStraddleStrategiesAlgorithm.cs b/Algorithm.CSharp/LongAndShortStraddleStrategiesAlgorithm.cs index f35b9c718f4b..789193a97b9a 100644 --- a/Algorithm.CSharp/LongAndShortStraddleStrategiesAlgorithm.cs +++ b/Algorithm.CSharp/LongAndShortStraddleStrategiesAlgorithm.cs @@ -60,7 +60,7 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup { if (positionGroup.Positions.Count() != 2) { - throw new Exception($"Expected position group to have 2 positions. Actual: {positionGroup.Positions.Count()}"); + throw new RegressionTestException($"Expected position group to have 2 positions. Actual: {positionGroup.Positions.Count()}"); } var callPosition = positionGroup.Positions.Single(x => x.Symbol.ID.OptionRight == OptionRight.Call); @@ -71,12 +71,12 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup if (callPosition.Quantity != expectedCallPositionQuantity) { - throw new Exception($@"Expected call position quantity to be {expectedCallPositionQuantity}. Actual: {callPosition.Quantity}"); + throw new RegressionTestException($@"Expected call position quantity to be {expectedCallPositionQuantity}. Actual: {callPosition.Quantity}"); } if (putPosition.Quantity != expectedPutPositionQuantity) { - throw new Exception($@"Expected put position quantity to be {expectedPutPositionQuantity}. Actual: {putPosition.Quantity}"); + throw new RegressionTestException($@"Expected put position quantity to be {expectedPutPositionQuantity}. Actual: {putPosition.Quantity}"); } } diff --git a/Algorithm.CSharp/LongAndShortStrangleStrategiesAlgorithm.cs b/Algorithm.CSharp/LongAndShortStrangleStrategiesAlgorithm.cs index c9829dbd46f9..3481531d2ba6 100644 --- a/Algorithm.CSharp/LongAndShortStrangleStrategiesAlgorithm.cs +++ b/Algorithm.CSharp/LongAndShortStrangleStrategiesAlgorithm.cs @@ -70,7 +70,7 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup { if (positionGroup.Positions.Count() != 2) { - throw new Exception($"Expected position group to have 2 positions. Actual: {positionGroup.Positions.Count()}"); + throw new RegressionTestException($"Expected position group to have 2 positions. Actual: {positionGroup.Positions.Count()}"); } var callPosition = positionGroup.Positions.Single(x => x.Symbol.ID.OptionRight == OptionRight.Call); @@ -81,12 +81,12 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup if (callPosition.Quantity != expectedCallPositionQuantity) { - throw new Exception($@"Expected call position quantity to be {expectedCallPositionQuantity}. Actual: {callPosition.Quantity}"); + throw new RegressionTestException($@"Expected call position quantity to be {expectedCallPositionQuantity}. Actual: {callPosition.Quantity}"); } if (putPosition.Quantity != expectedPutPositionQuantity) { - throw new Exception($@"Expected put position quantity to be {expectedPutPositionQuantity}. Actual: {putPosition.Quantity}"); + throw new RegressionTestException($@"Expected put position quantity to be {expectedPutPositionQuantity}. Actual: {putPosition.Quantity}"); } } diff --git a/Algorithm.CSharp/LongOnlyAlphaStreamAlgorithm.cs b/Algorithm.CSharp/LongOnlyAlphaStreamAlgorithm.cs index 319b8b1ab8c3..55b0c7b006b2 100644 --- a/Algorithm.CSharp/LongOnlyAlphaStreamAlgorithm.cs +++ b/Algorithm.CSharp/LongOnlyAlphaStreamAlgorithm.cs @@ -81,7 +81,7 @@ public override void OnOrderEvent(OrderEvent orderEvent) { if (Securities[orderEvent.Symbol].Holdings.IsShort) { - throw new Exception("Invalid position, should not be short"); + throw new RegressionTestException("Invalid position, should not be short"); } Debug($"Purchased Stock: {orderEvent}"); } diff --git a/Algorithm.CSharp/MacdAlphaModelFrameworkRegressionAlgorithm.cs b/Algorithm.CSharp/MacdAlphaModelFrameworkRegressionAlgorithm.cs index 8e3da54fa3e7..9a4adc2b90f4 100644 --- a/Algorithm.CSharp/MacdAlphaModelFrameworkRegressionAlgorithm.cs +++ b/Algorithm.CSharp/MacdAlphaModelFrameworkRegressionAlgorithm.cs @@ -35,7 +35,7 @@ public override void OnEndOfAlgorithm() const int expected = 4; if (Insights.TotalCount != expected) { - throw new Exception($"The total number of insights should be {expected}. Actual: {Insights.TotalCount}"); + throw new RegressionTestException($"The total number of insights should be {expected}. Actual: {Insights.TotalCount}"); } } diff --git a/Algorithm.CSharp/ManuallySetMarketHoursAndSymbolPropertiesDatabaseEntriesAlgorithm.cs b/Algorithm.CSharp/ManuallySetMarketHoursAndSymbolPropertiesDatabaseEntriesAlgorithm.cs index d64edab84369..36dd2f40e55f 100644 --- a/Algorithm.CSharp/ManuallySetMarketHoursAndSymbolPropertiesDatabaseEntriesAlgorithm.cs +++ b/Algorithm.CSharp/ManuallySetMarketHoursAndSymbolPropertiesDatabaseEntriesAlgorithm.cs @@ -51,12 +51,12 @@ public override void Initialize() if (!ReferenceEquals(spyCfd.Exchange.Hours, equityMarketHoursEntry.ExchangeHours)) { - throw new Exception("Expected the SPY CFD market hours to be the same as the underlying equity market hours."); + throw new RegressionTestException("Expected the SPY CFD market hours to be the same as the underlying equity market hours."); } if (!ReferenceEquals(spyCfd.SymbolProperties, equitySymbolProperties)) { - throw new Exception("Expected the SPY CFD symbol properties to be the same as the underlying equity symbol properties."); + throw new RegressionTestException("Expected the SPY CFD symbol properties to be the same as the underlying equity symbol properties."); } // We can also do it for a specific ticker: @@ -71,12 +71,12 @@ public override void Initialize() if (!ReferenceEquals(audUsdCfd.Exchange.Hours, audUsdForexMarketHoursEntry.ExchangeHours)) { - throw new Exception("Expected the AUDUSD CFD market hours to be the same as the underlying forex market hours."); + throw new RegressionTestException("Expected the AUDUSD CFD market hours to be the same as the underlying forex market hours."); } if (!ReferenceEquals(audUsdCfd.SymbolProperties, audUsdForexSymbolProperties)) { - throw new Exception("Expected the AUDUSD CFD symbol properties to be the same as the underlying forex symbol properties."); + throw new RegressionTestException("Expected the AUDUSD CFD symbol properties to be the same as the underlying forex symbol properties."); } } diff --git a/Algorithm.CSharp/MarginCallClosedMarketRegressionAlgorithm.cs b/Algorithm.CSharp/MarginCallClosedMarketRegressionAlgorithm.cs index 3b60e30d6751..5aae6353c2e2 100644 --- a/Algorithm.CSharp/MarginCallClosedMarketRegressionAlgorithm.cs +++ b/Algorithm.CSharp/MarginCallClosedMarketRegressionAlgorithm.cs @@ -81,13 +81,13 @@ public override void OnMarginCall(List requests) // leave a 1% margin for are expected calculations if (Math.Abs(expectedFinalQuantity - actualFinalQuantity) > (quantityHold * 0.01m)) { - throw new Exception($"Expected {expectedFinalQuantity} final quantity but was {actualFinalQuantity}"); + throw new RegressionTestException($"Expected {expectedFinalQuantity} final quantity but was {actualFinalQuantity}"); } if (!Securities[_spy].Exchange.ExchangeOpen || !Securities[_spy].Exchange.ClosingSoon) { - throw new Exception($"Expected exchange to be open: {Securities[_spy].Exchange.ExchangeOpen} and to be closing soon: {Securities[_spy].Exchange.ClosingSoon}"); + throw new RegressionTestException($"Expected exchange to be open: {Securities[_spy].Exchange.ExchangeOpen} and to be closing soon: {Securities[_spy].Exchange.ClosingSoon}"); } } } @@ -96,7 +96,7 @@ public override void OnEndOfAlgorithm() { if (_marginCall != 1) { - throw new Exception($"We expected a single margin call to happen, {_marginCall} occurred"); + throw new RegressionTestException($"We expected a single margin call to happen, {_marginCall} occurred"); } } diff --git a/Algorithm.CSharp/MarginRemainingRegressionAlgorithm.cs b/Algorithm.CSharp/MarginRemainingRegressionAlgorithm.cs index 4c112592f4e8..044b2a9077e4 100644 --- a/Algorithm.CSharp/MarginRemainingRegressionAlgorithm.cs +++ b/Algorithm.CSharp/MarginRemainingRegressionAlgorithm.cs @@ -58,7 +58,7 @@ public override void OnData(Slice data) if (Portfolio.MarginRemaining <= 0) { - throw new Exception($"Unexpected margin remaining value {Portfolio.MarginRemaining}"); + throw new RegressionTestException($"Unexpected margin remaining value {Portfolio.MarginRemaining}"); } // in the 2009 dip buy AAPL diff --git a/Algorithm.CSharp/MarketOnCloseOrderBufferCheckRegressionAlgorithm.cs b/Algorithm.CSharp/MarketOnCloseOrderBufferCheckRegressionAlgorithm.cs index ebf608388138..3075b990a2c0 100644 --- a/Algorithm.CSharp/MarketOnCloseOrderBufferCheckRegressionAlgorithm.cs +++ b/Algorithm.CSharp/MarketOnCloseOrderBufferCheckRegressionAlgorithm.cs @@ -67,7 +67,7 @@ public override void OnData(Slice slice) if (_validOrderTicket.Status == OrderStatus.Invalid) { - throw new Exception("MOC order placed at the last minute was expected to be valid."); + throw new RegressionTestException("MOC order placed at the last minute was expected to be valid."); } } @@ -79,7 +79,7 @@ public override void OnData(Slice slice) if (_invalidOrderTicket.Status != OrderStatus.Invalid || _invalidOrderTicket.SubmitRequest.Response.ErrorCode != OrderResponseErrorCode.MarketOnCloseOrderTooLate) { - throw new Exception( + throw new RegressionTestException( "MOC order placed after the latest allowed submission time was not rejected or the reason was not the submission time"); } } @@ -92,18 +92,18 @@ public override void OnEndOfAlgorithm() if (_validOrderTicket == null) { - throw new Exception("Valid MOC order was not placed"); + throw new RegressionTestException("Valid MOC order was not placed"); } // Verify that our good order filled if (_validOrderTicket.Status != OrderStatus.Filled) { - throw new Exception("MOC order failed to fill"); + throw new RegressionTestException("MOC order failed to fill"); } if (_invalidOrderTicket == null) { - throw new Exception("Invalid MOC order was not placed"); + throw new RegressionTestException("Invalid MOC order was not placed"); } } diff --git a/Algorithm.CSharp/MarketOnCloseOrderBufferExtendedMarketHoursRegressionAlgorithm.cs b/Algorithm.CSharp/MarketOnCloseOrderBufferExtendedMarketHoursRegressionAlgorithm.cs index 61c8073adf93..657a57b0b645 100644 --- a/Algorithm.CSharp/MarketOnCloseOrderBufferExtendedMarketHoursRegressionAlgorithm.cs +++ b/Algorithm.CSharp/MarketOnCloseOrderBufferExtendedMarketHoursRegressionAlgorithm.cs @@ -82,25 +82,25 @@ public override void OnEndOfAlgorithm() // Verify that our good order filled if (_validOrderTicket.Status != OrderStatus.Filled) { - throw new Exception("Valid order failed to fill"); + throw new RegressionTestException("Valid order failed to fill"); } // Verify our order was marked invalid if (_invalidOrderTicket.Status != OrderStatus.Invalid) { - throw new Exception("Invalid order was not rejected"); + throw new RegressionTestException("Invalid order was not rejected"); } // Verify that our second good order filled if (_validOrderTicketExtendedMarketHours.Status != OrderStatus.Filled) { - throw new Exception("Valid order during extended market hours failed to fill"); + throw new RegressionTestException("Valid order during extended market hours failed to fill"); } // Verify that our third good order filled if (_validOrderTicketAtMidnight.Status != OrderStatus.Filled) { - throw new Exception("Valid order at midnight failed to fill"); + throw new RegressionTestException("Valid order at midnight failed to fill"); } } diff --git a/Algorithm.CSharp/MarketOnCloseOrderBufferRegressionAlgorithm.cs b/Algorithm.CSharp/MarketOnCloseOrderBufferRegressionAlgorithm.cs index cbabde5aa3ba..020056b2df4f 100644 --- a/Algorithm.CSharp/MarketOnCloseOrderBufferRegressionAlgorithm.cs +++ b/Algorithm.CSharp/MarketOnCloseOrderBufferRegressionAlgorithm.cs @@ -71,19 +71,19 @@ public override void OnEndOfAlgorithm() // Verify that our good order filled if (_validOrderTicket.Status != OrderStatus.Filled) { - throw new Exception("Valid order failed to fill"); + throw new RegressionTestException("Valid order failed to fill"); } // Verify our order was marked invalid if (_invalidOrderTicket.Status != OrderStatus.Invalid) { - throw new Exception("Invalid order was not rejected"); + throw new RegressionTestException("Invalid order was not rejected"); } // Verify that our second good order filled if (_validOrderTicketExtendedMarketHours.Status != OrderStatus.Filled) { - throw new Exception("Valid order during extended market hours failed to fill"); + throw new RegressionTestException("Valid order during extended market hours failed to fill"); } } diff --git a/Algorithm.CSharp/MarketOnCloseOrderFillsOnCloseTradeWithTickResolutionAlgorithm.cs b/Algorithm.CSharp/MarketOnCloseOrderFillsOnCloseTradeWithTickResolutionAlgorithm.cs index 8f2b375165df..30198f3bea92 100644 --- a/Algorithm.CSharp/MarketOnCloseOrderFillsOnCloseTradeWithTickResolutionAlgorithm.cs +++ b/Algorithm.CSharp/MarketOnCloseOrderFillsOnCloseTradeWithTickResolutionAlgorithm.cs @@ -50,19 +50,19 @@ public override void OnOrderEvent(OrderEvent orderEvent) if (orderEvent.Message != "") { - throw new Exception($"OrderEvent.Message should be empty, but is '{orderEvent.Message}'"); + throw new RegressionTestException($"OrderEvent.Message should be empty, but is '{orderEvent.Message}'"); } var order = Transactions.GetOrderById(orderEvent.OrderId); if (order.Tag != "") { - throw new Exception($"Order.Tag should be empty, but is '{order.Tag}'"); + throw new RegressionTestException($"Order.Tag should be empty, but is '{order.Tag}'"); } var expectedFillPrice = orderEvent.UtcTime.Date == StartDate.Date ? 167.42m : 165.48m; if (orderEvent.FillPrice != expectedFillPrice) { - throw new Exception( + throw new RegressionTestException( $"Expected {orderEvent.UtcTime.Date} order fill price to be {expectedFillPrice} but was {orderEvent.FillPrice}"); } } @@ -76,12 +76,12 @@ public override void OnEndOfAlgorithm() var expectedOrdersCount = 2; if (orders.Count != expectedOrdersCount) { - throw new Exception($"Expected {expectedOrdersCount} orders, but found {orders.Count}"); + throw new RegressionTestException($"Expected {expectedOrdersCount} orders, but found {orders.Count}"); } if (orders.Any(x => x.Status != OrderStatus.Filled)) { - throw new Exception( + throw new RegressionTestException( $"Expected all orders to be filled, but found {orders.Count(x => x.Status != OrderStatus.Filled)} unfilled orders"); } } diff --git a/Algorithm.CSharp/MarketOnOpenOrderFillsOnOpenTradeWithTickResolutionAlgorithm.cs b/Algorithm.CSharp/MarketOnOpenOrderFillsOnOpenTradeWithTickResolutionAlgorithm.cs index cc741440efa1..9d801a2b7403 100644 --- a/Algorithm.CSharp/MarketOnOpenOrderFillsOnOpenTradeWithTickResolutionAlgorithm.cs +++ b/Algorithm.CSharp/MarketOnOpenOrderFillsOnOpenTradeWithTickResolutionAlgorithm.cs @@ -50,19 +50,19 @@ public override void OnOrderEvent(OrderEvent orderEvent) if (orderEvent.Message != "") { - throw new Exception($"OrderEvent.Message should be empty, but is '{orderEvent.Message}'"); + throw new RegressionTestException($"OrderEvent.Message should be empty, but is '{orderEvent.Message}'"); } var order = Transactions.GetOrderById(orderEvent.OrderId); if (order.Tag != "") { - throw new Exception($"Order.Tag should be empty, but is '{order.Tag}'"); + throw new RegressionTestException($"Order.Tag should be empty, but is '{order.Tag}'"); } var expectedFillPrice = orderEvent.UtcTime.Date == StartDate.Date ? 167.43m : 167.45m; if (orderEvent.FillPrice != expectedFillPrice) { - throw new Exception( + throw new RegressionTestException( $"Expected {orderEvent.UtcTime.Date} order fill price to be {expectedFillPrice} but was {orderEvent.FillPrice}"); } } @@ -76,12 +76,12 @@ public override void OnEndOfAlgorithm() var expectedOrdersCount = 2; if (orders.Count != expectedOrdersCount) { - throw new Exception($"Expected {expectedOrdersCount} orders, but found {orders.Count}"); + throw new RegressionTestException($"Expected {expectedOrdersCount} orders, but found {orders.Count}"); } if (orders.Any(x => x.Status != OrderStatus.Filled)) { - throw new Exception( + throw new RegressionTestException( $"Expected all orders to be filled, but found {orders.Count(x => x.Status != OrderStatus.Filled)} unfilled orders"); } } diff --git a/Algorithm.CSharp/MarketOrdersAreSupportedOnExtendedHoursForFuturesRegressionAlgorithm.cs b/Algorithm.CSharp/MarketOrdersAreSupportedOnExtendedHoursForFuturesRegressionAlgorithm.cs index afb4edde5662..3842260ae193 100644 --- a/Algorithm.CSharp/MarketOrdersAreSupportedOnExtendedHoursForFuturesRegressionAlgorithm.cs +++ b/Algorithm.CSharp/MarketOrdersAreSupportedOnExtendedHoursForFuturesRegressionAlgorithm.cs @@ -54,7 +54,7 @@ public override void OnData(Slice slice) var continuousContractMarketOrder = MarketOrder(_continuousContract.Mapped, 1); if (futureContractMarketOrder.Status == OrderStatus.Invalid || continuousContractMarketOrder.Status == OrderStatus.Invalid) { - throw new Exception($"Market orders should be allowed for futures outside of regular market hours"); + throw new RegressionTestException($"Market orders should be allowed for futures outside of regular market hours"); } } } @@ -63,7 +63,7 @@ public override void OnEndOfAlgorithm() { if (Transactions.GetOrders().Any(order => order.Status != OrderStatus.Filled )) { - throw new Exception("Not all orders were filled"); + throw new RegressionTestException("Not all orders were filled"); } } @@ -73,7 +73,7 @@ public override void OnOrderEvent(OrderEvent orderEvent) if (orderEvent.Status == OrderStatus.Filled && !Securities[orderEvent.Symbol].Exchange.DateTimeIsOpen(orderEvent.UtcTime) && (orderEvent.UtcTime.TimeOfDay >= new TimeSpan(13, 30, 0) && orderEvent.UtcTime.TimeOfDay < new TimeSpan(21, 0, 0))) { - throw new Exception($"Order should have been filled during extended market hours"); + throw new RegressionTestException($"Order should have been filled during extended market hours"); } } diff --git a/Algorithm.CSharp/MinimumOrderSizeRegressionAlgorithm.cs b/Algorithm.CSharp/MinimumOrderSizeRegressionAlgorithm.cs index 9be80a392315..8c04f54d8063 100644 --- a/Algorithm.CSharp/MinimumOrderSizeRegressionAlgorithm.cs +++ b/Algorithm.CSharp/MinimumOrderSizeRegressionAlgorithm.cs @@ -46,7 +46,7 @@ public override void OnData(Slice slice) var invalidOrder = MarketOrder("BTCUSD", 0.00002); if (invalidOrder.Status != OrderStatus.Invalid) { - throw new Exception("Invalid order expected, order size is less than allowed"); + throw new RegressionTestException("Invalid order expected, order size is less than allowed"); } // Update an order that fails because of the size @@ -74,13 +74,13 @@ public override void OnOrderEvent(OrderEvent orderEvent) // Update of validOrderOne is expected to fail if( (order.Id == 2) && (order.LastUpdateTime != null) && (order.Tag == "Updated")) { - throw new Exception("Order update expected to fail"); + throw new RegressionTestException("Order update expected to fail"); } // Update of validOrdertwo is expected to succeed if ((order.Id == 3) && (order.LastUpdateTime != null) && (order.Tag == "NotUpdated")) { - throw new Exception("Order update expected to succeed"); + throw new RegressionTestException("Order update expected to succeed"); } } diff --git a/Algorithm.CSharp/MissingTickDataAlgorithm.cs b/Algorithm.CSharp/MissingTickDataAlgorithm.cs index c74eb473e980..cd73a3178293 100644 --- a/Algorithm.CSharp/MissingTickDataAlgorithm.cs +++ b/Algorithm.CSharp/MissingTickDataAlgorithm.cs @@ -41,7 +41,7 @@ public override void Initialize() if (tickCountInSliceHistoryCall != tickCountInTickHistoryCall) { - throw new Exception($@"Tick count mismatch in Slice and Tick history calls: History() returned { + throw new RegressionTestException($@"Tick count mismatch in Slice and Tick history calls: History() returned { tickCountInSliceHistoryCall} ticks, while History() returned {tickCountInTickHistoryCall} ticks"); } diff --git a/Algorithm.CSharp/MultiUniverseSharedSecurityRegressionAlgorithm.cs b/Algorithm.CSharp/MultiUniverseSharedSecurityRegressionAlgorithm.cs index ea57a67ddccd..5429aea8aa5d 100644 --- a/Algorithm.CSharp/MultiUniverseSharedSecurityRegressionAlgorithm.cs +++ b/Algorithm.CSharp/MultiUniverseSharedSecurityRegressionAlgorithm.cs @@ -57,7 +57,7 @@ public override void OnData(Slice data) var spy = Securities["SPY"]; if (!spy.IsTradable || spy.Price == 0) { - throw new Exception("'SPY' should always be tradable and have a price even if removed by the custom universe!"); + throw new RegressionTestException("'SPY' should always be tradable and have a price even if removed by the custom universe!"); } } diff --git a/Algorithm.CSharp/NakedCallStrategyAlgorithm.cs b/Algorithm.CSharp/NakedCallStrategyAlgorithm.cs index 7a0c7ac931f1..eaa861f28a03 100644 --- a/Algorithm.CSharp/NakedCallStrategyAlgorithm.cs +++ b/Algorithm.CSharp/NakedCallStrategyAlgorithm.cs @@ -52,20 +52,20 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup { if (positionGroup.Positions.Count() != 1) { - throw new Exception($"Expected position group to have 1 position. Actual: {positionGroup.Positions.Count()}"); + throw new RegressionTestException($"Expected position group to have 1 position. Actual: {positionGroup.Positions.Count()}"); } var optionPosition = positionGroup.Positions.Single(x => x.Symbol.SecurityType == SecurityType.Option); if (optionPosition.Symbol.ID.OptionRight != OptionRight.Call) { - throw new Exception($"Expected option position to be a call. Actual: {optionPosition.Symbol.ID.OptionRight}"); + throw new RegressionTestException($"Expected option position to be a call. Actual: {optionPosition.Symbol.ID.OptionRight}"); } var expectedOptionPositionQuantity = -2; if (optionPosition.Quantity != expectedOptionPositionQuantity) { - throw new Exception($@"Expected option position quantity to be {expectedOptionPositionQuantity}. Actual: {optionPosition.Quantity}"); + throw new RegressionTestException($@"Expected option position quantity to be {expectedOptionPositionQuantity}. Actual: {optionPosition.Quantity}"); } } diff --git a/Algorithm.CSharp/NakedPutStrategyAlgorithm.cs b/Algorithm.CSharp/NakedPutStrategyAlgorithm.cs index 31aae0ac95f8..45db60675849 100644 --- a/Algorithm.CSharp/NakedPutStrategyAlgorithm.cs +++ b/Algorithm.CSharp/NakedPutStrategyAlgorithm.cs @@ -52,20 +52,20 @@ protected override void AssertStrategyPositionGroup(IPositionGroup positionGroup { if (positionGroup.Positions.Count() != 1) { - throw new Exception($"Expected position group to have 1 position. Actual: {positionGroup.Positions.Count()}"); + throw new RegressionTestException($"Expected position group to have 1 position. Actual: {positionGroup.Positions.Count()}"); } var optionPosition = positionGroup.Positions.Single(x => x.Symbol.SecurityType == SecurityType.Option); if (optionPosition.Symbol.ID.OptionRight != OptionRight.Put) { - throw new Exception($"Expected option position to be a put. Actual: {optionPosition.Symbol.ID.OptionRight}"); + throw new RegressionTestException($"Expected option position to be a put. Actual: {optionPosition.Symbol.ID.OptionRight}"); } var expectedOptionPositionQuantity = -2; if (optionPosition.Quantity != expectedOptionPositionQuantity) { - throw new Exception($@"Expected option position quantity to be {expectedOptionPositionQuantity}. Actual: {optionPosition.Quantity}"); + throw new RegressionTestException($@"Expected option position quantity to be {expectedOptionPositionQuantity}. Actual: {optionPosition.Quantity}"); } } diff --git a/Algorithm.CSharp/NakedShortOptionStrategyOverMarginAlgorithm.cs b/Algorithm.CSharp/NakedShortOptionStrategyOverMarginAlgorithm.cs index 077b81d9c5bf..7616a41c9f3a 100644 --- a/Algorithm.CSharp/NakedShortOptionStrategyOverMarginAlgorithm.cs +++ b/Algorithm.CSharp/NakedShortOptionStrategyOverMarginAlgorithm.cs @@ -95,7 +95,7 @@ public override void OnOrderEvent(OrderEvent orderEvent) if (orderEvent.Quantity == _quantityOverMargin && orderEvent.Status != OrderStatus.Invalid) { - throw new Exception($"Orders with quantity {_quantityOverMargin} should be invalid"); + throw new RegressionTestException($"Orders with quantity {_quantityOverMargin} should be invalid"); } } @@ -107,14 +107,14 @@ public override void OnEndOfAlgorithm() var expectedFilledOrdersCount = 2 * _optionStrategy.OptionLegs.Count; if (filledOrdersCount != expectedFilledOrdersCount) { - throw new Exception($"Expected {expectedFilledOrdersCount} filled orders, found {filledOrdersCount}"); + throw new RegressionTestException($"Expected {expectedFilledOrdersCount} filled orders, found {filledOrdersCount}"); } var expectedQuantity = Math.Abs(_quantity - _quantityToLiquidate); var positionGroup = Portfolio.Positions.Groups.Single(); if (positionGroup.Quantity != expectedQuantity) { - throw new Exception($"Expected position quantity to be {expectedQuantity} but was {positionGroup.Quantity}"); + throw new RegressionTestException($"Expected position quantity to be {expectedQuantity} but was {positionGroup.Quantity}"); } } diff --git a/Algorithm.CSharp/NoMarginCallExpectedRegressionAlgorithm.cs b/Algorithm.CSharp/NoMarginCallExpectedRegressionAlgorithm.cs index f53b1343346e..91c93856eea1 100644 --- a/Algorithm.CSharp/NoMarginCallExpectedRegressionAlgorithm.cs +++ b/Algorithm.CSharp/NoMarginCallExpectedRegressionAlgorithm.cs @@ -82,7 +82,7 @@ public override void OnEndOfAlgorithm() { if (_marginCall != 0) { - throw new Exception($"We expected NO margin call to happen, {_marginCall} occurred"); + throw new RegressionTestException($"We expected NO margin call to happen, {_marginCall} occurred"); } } diff --git a/Algorithm.CSharp/NonDynamicOptionsFilterRegressionAlgorithm.cs b/Algorithm.CSharp/NonDynamicOptionsFilterRegressionAlgorithm.cs index b353a7ff9b73..96e0f838e044 100644 --- a/Algorithm.CSharp/NonDynamicOptionsFilterRegressionAlgorithm.cs +++ b/Algorithm.CSharp/NonDynamicOptionsFilterRegressionAlgorithm.cs @@ -57,13 +57,13 @@ public override void OnSecuritiesChanged(SecurityChanges changes) // This is the underlying security addition if (changes.AddedSecurities.Count != 1 || changes.RemovedSecurities.Count != 0) { - throw new Exception("Unexpected security changes count: " + + throw new RegressionTestException("Unexpected security changes count: " + "on the first OnSecuritiesChanged callback, we expect only the underlying to be added."); } if (changes.AddedSecurities[0].Symbol != _optionSymbol.Underlying) { - throw new Exception("Unexpected security added: " + + throw new RegressionTestException("Unexpected security added: " + "on the first OnSecuritiesChanged callback, we expect only the underlying to be added."); } } @@ -77,19 +77,19 @@ public override void OnSecuritiesChanged(SecurityChanges changes) var marketOpen = exchangeHours.GetNextMarketOpen(Time.Date, false); if (Time.AddMinutes(-1) != marketOpen) { - throw new Exception($"Unexpected security changes time. Current time {Time}. Expected time: {marketOpen.AddMinutes(1)}"); + throw new RegressionTestException($"Unexpected security changes time. Current time {Time}. Expected time: {marketOpen.AddMinutes(1)}"); } // Check the changes if (changes.AddedSecurities.Count == 0) { - throw new Exception("Unexpected security changes count: " + + throw new RegressionTestException("Unexpected security changes count: " + "on second and third OnSecuritiesChanged callbacks we expect options to be added"); } if (changes.AddedSecurities.Any(security => !security.Symbol.HasCanonical() || security.Symbol.Canonical != _optionSymbol)) { - throw new Exception("Unexpected security added: " + + throw new RegressionTestException("Unexpected security added: " + $"on second and third OnSecuritiesChanged callbacks we expect only {UnderlyingTicker} options to be added"); } @@ -98,7 +98,7 @@ public override void OnSecuritiesChanged(SecurityChanges changes) // The options added the previous day should be removed if (changes.RemovedSecurities.Count != _previouslyAddedOptionsCount) { - throw new Exception("Unexpected security changes count: " + + throw new RegressionTestException("Unexpected security changes count: " + "on the third OnSecuritiesChanged callback we expect the previous day selection to be removed."); } } @@ -107,7 +107,7 @@ public override void OnSecuritiesChanged(SecurityChanges changes) } else { - throw new Exception($"Unexpected call to OnSecuritiesChanged: we expect only 3 OnSecuritiesChanged callbacks for this algorithm"); + throw new RegressionTestException($"Unexpected call to OnSecuritiesChanged: we expect only 3 OnSecuritiesChanged callbacks for this algorithm"); } } @@ -115,7 +115,7 @@ public override void OnEndOfAlgorithm() { if (_securitiesChangedCount != 3) { - throw new Exception($"Unexpected number of calls to OnSecuritiesChanged: {_securitiesChangedCount}. " + + throw new RegressionTestException($"Unexpected number of calls to OnSecuritiesChanged: {_securitiesChangedCount}. " + "We expect only 3 OnSecuritiesChanged callbacks for this algorithm"); } } diff --git a/Algorithm.CSharp/NullBuyingPowerOptionBullCallSpreadAlgorithm.cs b/Algorithm.CSharp/NullBuyingPowerOptionBullCallSpreadAlgorithm.cs index 338067d9dc8f..80d23c25c39e 100644 --- a/Algorithm.CSharp/NullBuyingPowerOptionBullCallSpreadAlgorithm.cs +++ b/Algorithm.CSharp/NullBuyingPowerOptionBullCallSpreadAlgorithm.cs @@ -80,7 +80,7 @@ public override void OnData(Slice slice) { if (ticket.Status != OrderStatus.Filled) { - throw new Exception($"There should be no restriction on buying {ticket.Quantity} of {ticket.Symbol} with BuyingPowerModel.Null"); + throw new RegressionTestException($"There should be no restriction on buying {ticket.Quantity} of {ticket.Symbol} with BuyingPowerModel.Null"); } } } @@ -90,7 +90,7 @@ public override void OnEndOfAlgorithm() { if (Portfolio.TotalMarginUsed != 0) { - throw new Exception("The TotalMarginUsed should be zero to avoid margin calls."); + throw new RegressionTestException("The TotalMarginUsed should be zero to avoid margin calls."); } } diff --git a/Algorithm.CSharp/NullMarginMultipleOrdersRegressionAlgorithm.cs b/Algorithm.CSharp/NullMarginMultipleOrdersRegressionAlgorithm.cs index 892c0e2c8f91..23e47ef03513 100644 --- a/Algorithm.CSharp/NullMarginMultipleOrdersRegressionAlgorithm.cs +++ b/Algorithm.CSharp/NullMarginMultipleOrdersRegressionAlgorithm.cs @@ -94,15 +94,15 @@ protected virtual void AssertState(OrderTicket ticket, int expectedGroupCount, i { if (ticket.Status != OrderStatus.Filled) { - throw new Exception($"Unexpected order status {ticket.Status} for symbol {ticket.Symbol} and quantity {ticket.Quantity}"); + throw new RegressionTestException($"Unexpected order status {ticket.Status} for symbol {ticket.Symbol} and quantity {ticket.Quantity}"); } if (Portfolio.Positions.Groups.Count != expectedGroupCount) { - throw new Exception($"Unexpected position group count {Portfolio.Positions.Groups.Count} for symbol {ticket.Symbol} and quantity {ticket.Quantity}"); + throw new RegressionTestException($"Unexpected position group count {Portfolio.Positions.Groups.Count} for symbol {ticket.Symbol} and quantity {ticket.Quantity}"); } if(Portfolio.TotalMarginUsed != expectedMarginUsed) { - throw new Exception($"Unexpected margin used {expectedMarginUsed}"); + throw new RegressionTestException($"Unexpected margin used {expectedMarginUsed}"); } } diff --git a/Algorithm.CSharp/OnEndOfDayAddDataRegressionAlgorithm.cs b/Algorithm.CSharp/OnEndOfDayAddDataRegressionAlgorithm.cs index 74cb74ec7b2d..624999e802b7 100644 --- a/Algorithm.CSharp/OnEndOfDayAddDataRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OnEndOfDayAddDataRegressionAlgorithm.cs @@ -41,7 +41,7 @@ public override void OnEndOfDay(Symbol symbol) { if (symbol != _spy) { - throw new Exception($"Unexpected 'OnEndOfDay(Symbol symbol)' symbol {symbol}"); + throw new RegressionTestException($"Unexpected 'OnEndOfDay(Symbol symbol)' symbol {symbol}"); } _count++; } @@ -51,7 +51,7 @@ public override void OnEndOfAlgorithm() // Monday to Friday if (_count != 5) { - throw new Exception($"Unexpected 'OnEndOfDay(Symbol symbol)' calls {_count}"); + throw new RegressionTestException($"Unexpected 'OnEndOfDay(Symbol symbol)' calls {_count}"); } } diff --git a/Algorithm.CSharp/OnEndOfDayRegressionAlgorithm.cs b/Algorithm.CSharp/OnEndOfDayRegressionAlgorithm.cs index d420f673e7ee..609aae06e8b5 100644 --- a/Algorithm.CSharp/OnEndOfDayRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OnEndOfDayRegressionAlgorithm.cs @@ -96,15 +96,15 @@ public override void OnEndOfAlgorithm() { if (_onEndOfDaySpyCallCount != 5) { - throw new Exception($"OnEndOfDay(SPY) unexpected count call {_onEndOfDaySpyCallCount}"); + throw new RegressionTestException($"OnEndOfDay(SPY) unexpected count call {_onEndOfDaySpyCallCount}"); } if (_onEndOfDayBacCallCount != 4) { - throw new Exception($"OnEndOfDay(BAC) unexpected count call {_onEndOfDayBacCallCount}"); + throw new RegressionTestException($"OnEndOfDay(BAC) unexpected count call {_onEndOfDayBacCallCount}"); } if (_onEndOfDayIbmCallCount != 1) { - throw new Exception($"OnEndOfDay(IBM) unexpected count call {_onEndOfDayIbmCallCount}"); + throw new RegressionTestException($"OnEndOfDay(IBM) unexpected count call {_onEndOfDayIbmCallCount}"); } } diff --git a/Algorithm.CSharp/OnOrderEventExceptionRegression.cs b/Algorithm.CSharp/OnOrderEventExceptionRegression.cs index cd8ae42ec917..1379fa56aac9 100644 --- a/Algorithm.CSharp/OnOrderEventExceptionRegression.cs +++ b/Algorithm.CSharp/OnOrderEventExceptionRegression.cs @@ -59,7 +59,7 @@ public override void OnData(Slice data) /// Order Event public override void OnOrderEvent(OrderEvent orderEvent) { - throw new Exception("OnOrderEvent exception"); + throw new RegressionTestException("OnOrderEvent exception"); } /// diff --git a/Algorithm.CSharp/OnWarmupFinishedNoWarmup.cs b/Algorithm.CSharp/OnWarmupFinishedNoWarmup.cs index 3941946ee099..80ca23c4804c 100644 --- a/Algorithm.CSharp/OnWarmupFinishedNoWarmup.cs +++ b/Algorithm.CSharp/OnWarmupFinishedNoWarmup.cs @@ -46,7 +46,7 @@ public override void OnEndOfAlgorithm() { if (_onWarmupFinished != 1) { - throw new Exception($"Unexpected {nameof(OnWarmupFinished)} call count {_onWarmupFinished}!"); + throw new RegressionTestException($"Unexpected {nameof(OnWarmupFinished)} call count {_onWarmupFinished}!"); } } diff --git a/Algorithm.CSharp/OnWarmupFinishedRegressionAlgorithm.cs b/Algorithm.CSharp/OnWarmupFinishedRegressionAlgorithm.cs index 19f73fa1f977..24ed02b3ca2e 100644 --- a/Algorithm.CSharp/OnWarmupFinishedRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OnWarmupFinishedRegressionAlgorithm.cs @@ -47,7 +47,7 @@ public override void OnEndOfAlgorithm() { if (_onWarmupFinished != 1) { - throw new Exception($"Unexpected {nameof(OnWarmupFinished)} call count {_onWarmupFinished}!"); + throw new RegressionTestException($"Unexpected {nameof(OnWarmupFinished)} call count {_onWarmupFinished}!"); } } diff --git a/Algorithm.CSharp/OpenInterestFuturesRegressionAlgorithm.cs b/Algorithm.CSharp/OpenInterestFuturesRegressionAlgorithm.cs index 7707f1222201..fd24ad3fc5e8 100644 --- a/Algorithm.CSharp/OpenInterestFuturesRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OpenInterestFuturesRegressionAlgorithm.cs @@ -64,7 +64,7 @@ public override void OnData(Slice slice) var matched = slice.Keys.Where(s => !s.IsCanonical() && !ExpectedExpiryDates.Contains(s.ID.Date)).ToList(); if (matched.Count != 0) { - throw new Exception($"{matched.Count}/{slice.Keys.Count} were unexpected expiry date(s): " + string.Join(", ", matched.Select(x => x.ID.Date))); + throw new RegressionTestException($"{matched.Count}/{slice.Keys.Count} were unexpected expiry date(s): " + string.Join(", ", matched.Select(x => x.ID.Date))); } foreach (var symbol in slice.Keys) diff --git a/Algorithm.CSharp/OptionAssignmentStatisticsRegressionAlgorithm.cs b/Algorithm.CSharp/OptionAssignmentStatisticsRegressionAlgorithm.cs index 3579a68e38bf..b152d52e2aef 100644 --- a/Algorithm.CSharp/OptionAssignmentStatisticsRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionAssignmentStatisticsRegressionAlgorithm.cs @@ -115,7 +115,7 @@ private void AssertTradeStatistics() if (trades.Count != 4) { - throw new Exception($@"AssertTradeStatistics(): Expected 4 closed trades: 2 for the options, 2 for the underlying. Actual: { + throw new RegressionTestException($@"AssertTradeStatistics(): Expected 4 closed trades: 2 for the options, 2 for the underlying. Actual: { trades.Count}"); } @@ -123,35 +123,35 @@ private void AssertTradeStatistics() if (statistics.TotalNumberOfTrades != 4) { - throw new Exception($@"AssertTradeStatistics(): Expected 4 total trades: 2 for the options, 2 for the underlying. Actual: { + throw new RegressionTestException($@"AssertTradeStatistics(): Expected 4 total trades: 2 for the options, 2 for the underlying. Actual: { statistics.TotalNumberOfTrades}"); } if (statistics.NumberOfWinningTrades != 3) { - throw new Exception($@"AssertTradeStatistics(): Expected 3 winning trades (the ITM 650 strike option and the underlying trades). Actual { + throw new RegressionTestException($@"AssertTradeStatistics(): Expected 3 winning trades (the ITM 650 strike option and the underlying trades). Actual { statistics.NumberOfWinningTrades}"); } if (statistics.NumberOfLosingTrades != 1) { - throw new Exception($@"AssertTradeStatistics(): Expected 1 losing trade (the 600 strike option). Actual { + throw new RegressionTestException($@"AssertTradeStatistics(): Expected 1 losing trade (the 600 strike option). Actual { statistics.NumberOfLosingTrades}"); } if (statistics.WinRate != 0.75m) { - throw new Exception($"AssertTradeStatistics(): Expected win rate to be 0.75. Actual {statistics.WinRate}"); + throw new RegressionTestException($"AssertTradeStatistics(): Expected win rate to be 0.75. Actual {statistics.WinRate}"); } if (statistics.LossRate != 0.25m) { - throw new Exception($"AssertTradeStatistics(): Expected loss rate to be 0.25. Actual {statistics.LossRate}"); + throw new RegressionTestException($"AssertTradeStatistics(): Expected loss rate to be 0.25. Actual {statistics.LossRate}"); } if (statistics.WinLossRatio != 3) { - throw new Exception($"AssertTradeStatistics(): Expected win-loss ratio to be 3. Actual {statistics.WinLossRatio}"); + throw new RegressionTestException($"AssertTradeStatistics(): Expected win-loss ratio to be 3. Actual {statistics.WinLossRatio}"); } // Let's assert the trades per symbol just to be sure @@ -160,35 +160,35 @@ private void AssertTradeStatistics() var googCall600Trade = trades.Where(t => t.Symbol == _googCall600Symbol).FirstOrDefault(); if (googCall600Trade == null) { - throw new Exception("AssertTradeStatistics(): Expected a closed trade for the 600 strike option"); + throw new RegressionTestException("AssertTradeStatistics(): Expected a closed trade for the 600 strike option"); } if (googCall600Trade.IsWin) { - throw new Exception("AssertTradeStatistics(): Expected the 600 strike option to be a losing trade"); + throw new RegressionTestException("AssertTradeStatistics(): Expected the 600 strike option to be a losing trade"); } // We expect the second option (650 strike) to be a winning trade var googCall650Trade = trades.Where(t => t.Symbol == _googCall650Symbol).FirstOrDefault(); if (googCall650Trade == null) { - throw new Exception("AssertTradeStatistics(): Expected a closed trade for the 650 strike option"); + throw new RegressionTestException("AssertTradeStatistics(): Expected a closed trade for the 650 strike option"); } if (!googCall650Trade.IsWin) { - throw new Exception("AssertTradeStatistics(): Expected the 650 strike option to be a winning trade"); + throw new RegressionTestException("AssertTradeStatistics(): Expected the 650 strike option to be a winning trade"); } // We expect the both underlying trades to be winning trades var googTrades = trades.Where(t => t.Symbol == _goog.Symbol).ToList(); if (googTrades.Count != 2) { - throw new Exception( + throw new RegressionTestException( $@"AssertTradeStatistics(): Expected 2 closed trades for the underlying, one for each option assignment. Actual: { googTrades.Count}"); } if (googTrades.Any(x => !x.IsWin || x.ProfitLoss < 0)) { - throw new Exception("AssertTradeStatistics(): Expected both underlying trades to be winning trades"); + throw new RegressionTestException("AssertTradeStatistics(): Expected both underlying trades to be winning trades"); } } @@ -200,50 +200,50 @@ private void AssertPortfolioStatistics() // and 1 losing transaction (the other option assignment) if (Transactions.WinCount != 2) { - throw new Exception($"AssertPortfolioStatistics(): Expected 2 winning transactions. Actual {Transactions.WinCount}"); + throw new RegressionTestException($"AssertPortfolioStatistics(): Expected 2 winning transactions. Actual {Transactions.WinCount}"); } if (Transactions.LossCount != 1) { - throw new Exception($"AssertPortfolioStatistics(): Expected 1 losing transaction. Actual {Transactions.LossCount}"); + throw new RegressionTestException($"AssertPortfolioStatistics(): Expected 1 losing transaction. Actual {Transactions.LossCount}"); } var portfolioStatistics = Statistics.TotalPerformance.PortfolioStatistics; if (portfolioStatistics.WinRate != 2m / 3m) { - throw new Exception($"AssertPortfolioStatistics(): Expected win rate to be 2/3. Actual {portfolioStatistics.WinRate}"); + throw new RegressionTestException($"AssertPortfolioStatistics(): Expected win rate to be 2/3. Actual {portfolioStatistics.WinRate}"); } if (portfolioStatistics.LossRate != 1m / 3m) { - throw new Exception($"AssertPortfolioStatistics(): Expected loss rate to be 1/3. Actual {portfolioStatistics.LossRate}"); + throw new RegressionTestException($"AssertPortfolioStatistics(): Expected loss rate to be 1/3. Actual {portfolioStatistics.LossRate}"); } var expectedAverageWinRate = 0.32962000910479m; if (!AreEqual(expectedAverageWinRate, portfolioStatistics.AverageWinRate)) { - throw new Exception($@"AssertPortfolioStatistics(): Expected average win rate to be {expectedAverageWinRate}. Actual { + throw new RegressionTestException($@"AssertPortfolioStatistics(): Expected average win rate to be {expectedAverageWinRate}. Actual { portfolioStatistics.AverageWinRate}"); } var expectedAverageLossRate = -0.13556638257576m; if (!AreEqual(expectedAverageLossRate, portfolioStatistics.AverageLossRate)) { - throw new Exception($@"AssertPortfolioStatistics(): Expected average loss rate to be {expectedAverageLossRate}. Actual { + throw new RegressionTestException($@"AssertPortfolioStatistics(): Expected average loss rate to be {expectedAverageLossRate}. Actual { portfolioStatistics.AverageLossRate}"); } var expectedProfitLossRatio = 2.43142881621545m; if (!AreEqual(expectedProfitLossRatio, portfolioStatistics.ProfitLossRatio)) { - throw new Exception($@"AssertPortfolioStatistics(): Expected profit loss ratio to be {expectedProfitLossRatio}. Actual { + throw new RegressionTestException($@"AssertPortfolioStatistics(): Expected profit loss ratio to be {expectedProfitLossRatio}. Actual { portfolioStatistics.ProfitLossRatio}"); } var totalNetProfit = -0.00697m; if (!AreEqual(totalNetProfit, portfolioStatistics.TotalNetProfit)) { - throw new Exception($@"AssertPortfolioStatistics(): Expected total net profit to be {totalNetProfit}. Actual { + throw new RegressionTestException($@"AssertPortfolioStatistics(): Expected total net profit to be {totalNetProfit}. Actual { portfolioStatistics.TotalNetProfit}"); } } diff --git a/Algorithm.CSharp/OptionChainConsistencyRegressionAlgorithm.cs b/Algorithm.CSharp/OptionChainConsistencyRegressionAlgorithm.cs index 3effc020b3cb..e1018f1af109 100644 --- a/Algorithm.CSharp/OptionChainConsistencyRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionChainConsistencyRegressionAlgorithm.cs @@ -72,7 +72,7 @@ public override void OnData(Slice slice) if (!Securities.ContainsKey(o.Symbol)) { // inconsistency found: option chains contains contract information that is not available in securities manager and not available for trading - throw new Exception("inconsistency found: option chains contains contract " + + throw new RegressionTestException("inconsistency found: option chains contains contract " + $"{o.Symbol.Value} that is not available in securities manager and not available for trading" ); } diff --git a/Algorithm.CSharp/OptionChainSubscriptionRemovalRegressionAlgorithm.cs b/Algorithm.CSharp/OptionChainSubscriptionRemovalRegressionAlgorithm.cs index 69be9477b2fe..74e3069fc332 100644 --- a/Algorithm.CSharp/OptionChainSubscriptionRemovalRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionChainSubscriptionRemovalRegressionAlgorithm.cs @@ -52,7 +52,7 @@ public override void OnEndOfAlgorithm() { if (_optionCount != 45) { - throw new Exception($"Unexpected option count {_optionCount}, expected 45"); + throw new RegressionTestException($"Unexpected option count {_optionCount}, expected 45"); } } @@ -79,7 +79,7 @@ private string GetStatusLog() // why 50? we select 15 option contracts, which add trade/quote/openInterest = 45 + SPY & underlying trade/quote + universe subscription => 50 if (SubscriptionManager.Subscriptions.Count() > 50) { - throw new Exception("Subscriptions aren't getting removed as expected!"); + throw new RegressionTestException("Subscriptions aren't getting removed as expected!"); } return $"{Time} | UniverseCount {UniverseManager.Count}. " + diff --git a/Algorithm.CSharp/OptionChainUniverseImmediateSelectionRegressionAlgorithm.cs b/Algorithm.CSharp/OptionChainUniverseImmediateSelectionRegressionAlgorithm.cs index 9067f5539498..5f89391dc438 100644 --- a/Algorithm.CSharp/OptionChainUniverseImmediateSelectionRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionChainUniverseImmediateSelectionRegressionAlgorithm.cs @@ -55,7 +55,7 @@ public override void Initialize() if (_firstOnDataCallDone) { - throw new Exception("Option chain universe selection time was set after OnData was called"); + throw new RegressionTestException("Option chain universe selection time was set after OnData was called"); } } @@ -80,12 +80,12 @@ public override void OnData(Slice slice) if (!slice.ContainsKey(_optionSymbol.Underlying)) { - throw new Exception($"Expected to find {_optionSymbol.Underlying} in first slice"); + throw new RegressionTestException($"Expected to find {_optionSymbol.Underlying} in first slice"); } if (!slice.OptionChains.ContainsKey(_optionSymbol)) { - throw new Exception($"Expected to find {_optionSymbol} in first slice's Option Chain"); + throw new RegressionTestException($"Expected to find {_optionSymbol} in first slice's Option Chain"); } } } @@ -97,7 +97,7 @@ public override void OnSecuritiesChanged(SecurityChanges changes) if (_securityChangesCallCount <= 2 && _firstOnDataCallDone) { - throw new Exception("Expected 2 OnSecuritiesChanged calls (Underlying addition + Options additions) " + + throw new RegressionTestException("Expected 2 OnSecuritiesChanged calls (Underlying addition + Options additions) " + "before the first data is sent to the algorithm"); } @@ -106,7 +106,7 @@ public override void OnSecuritiesChanged(SecurityChanges changes) // The first time, only the underlying should have been added if (changes.AddedSecurities.Count != 1 || changes.RemovedSecurities.Count != 0) { - throw new Exception($"Unexpected securities changes on first OnSecuritiesChanged event. " + + throw new RegressionTestException($"Unexpected securities changes on first OnSecuritiesChanged event. " + $"Expected one security added and none removed but got {changes.AddedSecurities.Count} securities added " + $"and {changes.RemovedSecurities.Count} removed."); } @@ -114,7 +114,7 @@ public override void OnSecuritiesChanged(SecurityChanges changes) var addedSecuritySymbol = changes.AddedSecurities.Single().Symbol; if (addedSecuritySymbol != _optionSymbol.Underlying) { - throw new Exception($"Expected to find {_optionSymbol.Underlying} in first OnSecuritiesChanged event, " + + throw new RegressionTestException($"Expected to find {_optionSymbol.Underlying} in first OnSecuritiesChanged event, " + $"but found {addedSecuritySymbol}"); } } @@ -124,19 +124,19 @@ public override void OnSecuritiesChanged(SecurityChanges changes) if (_selectionTimeUtc == DateTime.MinValue) { - throw new Exception("Option chain universe selection time was not set"); + throw new RegressionTestException("Option chain universe selection time was not set"); } if (changes.AddedSecurities.Count != _selectedOptionsCount || changes.RemovedSecurities.Count != 0) { - throw new Exception($"Unexpected securities changes on second OnSecuritiesChanged event. " + + throw new RegressionTestException($"Unexpected securities changes on second OnSecuritiesChanged event. " + $"Expected {_selectedOptionsCount} options added and none removed but got {changes.AddedSecurities.Count} " + $"securities added and {changes.RemovedSecurities.Count} removed."); } if (!changes.AddedSecurities.All(x => x.Type.IsOption() && !x.Symbol.IsCanonical() && x.Symbol.Canonical == _optionSymbol)) { - throw new Exception($"Expected to find a multiple option contracts"); + throw new RegressionTestException($"Expected to find a multiple option contracts"); } } } @@ -145,12 +145,12 @@ public override void OnEndOfAlgorithm() { if (!_firstOnDataCallDone) { - throw new Exception("OnData was never called"); + throw new RegressionTestException("OnData was never called"); } if (_securityChangesCallCount < 2) { - throw new Exception("OnSecuritiesChanged was not called at least twice"); + throw new RegressionTestException("OnSecuritiesChanged was not called at least twice"); } } diff --git a/Algorithm.CSharp/OptionChainUniverseRemovalRegressionAlgorithm.cs b/Algorithm.CSharp/OptionChainUniverseRemovalRegressionAlgorithm.cs index b8576c14b9c6..0c0e531ea13b 100644 --- a/Algorithm.CSharp/OptionChainUniverseRemovalRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionChainUniverseRemovalRegressionAlgorithm.cs @@ -58,7 +58,7 @@ public override void Initialize() { if (universe.Underlying == null) { - throw new Exception("Underlying data point is null! This shouldn't happen, each OptionChainUniverse handles and should provide this"); + throw new RegressionTestException("Underlying data point is null! This shouldn't happen, each OptionChainUniverse handles and should provide this"); } return universe.IncludeWeeklys() .BackMonth() // back month so that they don't get removed because of being delisted @@ -88,7 +88,7 @@ public override void OnData(Slice data) // options added should all match prev added security if (security.Symbol.Underlying != _lastEquityAdded) { - throw new Exception($"Unexpected symbol added {security.Symbol}"); + throw new RegressionTestException($"Unexpected symbol added {security.Symbol}"); } _optionCount++; @@ -104,12 +104,12 @@ public override void OnSecuritiesChanged(SecurityChanges changes) { if (Time.Hour != 0 && Time.Hour != 9) { - throw new Exception($"Unexpected SecurityChanges time: {Time} {changes}"); + throw new RegressionTestException($"Unexpected SecurityChanges time: {Time} {changes}"); } if (changes.RemovedSecurities.Count != 0) { - throw new Exception($"Unexpected removals: {changes}"); + throw new RegressionTestException($"Unexpected removals: {changes}"); } if (Time.Hour == 0) @@ -117,7 +117,7 @@ public override void OnSecuritiesChanged(SecurityChanges changes) // first we expect the equity to get Added if (changes.AddedSecurities.Count != 1 || changes.AddedSecurities[0].Symbol != _aapl) { - throw new Exception($"Unexpected SecurityChanges: {changes}"); + throw new RegressionTestException($"Unexpected SecurityChanges: {changes}"); } } else @@ -125,7 +125,7 @@ public override void OnSecuritiesChanged(SecurityChanges changes) // later we expect the options to be Added if (changes.AddedSecurities.Count != 5 || changes.AddedSecurities.Any(security => security.Symbol.SecurityType != SecurityType.Option)) { - throw new Exception($"Unexpected SecurityChanges: {changes}"); + throw new RegressionTestException($"Unexpected SecurityChanges: {changes}"); } } } @@ -134,17 +134,17 @@ public override void OnSecuritiesChanged(SecurityChanges changes) { if (Time.Hour != 0) { - throw new Exception($"Unexpected SecurityChanges time: {Time} {changes}"); + throw new RegressionTestException($"Unexpected SecurityChanges time: {Time} {changes}"); } if (changes.AddedSecurities.Count != 0) { - throw new Exception($"Unexpected additions: {changes}"); + throw new RegressionTestException($"Unexpected additions: {changes}"); } if (changes.RemovedSecurities.Count != 1 || changes.RemovedSecurities[0].Symbol != _aapl) { - throw new Exception($"Unexpected SecurityChanges: {changes}"); + throw new RegressionTestException($"Unexpected SecurityChanges: {changes}"); } } // We expect the options to get Removed, happens in the next loop after removing the equity @@ -152,7 +152,7 @@ public override void OnSecuritiesChanged(SecurityChanges changes) { if (Time.Hour != 0) { - throw new Exception($"Unexpected SecurityChanges time: {Time} {changes}"); + throw new RegressionTestException($"Unexpected SecurityChanges time: {Time} {changes}"); } // later we expect the options to be Removed @@ -162,7 +162,7 @@ public override void OnSecuritiesChanged(SecurityChanges changes) // the removal of the 5 option contracts || changes.RemovedSecurities.Count(security => security.Symbol.SecurityType == SecurityType.Option) != 5) { - throw new Exception($"Unexpected SecurityChanges: {changes}"); + throw new RegressionTestException($"Unexpected SecurityChanges: {changes}"); } } @@ -173,11 +173,11 @@ public override void OnEndOfAlgorithm() { if (_optionCount == 0) { - throw new Exception("Option universe chain did not add any option!"); + throw new RegressionTestException("Option universe chain did not add any option!"); } if (UniverseManager.Any(pair => pair.Value.DisposeRequested)) { - throw new Exception("There shouldn't be any disposed universe, they should be removed and replaced by new universes"); + throw new RegressionTestException("There shouldn't be any disposed universe, they should be removed and replaced by new universes"); } } diff --git a/Algorithm.CSharp/OptionChainedAndUniverseSelectionRegressionAlgorithm.cs b/Algorithm.CSharp/OptionChainedAndUniverseSelectionRegressionAlgorithm.cs index 28155286a4e8..171c193c2e48 100644 --- a/Algorithm.CSharp/OptionChainedAndUniverseSelectionRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionChainedAndUniverseSelectionRegressionAlgorithm.cs @@ -53,11 +53,11 @@ public override void OnEndOfAlgorithm() var config = SubscriptionManager.Subscriptions.ToList(); if (config.All(dataConfig => dataConfig.Symbol != "AAPL")) { - throw new Exception("Was expecting configurations for AAPL"); + throw new RegressionTestException("Was expecting configurations for AAPL"); } if (config.All(dataConfig => dataConfig.Symbol.SecurityType != SecurityType.Option)) { - throw new Exception($"Was expecting configurations for {_aaplOption}"); + throw new RegressionTestException($"Was expecting configurations for {_aaplOption}"); } } diff --git a/Algorithm.CSharp/OptionDelistedDataRegressionAlgorithm.cs b/Algorithm.CSharp/OptionDelistedDataRegressionAlgorithm.cs index d5d3a4e3baca..a2272dd7fecf 100644 --- a/Algorithm.CSharp/OptionDelistedDataRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionDelistedDataRegressionAlgorithm.cs @@ -45,7 +45,7 @@ public override void OnData(Slice data) { if (_delisted.Contains(d.Key)) { - throw new Exception("We shouldn't be recieving data from an already delisted symbol"); + throw new RegressionTestException("We shouldn't be recieving data from an already delisted symbol"); } } } @@ -58,11 +58,11 @@ public override void OnEndOfAlgorithm() Debug("CUSTOM OnEndOfAlgorithm"); if (_delisted.Count != 20) { - throw new Exception("Expecting exactly 20 delisted events"); + throw new RegressionTestException("Expecting exactly 20 delisted events"); } if (_toBeDelisted.Count != 20) { - throw new Exception("Expecting exactly 20 to be delisted warning events"); + throw new RegressionTestException("Expecting exactly 20 to be delisted warning events"); } } base.OnEndOfAlgorithm(); diff --git a/Algorithm.CSharp/OptionEquityBaseStrategyRegressionAlgorithm.cs b/Algorithm.CSharp/OptionEquityBaseStrategyRegressionAlgorithm.cs index 2bb7f6e66381..653b1912bd79 100644 --- a/Algorithm.CSharp/OptionEquityBaseStrategyRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionEquityBaseStrategyRegressionAlgorithm.cs @@ -55,7 +55,7 @@ protected void AssertOptionStrategyIsPresent(string name, int? quantity = null) .Count(group => ((OptionStrategyPositionGroupBuyingPowerModel)@group.BuyingPowerModel).ToString() == name && (!quantity.HasValue || Math.Abs(group.Quantity) == quantity)) != 1) { - throw new Exception($"Option strategy: '{name}' was not found!"); + throw new RegressionTestException($"Option strategy: '{name}' was not found!"); } } @@ -64,7 +64,7 @@ protected void AssertDefaultGroup(Symbol symbol, decimal quantity) if (Portfolio.Positions.Groups.Where(group => group.BuyingPowerModel is SecurityPositionGroupBuyingPowerModel) .Count(group => group.Positions.Any(position => position.Symbol == symbol && position.Quantity == quantity)) != 1) { - throw new Exception($"Default groupd for symbol '{symbol}' and quantity '{quantity}' was not found!"); + throw new RegressionTestException($"Default groupd for symbol '{symbol}' and quantity '{quantity}' was not found!"); } } diff --git a/Algorithm.CSharp/OptionEquityBearCallSpreadRegressionAlgorithm.cs b/Algorithm.CSharp/OptionEquityBearCallSpreadRegressionAlgorithm.cs index 256e687c3185..efbde981137c 100644 --- a/Algorithm.CSharp/OptionEquityBearCallSpreadRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionEquityBearCallSpreadRegressionAlgorithm.cs @@ -63,14 +63,14 @@ public override void OnData(Slice slice) if (expectedMarginUsage != Portfolio.TotalMarginUsed) { - throw new Exception("Unexpect margin used!"); + throw new RegressionTestException("Unexpect margin used!"); } // we payed the ask and value using the assets price var priceSpreadDifference = GetPriceSpreadDifference(longCall.Symbol, shortCall.Symbol); if (initialMargin != (freeMarginPostTrade + expectedMarginUsage + _paidFees - priceSpreadDifference)) { - throw new Exception("Unexpect margin remaining!"); + throw new RegressionTestException("Unexpect margin remaining!"); } } } diff --git a/Algorithm.CSharp/OptionEquityBearCallSpreadSetHoldingsRegressionAlgorithm.cs b/Algorithm.CSharp/OptionEquityBearCallSpreadSetHoldingsRegressionAlgorithm.cs index 3ecf97a03ece..b96e1e3e17a3 100644 --- a/Algorithm.CSharp/OptionEquityBearCallSpreadSetHoldingsRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionEquityBearCallSpreadSetHoldingsRegressionAlgorithm.cs @@ -69,7 +69,7 @@ public override void OnData(Slice slice) if (freeMargin >= freeMarginPostTrade) { - throw new Exception("We expect the margin used to actually be lower once we perform the second trade"); + throw new RegressionTestException("We expect the margin used to actually be lower once we perform the second trade"); } } } diff --git a/Algorithm.CSharp/OptionEquityBearPutSpreadRegressionAlgorithm.cs b/Algorithm.CSharp/OptionEquityBearPutSpreadRegressionAlgorithm.cs index baf8e5b79c73..52ed2ab63f34 100644 --- a/Algorithm.CSharp/OptionEquityBearPutSpreadRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionEquityBearPutSpreadRegressionAlgorithm.cs @@ -60,14 +60,14 @@ public override void OnData(Slice slice) var expectedMarginUsage = Math.Max((shortPut.Strike - longPut.Strike) * Securities[longPut.Symbol].SymbolProperties.ContractMultiplier * 10, 0); if (expectedMarginUsage != Portfolio.TotalMarginUsed) { - throw new Exception("Unexpect margin used!"); + throw new RegressionTestException("Unexpect margin used!"); } // we payed the ask and value using the assets price var priceSpreadDifference = GetPriceSpreadDifference(longPut.Symbol, shortPut.Symbol); if (initialMargin != (freeMarginPostTrade + expectedMarginUsage + _paidFees - priceSpreadDifference)) { - throw new Exception("Unexpect margin remaining!"); + throw new RegressionTestException("Unexpect margin remaining!"); } } } diff --git a/Algorithm.CSharp/OptionEquityBoxSpreadRegressionAlgorithm.cs b/Algorithm.CSharp/OptionEquityBoxSpreadRegressionAlgorithm.cs index ba1d621b82ee..674a6b52f99d 100644 --- a/Algorithm.CSharp/OptionEquityBoxSpreadRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionEquityBoxSpreadRegressionAlgorithm.cs @@ -71,7 +71,7 @@ public override void OnData(Slice slice) var expectedMarginUsage = 0m; if (expectedMarginUsage != Portfolio.TotalMarginUsed) { - throw new Exception("Unexpect margin used!"); + throw new RegressionTestException("Unexpect margin used!"); } // we payed the ask and value using the assets price @@ -79,7 +79,7 @@ public override void OnData(Slice slice) sellSidePut.Symbol, sellSideCall.Symbol); if (initialMargin != (freeMarginPostTrade + expectedMarginUsage + _paidFees - priceSpreadDifference)) { - throw new Exception("Unexpect margin remaining!"); + throw new RegressionTestException("Unexpect margin remaining!"); } } } diff --git a/Algorithm.CSharp/OptionEquityBullCallSpreadRegressionAlgorithm.cs b/Algorithm.CSharp/OptionEquityBullCallSpreadRegressionAlgorithm.cs index 243edfb7f1c5..2b317ea550da 100644 --- a/Algorithm.CSharp/OptionEquityBullCallSpreadRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionEquityBullCallSpreadRegressionAlgorithm.cs @@ -59,14 +59,14 @@ public override void OnData(Slice slice) var expectedMarginUsage = Math.Max((longCall.Strike - shortCall.Strike) * Securities[longCall.Symbol].SymbolProperties.ContractMultiplier * 5, 0); if (expectedMarginUsage != Portfolio.TotalMarginUsed) { - throw new Exception("Unexpect margin used!"); + throw new RegressionTestException("Unexpect margin used!"); } // we payed the ask and value using the assets price var priceSpreadDifference = GetPriceSpreadDifference(longCall.Symbol, shortCall.Symbol); if (initialMargin != (freeMarginPostTrade + expectedMarginUsage + _paidFees - priceSpreadDifference)) { - throw new Exception("Unexpect margin remaining!"); + throw new RegressionTestException("Unexpect margin remaining!"); } } } diff --git a/Algorithm.CSharp/OptionEquityBullPutSpreadRegressionAlgorithm.cs b/Algorithm.CSharp/OptionEquityBullPutSpreadRegressionAlgorithm.cs index c93781aaa442..611800088fbb 100644 --- a/Algorithm.CSharp/OptionEquityBullPutSpreadRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionEquityBullPutSpreadRegressionAlgorithm.cs @@ -58,14 +58,14 @@ public override void OnData(Slice slice) var expectedMarginUsage = Math.Max((shortPut.Strike - longPut.Strike) * Securities[longPut.Symbol].SymbolProperties.ContractMultiplier * 10, 0); if (expectedMarginUsage != Portfolio.TotalMarginUsed) { - throw new Exception("Unexpect margin used!"); + throw new RegressionTestException("Unexpect margin used!"); } // we payed the ask and value using the assets price var priceSpreadDifference = GetPriceSpreadDifference(longPut.Symbol, shortPut.Symbol); if (initialMargin != (freeMarginPostTrade + expectedMarginUsage + _paidFees - priceSpreadDifference)) { - throw new Exception("Unexpect margin remaining!"); + throw new RegressionTestException("Unexpect margin remaining!"); } } } diff --git a/Algorithm.CSharp/OptionEquityCallButterflyRegressionAlgorithm.cs b/Algorithm.CSharp/OptionEquityCallButterflyRegressionAlgorithm.cs index 767a058d2d6f..58d595507bec 100644 --- a/Algorithm.CSharp/OptionEquityCallButterflyRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionEquityCallButterflyRegressionAlgorithm.cs @@ -63,14 +63,14 @@ public override void OnData(Slice slice) var expectedMarginUsage = 0; if (expectedMarginUsage != Portfolio.TotalMarginUsed) { - throw new Exception("Unexpect margin used!"); + throw new RegressionTestException("Unexpect margin used!"); } // we payed the ask and value using the assets price var priceSpreadDifference = GetPriceSpreadDifference(lowerCall.Symbol, middleCall.Symbol, highestCall.Symbol); if (initialMargin != (freeMarginPostTrade + expectedMarginUsage + _paidFees - priceSpreadDifference)) { - throw new Exception("Unexpect margin remaining!"); + throw new RegressionTestException("Unexpect margin remaining!"); } } } diff --git a/Algorithm.CSharp/OptionEquityCallCalendarSpreadRegressionAlgorithm.cs b/Algorithm.CSharp/OptionEquityCallCalendarSpreadRegressionAlgorithm.cs index f7733acc2d88..494de2c84ee6 100644 --- a/Algorithm.CSharp/OptionEquityCallCalendarSpreadRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionEquityCallCalendarSpreadRegressionAlgorithm.cs @@ -60,14 +60,14 @@ public override void OnData(Slice slice) var expectedMarginUsage = 0; if (expectedMarginUsage != Portfolio.TotalMarginUsed) { - throw new Exception("Unexpect margin used!"); + throw new RegressionTestException("Unexpect margin used!"); } // we payed the ask and value using the assets price var priceSpreadDifference = GetPriceSpreadDifference(shortCall.Symbol, longCall.Symbol); if (initialMargin != (freeMarginPostTrade + expectedMarginUsage + _paidFees - priceSpreadDifference)) { - throw new Exception("Unexpect margin remaining!"); + throw new RegressionTestException("Unexpect margin remaining!"); } } } diff --git a/Algorithm.CSharp/OptionEquityConversionRegressionAlgorithm.cs b/Algorithm.CSharp/OptionEquityConversionRegressionAlgorithm.cs index c1fcd4057588..27a27515aa8b 100644 --- a/Algorithm.CSharp/OptionEquityConversionRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionEquityConversionRegressionAlgorithm.cs @@ -62,14 +62,14 @@ public override void OnData(Slice slice) if (expectedMarginUsage != Portfolio.TotalMarginUsed) { - throw new Exception("Unexpect margin used!"); + throw new RegressionTestException("Unexpect margin used!"); } // we payed the ask and value using the assets price var priceSpreadDifference = GetPriceSpreadDifference(call.Symbol, put.Symbol, underlying); if (initialMargin != (freeMarginPostTrade + expectedMarginUsage + _paidFees - priceSpreadDifference)) { - throw new Exception("Unexpect margin remaining!"); + throw new RegressionTestException("Unexpect margin remaining!"); } } } diff --git a/Algorithm.CSharp/OptionEquityCoveredCallRegressionAlgorithm.cs b/Algorithm.CSharp/OptionEquityCoveredCallRegressionAlgorithm.cs index c1e43a2d9a43..7742c68344fb 100644 --- a/Algorithm.CSharp/OptionEquityCoveredCallRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionEquityCoveredCallRegressionAlgorithm.cs @@ -61,14 +61,14 @@ public override void OnData(Slice slice) var expectedMarginUsage = underlyingMarginRequirements; if (expectedMarginUsage != Portfolio.TotalMarginUsed) { - throw new Exception("Unexpect margin used!"); + throw new RegressionTestException("Unexpect margin used!"); } // we payed the ask and value using the assets price var priceSpreadDifference = GetPriceSpreadDifference(atmContract.Symbol, atmContract.Symbol.Underlying); if (initialMargin != (freeMarginPostTrade + expectedMarginUsage + _paidFees - priceSpreadDifference)) { - throw new Exception("Unexpect margin remaining!"); + throw new RegressionTestException("Unexpect margin remaining!"); } } } diff --git a/Algorithm.CSharp/OptionEquityCoveredPutRegressionAlgorithm.cs b/Algorithm.CSharp/OptionEquityCoveredPutRegressionAlgorithm.cs index b2739734e91d..64a877ea060d 100644 --- a/Algorithm.CSharp/OptionEquityCoveredPutRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionEquityCoveredPutRegressionAlgorithm.cs @@ -62,14 +62,14 @@ public override void OnData(Slice slice) var expectedMarginUsage = inTheMoneyAmount + Math.Abs(underlyingMarginRequirements.Value); if (expectedMarginUsage != Portfolio.TotalMarginUsed) { - throw new Exception("Unexpect margin used!"); + throw new RegressionTestException("Unexpect margin used!"); } // we payed the ask and value using the assets price var priceSpreadDifference = GetPriceSpreadDifference(atmContract.Symbol, atmContract.Symbol.Underlying); if (initialMargin != (freeMarginPostTrade + expectedMarginUsage + _paidFees - priceSpreadDifference)) { - throw new Exception("Unexpect margin remaining!"); + throw new RegressionTestException("Unexpect margin remaining!"); } } } diff --git a/Algorithm.CSharp/OptionEquityIronCondorRegressionAlgorithm.cs b/Algorithm.CSharp/OptionEquityIronCondorRegressionAlgorithm.cs index ab28e10569e9..3f6091f6bd67 100644 --- a/Algorithm.CSharp/OptionEquityIronCondorRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionEquityIronCondorRegressionAlgorithm.cs @@ -71,7 +71,7 @@ public override void OnData(Slice slice) var expectedMarginUsage = (lessOufOfTheMoneyPut.Strike - oufOfTheMoneyPut.Strike) * Securities[lessOufOfTheMoneyPut.Symbol].SymbolProperties.ContractMultiplier * 10; ; if (expectedMarginUsage != Portfolio.TotalMarginUsed) { - throw new Exception("Unexpect margin used!"); + throw new RegressionTestException("Unexpect margin used!"); } // we payed the ask and value using the assets price @@ -79,7 +79,7 @@ public override void OnData(Slice slice) oufOfTheMoneyCall.Symbol, moreOufOfTheMoneyCall.Symbol); if (initialMargin != (freeMarginPostTrade + expectedMarginUsage + _paidFees - priceSpreadDifference)) { - throw new Exception("Unexpect margin remaining!"); + throw new RegressionTestException("Unexpect margin remaining!"); } } } diff --git a/Algorithm.CSharp/OptionEquityProtectiveCollarRegressionAlgorithm.cs b/Algorithm.CSharp/OptionEquityProtectiveCollarRegressionAlgorithm.cs index 579b9fd52dd4..fa9613c6c0b1 100644 --- a/Algorithm.CSharp/OptionEquityProtectiveCollarRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionEquityProtectiveCollarRegressionAlgorithm.cs @@ -63,14 +63,14 @@ public override void OnData(Slice slice) if (expectedMarginUsage != Portfolio.TotalMarginUsed) { - throw new Exception("Unexpect margin used!"); + throw new RegressionTestException("Unexpect margin used!"); } // we payed the ask and value using the assets price var priceSpreadDifference = GetPriceSpreadDifference(call.Symbol, put.Symbol, underlying); if (initialMargin != (freeMarginPostTrade + expectedMarginUsage + _paidFees - priceSpreadDifference)) { - throw new Exception("Unexpect margin remaining!"); + throw new RegressionTestException("Unexpect margin remaining!"); } } } diff --git a/Algorithm.CSharp/OptionEquityPutButterflyRegressionAlgorithm.cs b/Algorithm.CSharp/OptionEquityPutButterflyRegressionAlgorithm.cs index 796d521bf8de..7fda770d3d4b 100644 --- a/Algorithm.CSharp/OptionEquityPutButterflyRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionEquityPutButterflyRegressionAlgorithm.cs @@ -62,14 +62,14 @@ public override void OnData(Slice slice) var expectedMarginUsage = 0; if (expectedMarginUsage != Portfolio.TotalMarginUsed) { - throw new Exception("Unexpect margin used!"); + throw new RegressionTestException("Unexpect margin used!"); } // we payed the ask and value using the assets price var priceSpreadDifference = GetPriceSpreadDifference(lowerPut.Symbol, middlePut.Symbol, highestPut.Symbol); if (initialMargin != (freeMarginPostTrade + expectedMarginUsage + _paidFees - priceSpreadDifference)) { - throw new Exception("Unexpect margin remaining!"); + throw new RegressionTestException("Unexpect margin remaining!"); } } } diff --git a/Algorithm.CSharp/OptionEquityPutCalendarSpreadRegressionAlgorithm.cs b/Algorithm.CSharp/OptionEquityPutCalendarSpreadRegressionAlgorithm.cs index c73bbd22f9e6..26c7416e59d7 100644 --- a/Algorithm.CSharp/OptionEquityPutCalendarSpreadRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionEquityPutCalendarSpreadRegressionAlgorithm.cs @@ -59,14 +59,14 @@ public override void OnData(Slice slice) var expectedMarginUsage = Math.Max((shortPut.Strike - longPut.Strike) * Securities[longPut.Symbol].SymbolProperties.ContractMultiplier * 10, 0); if (expectedMarginUsage != Portfolio.TotalMarginUsed) { - throw new Exception("Unexpect margin used!"); + throw new RegressionTestException("Unexpect margin used!"); } // we payed the ask and value using the assets price var priceSpreadDifference = GetPriceSpreadDifference(longPut.Symbol, shortPut.Symbol); if (initialMargin != (freeMarginPostTrade + expectedMarginUsage + _paidFees - priceSpreadDifference)) { - throw new Exception("Unexpect margin remaining!"); + throw new RegressionTestException("Unexpect margin remaining!"); } } } diff --git a/Algorithm.CSharp/OptionEquityReverseConversionRegressionAlgorithm.cs b/Algorithm.CSharp/OptionEquityReverseConversionRegressionAlgorithm.cs index a5655dbcb04b..3138fbf65531 100644 --- a/Algorithm.CSharp/OptionEquityReverseConversionRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionEquityReverseConversionRegressionAlgorithm.cs @@ -62,14 +62,14 @@ public override void OnData(Slice slice) if (expectedMarginUsage != Portfolio.TotalMarginUsed) { - throw new Exception("Unexpect margin used!"); + throw new RegressionTestException("Unexpect margin used!"); } // we payed the ask and value using the assets price var priceSpreadDifference = GetPriceSpreadDifference(call.Symbol, put.Symbol, underlying); if (initialMargin != (freeMarginPostTrade + expectedMarginUsage + _paidFees - priceSpreadDifference)) { - throw new Exception("Unexpect margin remaining!"); + throw new RegressionTestException("Unexpect margin remaining!"); } } } diff --git a/Algorithm.CSharp/OptionEquityShortBoxSpreadRegressionAlgorithm.cs b/Algorithm.CSharp/OptionEquityShortBoxSpreadRegressionAlgorithm.cs index 379abed7eb8e..1ef1db4bc696 100644 --- a/Algorithm.CSharp/OptionEquityShortBoxSpreadRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionEquityShortBoxSpreadRegressionAlgorithm.cs @@ -78,7 +78,7 @@ public override void OnData(Slice slice) var expectedMarginUsage = Math.Max(1.02m * closeCost, strikeDifference * 1000m); if (expectedMarginUsage != Portfolio.TotalMarginUsed) { - throw new Exception("Unexpect margin used!"); + throw new RegressionTestException("Unexpect margin used!"); } // we payed the ask and value using the assets price @@ -86,7 +86,7 @@ public override void OnData(Slice slice) sellSidePut.Symbol, sellSideCall.Symbol); if (initialMargin != (freeMarginPostTrade + expectedMarginUsage + _paidFees - priceSpreadDifference)) { - throw new Exception("Unexpect margin remaining!"); + throw new RegressionTestException("Unexpect margin remaining!"); } } } diff --git a/Algorithm.CSharp/OptionEquityShortButterflyCallRegressionAlgorithm.cs b/Algorithm.CSharp/OptionEquityShortButterflyCallRegressionAlgorithm.cs index b9bff76f11c3..285c9ec6d2c1 100644 --- a/Algorithm.CSharp/OptionEquityShortButterflyCallRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionEquityShortButterflyCallRegressionAlgorithm.cs @@ -63,14 +63,14 @@ public override void OnData(Slice slice) var expectedMarginUsage = Math.Max((middleCall.Strike - lowerCall.Strike) * Securities[lowerCall.Symbol].SymbolProperties.ContractMultiplier * 10, 0); if (expectedMarginUsage != Portfolio.TotalMarginUsed) { - throw new Exception("Unexpect margin used!"); + throw new RegressionTestException("Unexpect margin used!"); } // we payed the ask and value using the assets price var priceSpreadDifference = GetPriceSpreadDifference(middleCall.Symbol, lowerCall.Symbol, highestCall.Symbol); if (initialMargin != (freeMarginPostTrade + expectedMarginUsage + _paidFees - priceSpreadDifference)) { - throw new Exception("Unexpect margin remaining!"); + throw new RegressionTestException("Unexpect margin remaining!"); } } } diff --git a/Algorithm.CSharp/OptionEquityShortButterflyPutRegressionAlgorithm.cs b/Algorithm.CSharp/OptionEquityShortButterflyPutRegressionAlgorithm.cs index 26f50dfdff5c..e8190ad85424 100644 --- a/Algorithm.CSharp/OptionEquityShortButterflyPutRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionEquityShortButterflyPutRegressionAlgorithm.cs @@ -61,14 +61,14 @@ public override void OnData(Slice slice) var expectedMarginUsage = Math.Max((middlePut.Strike - lowerPut.Strike) * Securities[middlePut.Symbol].SymbolProperties.ContractMultiplier * 10, 0); if (expectedMarginUsage != Portfolio.TotalMarginUsed) { - throw new Exception("Unexpect margin used!"); + throw new RegressionTestException("Unexpect margin used!"); } // we payed the ask and value using the assets price var priceSpreadDifference = GetPriceSpreadDifference(lowerPut.Symbol, middlePut.Symbol, highestPut.Symbol); if (initialMargin != (freeMarginPostTrade + expectedMarginUsage + _paidFees - priceSpreadDifference)) { - throw new Exception("Unexpect margin remaining!"); + throw new RegressionTestException("Unexpect margin remaining!"); } } } diff --git a/Algorithm.CSharp/OptionEquityStraddleRegressionAlgorithm.cs b/Algorithm.CSharp/OptionEquityStraddleRegressionAlgorithm.cs index 0bed259f571b..3c40ef835227 100644 --- a/Algorithm.CSharp/OptionEquityStraddleRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionEquityStraddleRegressionAlgorithm.cs @@ -59,14 +59,14 @@ public override void OnData(Slice slice) var expectedMarginUsage = 0m; if (expectedMarginUsage != Portfolio.TotalMarginUsed) { - throw new Exception("Unexpect margin used!"); + throw new RegressionTestException("Unexpect margin used!"); } // we payed the ask and value using the assets price var priceSpreadDifference = GetPriceSpreadDifference(put.Symbol, call.Symbol); if (initialMargin != (freeMarginPostTrade + expectedMarginUsage + _paidFees - priceSpreadDifference)) { - throw new Exception("Unexpect margin remaining!"); + throw new RegressionTestException("Unexpect margin remaining!"); } } } diff --git a/Algorithm.CSharp/OptionEquityStrangleRegressionAlgorithm.cs b/Algorithm.CSharp/OptionEquityStrangleRegressionAlgorithm.cs index 3e5d0a89bddd..789a248369d6 100644 --- a/Algorithm.CSharp/OptionEquityStrangleRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionEquityStrangleRegressionAlgorithm.cs @@ -59,14 +59,14 @@ public override void OnData(Slice slice) var expectedMarginUsage = 0m; if (expectedMarginUsage != Portfolio.TotalMarginUsed) { - throw new Exception("Unexpect margin used!"); + throw new RegressionTestException("Unexpect margin used!"); } // we payed the ask and value using the assets price var priceSpreadDifference = GetPriceSpreadDifference(oufOfTheMoneyPut.Symbol, oufOfTheMoneyCall.Symbol); if (initialMargin != (freeMarginPostTrade + expectedMarginUsage + _paidFees - priceSpreadDifference)) { - throw new Exception("Unexpect margin remaining!"); + throw new RegressionTestException("Unexpect margin remaining!"); } } } diff --git a/Algorithm.CSharp/OptionExerciseAssignRegressionAlgorithm.cs b/Algorithm.CSharp/OptionExerciseAssignRegressionAlgorithm.cs index 6d4c67ef48b2..46ceca5729de 100644 --- a/Algorithm.CSharp/OptionExerciseAssignRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionExerciseAssignRegressionAlgorithm.cs @@ -59,7 +59,7 @@ public override void OnEndOfAlgorithm() { if (!_assignedOption) { - throw new Exception("In the end, short ITM option position was not assigned."); + throw new RegressionTestException("In the end, short ITM option position was not assigned."); } } diff --git a/Algorithm.CSharp/OptionExerciseRegressionAlgorithm.cs b/Algorithm.CSharp/OptionExerciseRegressionAlgorithm.cs index 4dd34aeca433..a6fcdc54bce6 100644 --- a/Algorithm.CSharp/OptionExerciseRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionExerciseRegressionAlgorithm.cs @@ -96,7 +96,7 @@ public override void OnEndOfAlgorithm() { if (Portfolio[_equity].Quantity != 0) { - throw new Exception("Regression equity holdings should be zero after exercise."); + throw new RegressionTestException("Regression equity holdings should be zero after exercise."); } } diff --git a/Algorithm.CSharp/OptionExpiryDateOnHolidayCase.cs b/Algorithm.CSharp/OptionExpiryDateOnHolidayCase.cs index 60d33c7f8c0e..556724026309 100644 --- a/Algorithm.CSharp/OptionExpiryDateOnHolidayCase.cs +++ b/Algorithm.CSharp/OptionExpiryDateOnHolidayCase.cs @@ -68,24 +68,24 @@ public override void OnEndOfAlgorithm() _delistings.Any(d => d.Type == DelistingType.Warning) && _delistings.Any(d => d.Type == DelistingType.Delisted))) { - throw new Exception($"Option contract {_optionContract.Symbol} was not correctly delisted."); + throw new RegressionTestException($"Option contract {_optionContract.Symbol} was not correctly delisted."); } if (_delistings.FirstOrDefault(d => d.Type == DelistingType.Warning).EndTime.Date != new DateTime(2014, 04, 16)) { - throw new Exception($"Option contract {_optionContract.Symbol} delisting warning was not fired the right date."); + throw new RegressionTestException($"Option contract {_optionContract.Symbol} delisting warning was not fired the right date."); } if (_delistings.FirstOrDefault(d => d.Type == DelistingType.Delisted).EndTime.Date != new DateTime(2014, 04, 17)) { - throw new Exception($"Option contract {_optionContract.Symbol} was not delisted the right date."); + throw new RegressionTestException($"Option contract {_optionContract.Symbol} was not delisted the right date."); } if (Portfolio[_optionContract.Symbol].Invested) { - throw new Exception($"Option contract {_optionContract.Symbol} was not wasn't liquidated as part of delisting."); + throw new RegressionTestException($"Option contract {_optionContract.Symbol} was not wasn't liquidated as part of delisting."); } } diff --git a/Algorithm.CSharp/OptionExpiryDateTodayRegressionAlgorithm.cs b/Algorithm.CSharp/OptionExpiryDateTodayRegressionAlgorithm.cs index e1deb2e82e6f..74b8ee670459 100644 --- a/Algorithm.CSharp/OptionExpiryDateTodayRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionExpiryDateTodayRegressionAlgorithm.cs @@ -80,7 +80,7 @@ public override void OnData(Slice slice) var greeks = contract.Greeks; if (greeks.Delta == 0m && greeks.Gamma == 0m && greeks.Theta == 0m && greeks.Vega == 0m && greeks.Rho == 0m) { - throw new Exception($"Expected greeks to not be zero simultaneously for {contract.Symbol} at contract expiration date {contract.Expiry}"); + throw new RegressionTestException($"Expected greeks to not be zero simultaneously for {contract.Symbol} at contract expiration date {contract.Expiry}"); } } } @@ -90,7 +90,7 @@ public override void OnEndOfAlgorithm() { if (!_triedGreeksCalculation) { - throw new Exception("Expected to have tried greeks calculation"); + throw new RegressionTestException("Expected to have tried greeks calculation"); } } diff --git a/Algorithm.CSharp/OptionGreeksRegressionAlgorithm.cs b/Algorithm.CSharp/OptionGreeksRegressionAlgorithm.cs index de51556b6980..7cd3020e7b46 100644 --- a/Algorithm.CSharp/OptionGreeksRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionGreeksRegressionAlgorithm.cs @@ -86,7 +86,7 @@ public override void OnData(Slice slice) if (delta >= expected + error || delta <= expected - error) { - throw new Exception($"{symbol.Value} greeks not calculated accurately! Expected: {expected}, Estimation: {delta}"); + throw new RegressionTestException($"{symbol.Value} greeks not calculated accurately! Expected: {expected}, Estimation: {delta}"); } } diff --git a/Algorithm.CSharp/OptionIndicatorsMirrorContractsRegressionAlgorithm.cs b/Algorithm.CSharp/OptionIndicatorsMirrorContractsRegressionAlgorithm.cs index 1ef35562de7c..aa4593df189a 100644 --- a/Algorithm.CSharp/OptionIndicatorsMirrorContractsRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionIndicatorsMirrorContractsRegressionAlgorithm.cs @@ -77,7 +77,7 @@ public override void OnEndOfAlgorithm() { if (_impliedVolatility == 0m || _delta == 0m || _gamma == 0m || _vega == 0m || _theta == 0m || _rho == 0m) { - throw new Exception("Expected IV/greeks calculated"); + throw new RegressionTestException("Expected IV/greeks calculated"); } Debug(@$"Implied Volatility: {_impliedVolatility}, Delta: {_delta}, diff --git a/Algorithm.CSharp/OptionIndicatorsRegressionAlgorithm.cs b/Algorithm.CSharp/OptionIndicatorsRegressionAlgorithm.cs index bda9382b6c25..e4790c2a82f5 100644 --- a/Algorithm.CSharp/OptionIndicatorsRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionIndicatorsRegressionAlgorithm.cs @@ -61,14 +61,14 @@ public override void OnEndOfAlgorithm() { if (_impliedVolatility == 0m || _delta == 0m || _gamma == 0m || _vega == 0m || _theta == 0m || _rho == 0m) { - throw new Exception("Expected IV/greeks calculated"); + throw new RegressionTestException("Expected IV/greeks calculated"); } var result = @$"Implied Volatility: {_impliedVolatility},Delta: {_delta},Gamma: {_gamma},Vega: {_vega},Theta: {_theta},Rho: {_rho}"; Debug(result); if (result != ExpectedGreeks) { - throw new Exception($"Unexpected greek values {result}. Expected {ExpectedGreeks}"); + throw new RegressionTestException($"Unexpected greek values {result}. Expected {ExpectedGreeks}"); } } diff --git a/Algorithm.CSharp/OptionNoTimeInUniverseRegressionAlgorithm.cs b/Algorithm.CSharp/OptionNoTimeInUniverseRegressionAlgorithm.cs index 57525748c71e..5e9e6e03f3b8 100644 --- a/Algorithm.CSharp/OptionNoTimeInUniverseRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionNoTimeInUniverseRegressionAlgorithm.cs @@ -63,7 +63,7 @@ public override void OnData(Slice slice) if (strikes.Count > 2) { - throw new Exception($"At {Time} found {strikes.Count}. Underlying: {underlyingPrice}. Strikes: [{string.Join(",", strikes)}]"); + throw new RegressionTestException($"At {Time} found {strikes.Count}. Underlying: {underlyingPrice}. Strikes: [{string.Join(",", strikes)}]"); } } diff --git a/Algorithm.CSharp/OptionOTMExpiryOrderHasZeroPriceRegressionAlgorithm.cs b/Algorithm.CSharp/OptionOTMExpiryOrderHasZeroPriceRegressionAlgorithm.cs index 661508dce043..2b29e1a2e48c 100644 --- a/Algorithm.CSharp/OptionOTMExpiryOrderHasZeroPriceRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionOTMExpiryOrderHasZeroPriceRegressionAlgorithm.cs @@ -67,7 +67,7 @@ public override void Initialize() _expectedContract = QuantConnect.Symbol.CreateOption(_es19m20, Market.CME, OptionStyle.American, OptionRight.Call, 3300m, new DateTime(2020, 6, 19)); if (_esOption != _expectedContract) { - throw new Exception($"Contract {_expectedContract} was not found in the chain"); + throw new RegressionTestException($"Contract {_expectedContract} was not found in the chain"); } } @@ -90,13 +90,13 @@ public override void OnOrderEvent(OrderEvent orderEvent) if (!Securities.ContainsKey(orderEvent.Symbol)) { - throw new Exception($"Order event Symbol not found in Securities collection: {orderEvent.Symbol}"); + throw new RegressionTestException($"Order event Symbol not found in Securities collection: {orderEvent.Symbol}"); } var security = Securities[orderEvent.Symbol]; if (security.Symbol == _es19m20) { - throw new Exception("Invalid state: did not expect a position for the underlying to be opened, since this contract expires OTM"); + throw new RegressionTestException("Invalid state: did not expect a position for the underlying to be opened, since this contract expires OTM"); } if (_cashAfterMarketOrder > 0) @@ -104,7 +104,7 @@ public override void OnOrderEvent(OrderEvent orderEvent) // This is the exercise order fill event if (orderEvent.IsInTheMoney || orderEvent.FillPrice != 0) { - throw new Exception($"Expected exercise order event fill price to be zero and to be marked as OTM, " + + throw new RegressionTestException($"Expected exercise order event fill price to be zero and to be marked as OTM, " + $"but was the fill price was {orderEvent.FillPrice} and IsInTheMoney = {orderEvent.IsInTheMoney}"); } } @@ -113,30 +113,30 @@ public override void OnOrderEvent(OrderEvent orderEvent) /// /// Ran at the end of the algorithm to ensure the algorithm has no holdings /// - /// The algorithm has holdings + /// The algorithm has holdings public override void OnEndOfAlgorithm() { if (Portfolio.Invested) { - throw new Exception($"Expected no holdings at end of algorithm, but are invested in: {string.Join(", ", Portfolio.Keys)}"); + throw new RegressionTestException($"Expected no holdings at end of algorithm, but are invested in: {string.Join(", ", Portfolio.Keys)}"); } // No change in cash is expected, only the market order fill price if (Portfolio.Cash != _cashAfterMarketOrder) { - throw new Exception($"Expected no change in cash after the market order. Cash in portfolio: {Portfolio.Cash}. Cash in portfolio after the market order: {_cashAfterMarketOrder}"); + throw new RegressionTestException($"Expected no change in cash after the market order. Cash in portfolio: {Portfolio.Cash}. Cash in portfolio after the market order: {_cashAfterMarketOrder}"); } var orders = Transactions.GetOrders().ToList(); if (orders.Count != 2) { - throw new Exception($"Expected 2 orders (market order and OTM option exercise), but found: {orders.Count}"); + throw new RegressionTestException($"Expected 2 orders (market order and OTM option exercise), but found: {orders.Count}"); } var exerciseOrder = orders.Find(x => x.Type == OrderType.OptionExercise); if (!exerciseOrder.Tag.Contains("OTM", StringComparison.InvariantCulture) || exerciseOrder.Price != 0) { - throw new Exception($"Expected the OTM exercise order to have price = 0, but was: {exerciseOrder.Price}"); + throw new RegressionTestException($"Expected the OTM exercise order to have price = 0, but was: {exerciseOrder.Price}"); } } diff --git a/Algorithm.CSharp/OptionOpenInterestRegressionAlgorithm.cs b/Algorithm.CSharp/OptionOpenInterestRegressionAlgorithm.cs index 46ab372c5b66..4862d0a3e7cf 100644 --- a/Algorithm.CSharp/OptionOpenInterestRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionOpenInterestRegressionAlgorithm.cs @@ -65,23 +65,23 @@ public override void OnData(Slice slice) var history = History(contract.Symbol, TimeSpan.FromDays(1)).ToList(); if (history.Count == 0) { - throw new Exception("Regression test failed: open interest history request is empty"); + throw new RegressionTestException("Regression test failed: open interest history request is empty"); } var security = Securities[contract.Symbol]; var openInterestCache = security.Cache.GetData(); if (openInterestCache == null) { - throw new Exception("Regression test failed: current open interest isn't in the security cache"); + throw new RegressionTestException("Regression test failed: current open interest isn't in the security cache"); } if (slice.Time.Date == new DateTime(2014, 06, 05) && (contract.OpenInterest != 50 || security.OpenInterest != 50)) { - throw new Exception("Regression test failed: current open interest was not correctly loaded and is not equal to 50"); + throw new RegressionTestException("Regression test failed: current open interest was not correctly loaded and is not equal to 50"); } if (slice.Time.Date == new DateTime(2014, 06, 06) && (contract.OpenInterest != 70 || security.OpenInterest != 70)) { - throw new Exception("Regression test failed: current open interest was not correctly loaded and is not equal to 70"); + throw new RegressionTestException("Regression test failed: current open interest was not correctly loaded and is not equal to 70"); } if (slice.Time.Date == new DateTime(2014, 06, 06)) { diff --git a/Algorithm.CSharp/OptionOrdersOnSplitRegressionAlgorithm.cs b/Algorithm.CSharp/OptionOrdersOnSplitRegressionAlgorithm.cs index 08d403d118d7..3f7279580746 100644 --- a/Algorithm.CSharp/OptionOrdersOnSplitRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionOrdersOnSplitRegressionAlgorithm.cs @@ -64,7 +64,7 @@ public override void OnData(Slice slice) _ticket.SubmitRequest.Response.ErrorCode != OrderResponseErrorCode.OptionOrderOnStockSplit || _ticket.SubmitRequest.Response.ErrorMessage != "Options orders are not allowed when a split occurred for its underlying stock") { - throw new Exception( + throw new RegressionTestException( $"Expected invalid order ticket with error code {nameof(OrderResponseErrorCode.OptionOrderOnStockSplit)}, " + $"but received {_ticket.SubmitRequest.Response.ErrorCode} - {_ticket.SubmitRequest.Response.ErrorMessage}"); } @@ -76,7 +76,7 @@ public override void OnEndOfAlgorithm() { if (_ticket == null) { - throw new Exception("Expected invalid order ticket with error code OptionOrderOnStockSplit, but no order was submitted"); + throw new RegressionTestException("Expected invalid order ticket with error code OptionOrderOnStockSplit, but no order was submitted"); } } diff --git a/Algorithm.CSharp/OptionPriceModelForOptionStylesBaseRegressionAlgorithm.cs b/Algorithm.CSharp/OptionPriceModelForOptionStylesBaseRegressionAlgorithm.cs index fc672693e760..75e028a103fd 100644 --- a/Algorithm.CSharp/OptionPriceModelForOptionStylesBaseRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionPriceModelForOptionStylesBaseRegressionAlgorithm.cs @@ -61,7 +61,7 @@ public override void OnEndOfAlgorithm() { if (!_triedGreeksCalculation) { - throw new Exception("Expected greeks to be accessed"); + throw new RegressionTestException("Expected greeks to be accessed"); } } @@ -94,7 +94,7 @@ public void CheckGreeks(OptionChain contracts) // Greeks should have not been successfully accessed if the option style is not supported if (!_optionStyleIsSupported) { - throw new Exception($"Expected greeks not to be calculated for {contract.Symbol.Value}, an {_option.Style} style option, using {_option?.PriceModel.GetType().Name}, which does not support them, but they were"); + throw new RegressionTestException($"Expected greeks not to be calculated for {contract.Symbol.Value}, an {_option.Style} style option, using {_option?.PriceModel.GetType().Name}, which does not support them, but they were"); } } @@ -103,7 +103,7 @@ public void CheckGreeks(OptionChain contracts) // ArgumentException is only expected if the option style is not supported if (_optionStyleIsSupported) { - throw new Exception($"Expected greeks to be calculated for {contract.Symbol.Value}, an {_option.Style} style option, using {_option?.PriceModel.GetType().Name}, which supports them, but they were not"); + throw new RegressionTestException($"Expected greeks to be calculated for {contract.Symbol.Value}, an {_option.Style} style option, using {_option?.PriceModel.GetType().Name}, which supports them, but they were not"); } } @@ -112,7 +112,7 @@ public void CheckGreeks(OptionChain contracts) { if (greeks.Delta == 0m && greeks.Gamma == 0m && greeks.Theta == 0m && greeks.Vega == 0m && greeks.Rho == 0m) { - throw new Exception($"Expected greeks to not be zero simultaneously for {contract.Symbol.Value}, an {_option.Style} style option, using {_option?.PriceModel.GetType().Name}, but they were"); + throw new RegressionTestException($"Expected greeks to not be zero simultaneously for {contract.Symbol.Value}, an {_option.Style} style option, using {_option?.PriceModel.GetType().Name}, but they were"); } // Delta can be {-1, 0, 1} if the price is too wild, rho can be 0 if risk free rate is 0 @@ -121,7 +121,7 @@ public void CheckGreeks(OptionChain contracts) || (contract.Right == OptionRight.Put && (greeks.Delta < -1m || greeks.Delta > 0m || greeks.Rho > 0m)) || greeks.Vega < 0m || greeks.Gamma < 0m)) { - throw new Exception($"Expected greeks to have valid values. Greeks were: Delta: {greeks.Delta}, Rho: {greeks.Rho}, Theta: {greeks.Theta}, Vega: {greeks.Vega}, Gamma: {greeks.Gamma}"); + throw new RegressionTestException($"Expected greeks to have valid values. Greeks were: Delta: {greeks.Delta}, Rho: {greeks.Rho}, Theta: {greeks.Theta}, Vega: {greeks.Vega}, Gamma: {greeks.Gamma}"); } } } diff --git a/Algorithm.CSharp/OptionRenameDailyRegressionAlgorithm.cs b/Algorithm.CSharp/OptionRenameDailyRegressionAlgorithm.cs index a1bada24f703..ce8deb759828 100644 --- a/Algorithm.CSharp/OptionRenameDailyRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionRenameDailyRegressionAlgorithm.cs @@ -62,7 +62,7 @@ public override void OnData(Slice slice) { if (dividend.ReferencePrice != 32.6m || dividend.Distribution != 3.82m) { - throw new Exception($"{Time} - Invalid dividend {dividend}"); + throw new RegressionTestException($"{Time} - Invalid dividend {dividend}"); } } if (!Portfolio.Invested) @@ -88,17 +88,17 @@ public override void OnData(Slice slice) // Check if (slice.Time != new DateTime(2013, 6, 28)) { - throw new Exception(@"Received first contract at {slice.Time}; Expected at 6/28/2013 12AM."); + throw new RegressionTestException(@"Received first contract at {slice.Time}; Expected at 6/28/2013 12AM."); } if (contract.AskPrice != 1.15m) { - throw new Exception("Current ask price was not loaded from NWSA backtest file and is not $1.1"); + throw new RegressionTestException("Current ask price was not loaded from NWSA backtest file and is not $1.1"); } if (contract.UnderlyingSymbol.Value != "NWSA") { - throw new Exception("Contract underlying symbol was not NWSA as expected"); + throw new RegressionTestException("Contract underlying symbol was not NWSA as expected"); } } } @@ -114,7 +114,7 @@ public override void OnData(Slice slice) { if (chain.Underlying.Symbol.Value != "FOXA") { - throw new Exception("Chain underlying symbol was not FOXA as expected"); + throw new RegressionTestException("Chain underlying symbol was not FOXA as expected"); } var contract = @@ -124,7 +124,7 @@ public override void OnData(Slice slice) if (contract.BidPrice != 0.05m) { - throw new Exception("Current bid price was not loaded from FOXA file and is not $0.05"); + throw new RegressionTestException("Current bid price was not loaded from FOXA file and is not $0.05"); } } } diff --git a/Algorithm.CSharp/OptionRenameRegressionAlgorithm.cs b/Algorithm.CSharp/OptionRenameRegressionAlgorithm.cs index 4f6540f52227..9277af867908 100644 --- a/Algorithm.CSharp/OptionRenameRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionRenameRegressionAlgorithm.cs @@ -60,7 +60,7 @@ public override void OnData(Slice slice) { if (dividend.ReferencePrice != 32.6m || dividend.Distribution != 3.82m) { - throw new Exception($"{Time} - Invalid dividend {dividend}"); + throw new RegressionTestException($"{Time} - Invalid dividend {dividend}"); } } if (!Portfolio.Invested) @@ -87,7 +87,7 @@ public override void OnData(Slice slice) // checks if (contract.AskPrice != 1.1m) { - throw new Exception("Regression test failed: current ask price was not loaded from NWSA backtest file and is not $1.1"); + throw new RegressionTestException("Regression test failed: current ask price was not loaded from NWSA backtest file and is not $1.1"); } } } @@ -111,7 +111,7 @@ public override void OnData(Slice slice) if (contract.BidPrice != 0.05m) { - throw new Exception("Regression test failed: current bid price was not loaded from FOXA file and is not $0.05"); + throw new RegressionTestException("Regression test failed: current bid price was not loaded from FOXA file and is not $0.05"); } } } diff --git a/Algorithm.CSharp/OptionSplitRegressionAlgorithm.cs b/Algorithm.CSharp/OptionSplitRegressionAlgorithm.cs index fb285a841ae9..304a74ebd3c4 100644 --- a/Algorithm.CSharp/OptionSplitRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionSplitRegressionAlgorithm.cs @@ -92,11 +92,11 @@ public override void OnData(Slice slice) if (Time.Day == 6 && holdings != 1) { - throw new Exception($"Expected position quantity of 1 but was {holdings.ToStringInvariant()}"); + throw new RegressionTestException($"Expected position quantity of 1 but was {holdings.ToStringInvariant()}"); } if (Time.Day == 9 && holdings != 7) { - throw new Exception($"Expected position quantity of 7 but was {holdings.ToStringInvariant()}"); + throw new RegressionTestException($"Expected position quantity of 7 but was {holdings.ToStringInvariant()}"); } } } diff --git a/Algorithm.CSharp/OptionStrategyFactoryMethodsBaseAlgorithm.cs b/Algorithm.CSharp/OptionStrategyFactoryMethodsBaseAlgorithm.cs index 691f2243eb80..62839d6e921c 100644 --- a/Algorithm.CSharp/OptionStrategyFactoryMethodsBaseAlgorithm.cs +++ b/Algorithm.CSharp/OptionStrategyFactoryMethodsBaseAlgorithm.cs @@ -67,7 +67,7 @@ public override void OnData(Slice slice) var buyingPowerModel = positionGroup.BuyingPowerModel as OptionStrategyPositionGroupBuyingPowerModel; if (buyingPowerModel == null) { - throw new Exception($@"Expected position group buying power model type: {nameof(OptionStrategyPositionGroupBuyingPowerModel) + throw new RegressionTestException($@"Expected position group buying power model type: {nameof(OptionStrategyPositionGroupBuyingPowerModel) }. Actual: {positionGroup.BuyingPowerModel.GetType()}"); } @@ -85,13 +85,13 @@ public override void OnEndOfAlgorithm() { if (Portfolio.Invested) { - throw new Exception("Expected no holdings at end of algorithm"); + throw new RegressionTestException("Expected no holdings at end of algorithm"); } var ordersCount = Transactions.GetOrders((order) => order.Status == OrderStatus.Filled).Count(); if (ordersCount != ExpectedOrdersCount) { - throw new Exception($@"Expected {ExpectedOrdersCount + throw new RegressionTestException($@"Expected {ExpectedOrdersCount } orders to have been submitted and filled, half for buying the strategy and the other half for the liquidation. Actual { ordersCount}"); } diff --git a/Algorithm.CSharp/OptionStrategyMarginCallEventsAlgorithm.cs b/Algorithm.CSharp/OptionStrategyMarginCallEventsAlgorithm.cs index 832c6b29d2fd..3ddcd989e50a 100644 --- a/Algorithm.CSharp/OptionStrategyMarginCallEventsAlgorithm.cs +++ b/Algorithm.CSharp/OptionStrategyMarginCallEventsAlgorithm.cs @@ -87,7 +87,7 @@ public override void OnMarginCall(List requests) var expectedQuantity = -Math.Sign(position.Quantity) * 1; if (request.Quantity != expectedQuantity) { - throw new Exception($"Expected margin call order quantity to be {expectedQuantity} but was {request.Quantity}"); + throw new RegressionTestException($"Expected margin call order quantity to be {expectedQuantity} but was {request.Quantity}"); } } } diff --git a/Algorithm.CSharp/OptionSymbolCanonicalRegressionAlgorithm.cs b/Algorithm.CSharp/OptionSymbolCanonicalRegressionAlgorithm.cs index a9e2e0a6ea53..75b2c772f4bf 100644 --- a/Algorithm.CSharp/OptionSymbolCanonicalRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionSymbolCanonicalRegressionAlgorithm.cs @@ -50,7 +50,7 @@ public override void OnData(Slice slice) { if (!ReferenceEquals(_canonicalOptionContract, _optionContract.Canonical)) { - throw new Exception("Canonical Symbol reference changed!"); + throw new RegressionTestException("Canonical Symbol reference changed!"); } _canonicalOptionContract = _optionContract.Canonical; diff --git a/Algorithm.CSharp/OptionTimeSliceRegressionAlgorithm.cs b/Algorithm.CSharp/OptionTimeSliceRegressionAlgorithm.cs index 1300a7309c52..59605440f31b 100644 --- a/Algorithm.CSharp/OptionTimeSliceRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OptionTimeSliceRegressionAlgorithm.cs @@ -47,7 +47,7 @@ public override void OnData(Slice data) // Because of issues with Delisting data we have to let Auxiliary data pass through GH #5207 if (Time.Ticks - _lastSliceTime.Ticks < 1000 && data.Values.Any(x => x.DataType != MarketDataType.Auxiliary)) { - throw new Exception($"Emitted two slices within 1000 ticks of each other."); + throw new RegressionTestException($"Emitted two slices within 1000 ticks of each other."); } // Store our slice time @@ -69,7 +69,7 @@ public override void OnEndOfAlgorithm() { if (_optionSymbol == null) { - throw new Exception("No option symbol was added!"); + throw new RegressionTestException("No option symbol was added!"); } } diff --git a/Algorithm.CSharp/OptionsExpiredContractRegression.cs b/Algorithm.CSharp/OptionsExpiredContractRegression.cs index 1688ae177e28..ca2f813405d7 100644 --- a/Algorithm.CSharp/OptionsExpiredContractRegression.cs +++ b/Algorithm.CSharp/OptionsExpiredContractRegression.cs @@ -53,7 +53,7 @@ public override void OnData(Slice data) { if (contract.Expiry.Date < Time.Date) { - throw new Exception($"Received expired contract {contract} expired: {contract.Expiry} current time: {Time}"); + throw new RegressionTestException($"Received expired contract {contract} expired: {contract.Expiry} current time: {Time}"); } } } @@ -63,7 +63,7 @@ public override void OnEndOfAlgorithm() { if (!_receivedData) { - throw new Exception("No Options chains were received in this regression"); + throw new RegressionTestException("No Options chains were received in this regression"); } } diff --git a/Algorithm.CSharp/OptionsMarginCallEventsAlgorithmBase.cs b/Algorithm.CSharp/OptionsMarginCallEventsAlgorithmBase.cs index 26e3b086118a..35efe2d4722f 100644 --- a/Algorithm.CSharp/OptionsMarginCallEventsAlgorithmBase.cs +++ b/Algorithm.CSharp/OptionsMarginCallEventsAlgorithmBase.cs @@ -57,7 +57,7 @@ public override void OnOrderEvent(OrderEvent orderEvent) // the check in the OnEndOfAlgorithm method to be accurate. if (orderEvent.Quantity != OriginalQuantity) { - throw new Exception($"Expected order quantity to be {OriginalQuantity} but was {orderEvent.Quantity}"); + throw new RegressionTestException($"Expected order quantity to be {OriginalQuantity} but was {orderEvent.Quantity}"); } } } @@ -66,34 +66,34 @@ public override void OnEndOfAlgorithm() { if (!Portfolio.Invested) { - throw new Exception("Portfolio should be invested"); + throw new RegressionTestException("Portfolio should be invested"); } if (_onMarginCallCount != 1) { - throw new Exception($"OnMarginCall was called {_onMarginCallCount} times, expected 1"); + throw new RegressionTestException($"OnMarginCall was called {_onMarginCallCount} times, expected 1"); } if (_onMarginCallWarningCount == 0) { - throw new Exception("OnMarginCallWarning was not called"); + throw new RegressionTestException("OnMarginCallWarning was not called"); } var orders = Transactions.GetOrders().ToList(); if (orders.Count != ExpectedOrdersCount) { - throw new Exception($"Expected {ExpectedOrdersCount} orders, found {orders.Count}"); + throw new RegressionTestException($"Expected {ExpectedOrdersCount} orders, found {orders.Count}"); } if (orders.Any(order => !order.Status.IsFill())) { - throw new Exception("All orders should be filled"); + throw new RegressionTestException("All orders should be filled"); } var finalStrategyQuantity = Portfolio.Positions.Groups.First().Quantity; if (Math.Abs(OriginalQuantity) <= Math.Abs(finalStrategyQuantity)) { - throw new Exception($@"Strategy position group quantity should have been decreased from the original quantity {OriginalQuantity + throw new RegressionTestException($@"Strategy position group quantity should have been decreased from the original quantity {OriginalQuantity }, but was {finalStrategyQuantity}"); } } diff --git a/Algorithm.CSharp/OrderImmutabilityRegressionAlgorithm.cs b/Algorithm.CSharp/OrderImmutabilityRegressionAlgorithm.cs index 78bf0c37a184..49889a6e3e50 100644 --- a/Algorithm.CSharp/OrderImmutabilityRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OrderImmutabilityRegressionAlgorithm.cs @@ -69,7 +69,7 @@ public override void OnData(Slice data) if (_originalOrder.Time != UtcTime) { Error("Order Time should be UtcTime!"); - throw new Exception("Order Time should be UtcTime!"); + throw new RegressionTestException("Order Time should be UtcTime!"); } } } @@ -90,7 +90,7 @@ public override void OnOrderEvent(OrderEvent orderEvent) if (orderV1 == orderV2) { Error("Orders should be clones, hence not equal!"); - throw new Exception("Orders should be clones, hence not equal!"); + throw new RegressionTestException("Orders should be clones, hence not equal!"); } // Try and manipulate orderV2 using the only external accessor BrokerID, since we @@ -101,7 +101,7 @@ public override void OnOrderEvent(OrderEvent orderEvent) if (orderV2.BrokerId.SequenceEqual(orderV3.BrokerId)) { Error("Broker IDs should not be the same!"); - throw new Exception("Broker IDs should not be the same!"); + throw new RegressionTestException("Broker IDs should not be the same!"); } //Try and manipulate the orderV1 using UpdateOrderRequest @@ -114,13 +114,13 @@ public override void OnOrderEvent(OrderEvent orderEvent) if (orderV4.Quantity == orderV1.Quantity) { Error("Order quantity should not be the same!"); - throw new Exception("Order quantity should not be the same!"); + throw new RegressionTestException("Order quantity should not be the same!"); } if (orderV4.Tag == orderV1.Tag) { Error("Order tag should not be the same!"); - throw new Exception("Order tag should not be the same!"); + throw new RegressionTestException("Order tag should not be the same!"); } } @@ -136,13 +136,13 @@ public override void OnEndOfAlgorithm() if (updatedOrder.Quantity == _originalOrder.Quantity) { Error("Quantities should have been updated!"); - throw new Exception("Quantities should have been updated!"); + throw new RegressionTestException("Quantities should have been updated!"); } if (updatedOrder.Tag == _originalOrder.Tag) { Error("Tag should have been updated!"); - throw new Exception("Tag should have been updated!"); + throw new RegressionTestException("Tag should have been updated!"); } } diff --git a/Algorithm.CSharp/OrderSubmissionDataRegressionAlgorithm.cs b/Algorithm.CSharp/OrderSubmissionDataRegressionAlgorithm.cs index 37e319783bba..54e8a562ea9c 100644 --- a/Algorithm.CSharp/OrderSubmissionDataRegressionAlgorithm.cs +++ b/Algorithm.CSharp/OrderSubmissionDataRegressionAlgorithm.cs @@ -54,7 +54,7 @@ private void PlaceTrade(string ticker) var data = order.OrderSubmissionData; if (data == null || data.AskPrice == 0 || data.BidPrice == 0 || data.LastPrice == 0) { - throw new Exception("Invalid Order Submission data detected"); + throw new RegressionTestException("Invalid Order Submission data detected"); } if (_orderSubmissionData.ContainsKey(ticker)) @@ -62,7 +62,7 @@ private void PlaceTrade(string ticker) var previous = _orderSubmissionData[ticker]; if (previous.AskPrice == data.AskPrice || previous.BidPrice == data.BidPrice || previous.LastPrice == data.LastPrice) { - throw new Exception("Order Submission data didn't change"); + throw new RegressionTestException("Order Submission data didn't change"); } } _orderSubmissionData[ticker] = data; diff --git a/Algorithm.CSharp/OrderTicketAssignmentDemoAlgorithm.cs b/Algorithm.CSharp/OrderTicketAssignmentDemoAlgorithm.cs index 67fbb66e586d..f3ee97ca3546 100644 --- a/Algorithm.CSharp/OrderTicketAssignmentDemoAlgorithm.cs +++ b/Algorithm.CSharp/OrderTicketAssignmentDemoAlgorithm.cs @@ -59,11 +59,11 @@ public override void OnOrderEvent(OrderEvent orderEvent) var ticket = orderEvent.Ticket; if (ticket == null) { - throw new Exception("Expected order ticket in order event to not be null"); + throw new RegressionTestException("Expected order ticket in order event to not be null"); } if (orderEvent.Status == OrderStatus.Submitted && _ticket != null) { - throw new Exception("Field _ticket not expected no be assigned on the first order event"); + throw new RegressionTestException("Field _ticket not expected no be assigned on the first order event"); } Debug(ticket.ToString()); @@ -74,7 +74,7 @@ public override void OnEndOfAlgorithm() // Just checking that orders were placed if (!Portfolio.Invested || _tradeCount != Transactions.OrdersCount) { - throw new Exception($"Expected the portfolio to have holdings and to have {_tradeCount} trades, but had {Transactions.OrdersCount}"); + throw new RegressionTestException($"Expected the portfolio to have holdings and to have {_tradeCount} trades, but had {Transactions.OrdersCount}"); } } diff --git a/Algorithm.CSharp/OrderTicketDemoAlgorithm.cs b/Algorithm.CSharp/OrderTicketDemoAlgorithm.cs index 0bed8ead88b4..ba2feab0f4f6 100644 --- a/Algorithm.CSharp/OrderTicketDemoAlgorithm.cs +++ b/Algorithm.CSharp/OrderTicketDemoAlgorithm.cs @@ -513,30 +513,30 @@ public override void OnOrderEvent(OrderEvent orderEvent) if (orderEvent.Quantity == 0) { - throw new Exception("OrderEvent quantity is Not expected to be 0, it should hold the current order Quantity"); + throw new RegressionTestException("OrderEvent quantity is Not expected to be 0, it should hold the current order Quantity"); } if (orderEvent.Quantity != order.Quantity) { - throw new Exception("OrderEvent quantity should hold the current order Quantity"); + throw new RegressionTestException("OrderEvent quantity should hold the current order Quantity"); } if (order is LimitOrder && orderEvent.LimitPrice == 0 || order is StopLimitOrder && orderEvent.LimitPrice == 0) { - throw new Exception("OrderEvent LimitPrice is Not expected to be 0 for LimitOrder and StopLimitOrder"); + throw new RegressionTestException("OrderEvent LimitPrice is Not expected to be 0 for LimitOrder and StopLimitOrder"); } if (order is StopMarketOrder && orderEvent.StopPrice == 0) { - throw new Exception("OrderEvent StopPrice is Not expected to be 0 for StopMarketOrder"); + throw new RegressionTestException("OrderEvent StopPrice is Not expected to be 0 for StopMarketOrder"); } // We can access the order ticket from the order event if (orderEvent.Ticket == null) { - throw new Exception("OrderEvent Ticket was not set"); + throw new RegressionTestException("OrderEvent Ticket was not set"); } if (orderEvent.OrderId != orderEvent.Ticket.OrderId) { - throw new Exception("OrderEvent.OrderId and orderEvent.Ticket.OrderId do not match"); + throw new RegressionTestException("OrderEvent.OrderId and orderEvent.Ticket.OrderId do not match"); } } @@ -574,15 +574,15 @@ public override void OnEndOfAlgorithm() if (filledOrders.Count() != 9 || orderTickets.Count() != 12) { - throw new Exception($"There were expected 9 filled orders and 12 order tickets"); + throw new RegressionTestException($"There were expected 9 filled orders and 12 order tickets"); } if (openOrders.Count != 0 || openOrderTickets.Any()) { - throw new Exception($"No open orders or tickets were expected"); + throw new RegressionTestException($"No open orders or tickets were expected"); } if (remainingOpenOrders != 0m) { - throw new Exception($"No remaining quantity to be filled from open orders was expected"); + throw new RegressionTestException($"No remaining quantity to be filled from open orders was expected"); } var symbolOpenOrders = Transactions.GetOpenOrders(symbol).Count; @@ -591,11 +591,11 @@ public override void OnEndOfAlgorithm() if (symbolOpenOrders != 0 || symbolOpenOrdersTickets != 0) { - throw new Exception($"No open orders or tickets were expected"); + throw new RegressionTestException($"No open orders or tickets were expected"); } if (symbolOpenOrdersRemainingQuantity != 0) { - throw new Exception($"No remaining quantity to be filled from open orders was expected"); + throw new RegressionTestException($"No remaining quantity to be filled from open orders was expected"); } var defaultOrders = Transactions.GetOrders(); @@ -606,15 +606,15 @@ public override void OnEndOfAlgorithm() if (defaultOrders.Count() != 12 || defaultOrderTickets.Count() != 12) { - throw new Exception($"There were expected 12 orders and 12 order tickets"); + throw new RegressionTestException($"There were expected 12 orders and 12 order tickets"); } if (defaultOpenOrders.Count != 0 || defaultOpenOrderTickets.Any()) { - throw new Exception($"No open orders or tickets were expected"); + throw new RegressionTestException($"No open orders or tickets were expected"); } if (defaultOpenOrdersRemaining != 0m) { - throw new Exception($"No remaining quantity to be filled from open orders was expected"); + throw new RegressionTestException($"No remaining quantity to be filled from open orders was expected"); } } diff --git a/Algorithm.CSharp/PearsonCorrelationPairsTradingAlphaModelFrameworkAlgorithm.cs b/Algorithm.CSharp/PearsonCorrelationPairsTradingAlphaModelFrameworkAlgorithm.cs index ea71f08a02e4..4086409ae956 100644 --- a/Algorithm.CSharp/PearsonCorrelationPairsTradingAlphaModelFrameworkAlgorithm.cs +++ b/Algorithm.CSharp/PearsonCorrelationPairsTradingAlphaModelFrameworkAlgorithm.cs @@ -62,7 +62,7 @@ public override void OnEndOfAlgorithm() var consolidatorCount = SubscriptionManager.Subscriptions.Sum(s => s.Consolidators.Count); if (consolidatorCount > 0) { - throw new Exception($"The number of consolidator is should be zero. Actual: {consolidatorCount}"); + throw new RegressionTestException($"The number of consolidator is should be zero. Actual: {consolidatorCount}"); } } diff --git a/Algorithm.CSharp/PeriodBasedHistoryRequestNotAllowedWithTickResolutionRegressionAlgorithm.cs b/Algorithm.CSharp/PeriodBasedHistoryRequestNotAllowedWithTickResolutionRegressionAlgorithm.cs index 7bf03bf2957f..e3fa24356945 100644 --- a/Algorithm.CSharp/PeriodBasedHistoryRequestNotAllowedWithTickResolutionRegressionAlgorithm.cs +++ b/Algorithm.CSharp/PeriodBasedHistoryRequestNotAllowedWithTickResolutionRegressionAlgorithm.cs @@ -46,13 +46,13 @@ public override void Initialize() var history = History(spy, TimeSpan.FromHours(12)); if (history.Count() == 0) { - throw new Exception("On history call with implicit tick resolution: history returned no results"); + throw new RegressionTestException("On history call with implicit tick resolution: history returned no results"); } history = History(spy, TimeSpan.FromHours(12), Resolution.Tick); if (history.Count() == 0) { - throw new Exception("On history call with explicit tick resolution: history returned no results"); + throw new RegressionTestException("On history call with explicit tick resolution: history returned no results"); } } @@ -61,7 +61,7 @@ private void AssertThatHistoryThrowsForTickResolution(Action historyCall, string try { historyCall(); - throw new Exception($"{historyCallDescription}: expected an exception to be thrown"); + throw new RegressionTestException($"{historyCallDescription}: expected an exception to be thrown"); } catch (InvalidOperationException) { diff --git a/Algorithm.CSharp/PeriodConsolidatorRegressionAlgorithm.cs b/Algorithm.CSharp/PeriodConsolidatorRegressionAlgorithm.cs index 986252ea051b..cfc8696588ab 100644 --- a/Algorithm.CSharp/PeriodConsolidatorRegressionAlgorithm.cs +++ b/Algorithm.CSharp/PeriodConsolidatorRegressionAlgorithm.cs @@ -59,7 +59,7 @@ public override void OnEndOfAlgorithm() { if (_countConsolidation.Count == 0 || _countConsolidation.Count != _periodConsolidation.Count) { - throw new Exception($"Unexpected consolidated data count. Period: {_periodConsolidation.Count} Count: {_countConsolidation.Count}"); + throw new RegressionTestException($"Unexpected consolidated data count. Period: {_periodConsolidation.Count} Count: {_countConsolidation.Count}"); } while (_countConsolidation.TryDequeue(out var countData)) @@ -67,7 +67,7 @@ public override void OnEndOfAlgorithm() var periodData = _periodConsolidation.Dequeue(); if (periodData != countData) { - throw new Exception($"Unexpected consolidated data. Period: '{periodData}' != Count: '{countData}'"); + throw new RegressionTestException($"Unexpected consolidated data. Period: '{periodData}' != Count: '{countData}'"); } } _periodConsolidation.Clear(); diff --git a/Algorithm.CSharp/PortfolioRebalanceOnCustomFuncRegressionAlgorithm.cs b/Algorithm.CSharp/PortfolioRebalanceOnCustomFuncRegressionAlgorithm.cs index 0d4f3d960ea0..64e7691ca8c7 100644 --- a/Algorithm.CSharp/PortfolioRebalanceOnCustomFuncRegressionAlgorithm.cs +++ b/Algorithm.CSharp/PortfolioRebalanceOnCustomFuncRegressionAlgorithm.cs @@ -105,7 +105,7 @@ public override void OnOrderEvent(OrderEvent orderEvent) { if (UtcTime - _lastRebalanceTime > TimeSpan.Zero || UtcTime.DayOfWeek != DayOfWeek.Monday) { - throw new Exception($"{UtcTime} {orderEvent.Symbol} {UtcTime - _lastRebalanceTime}"); + throw new RegressionTestException($"{UtcTime} {orderEvent.Symbol} {UtcTime - _lastRebalanceTime}"); } } } diff --git a/Algorithm.CSharp/PortfolioRebalanceOnDateRulesRegressionAlgorithm.cs b/Algorithm.CSharp/PortfolioRebalanceOnDateRulesRegressionAlgorithm.cs index 496a0445714b..5d76e476a17c 100644 --- a/Algorithm.CSharp/PortfolioRebalanceOnDateRulesRegressionAlgorithm.cs +++ b/Algorithm.CSharp/PortfolioRebalanceOnDateRulesRegressionAlgorithm.cs @@ -67,7 +67,7 @@ public override void OnOrderEvent(OrderEvent orderEvent) Debug($"{orderEvent}"); if (UtcTime.DayOfWeek != DayOfWeek.Wednesday) { - throw new Exception($"{UtcTime} {orderEvent.Symbol} {UtcTime.DayOfWeek}"); + throw new RegressionTestException($"{UtcTime} {orderEvent.Symbol} {UtcTime.DayOfWeek}"); } } } diff --git a/Algorithm.CSharp/PortfolioRebalanceOnInsightChangesRegressionAlgorithm.cs b/Algorithm.CSharp/PortfolioRebalanceOnInsightChangesRegressionAlgorithm.cs index b69b5d1da0cc..9189252fba5b 100644 --- a/Algorithm.CSharp/PortfolioRebalanceOnInsightChangesRegressionAlgorithm.cs +++ b/Algorithm.CSharp/PortfolioRebalanceOnInsightChangesRegressionAlgorithm.cs @@ -67,7 +67,7 @@ public override void OnOrderEvent(OrderEvent orderEvent) { if (UtcTime - lastOrderFilled < TimeSpan.FromDays(30)) { - throw new Exception($"{UtcTime} {orderEvent.Symbol} {UtcTime - lastOrderFilled}"); + throw new RegressionTestException($"{UtcTime} {orderEvent.Symbol} {UtcTime - lastOrderFilled}"); } } _lastOrderFilled[orderEvent.Symbol] = UtcTime; diff --git a/Algorithm.CSharp/PortfolioRebalanceOnSecurityChangesRegressionAlgorithm.cs b/Algorithm.CSharp/PortfolioRebalanceOnSecurityChangesRegressionAlgorithm.cs index 55ce95fd3c2c..de96db260e46 100644 --- a/Algorithm.CSharp/PortfolioRebalanceOnSecurityChangesRegressionAlgorithm.cs +++ b/Algorithm.CSharp/PortfolioRebalanceOnSecurityChangesRegressionAlgorithm.cs @@ -76,7 +76,7 @@ public override void OnOrderEvent(OrderEvent orderEvent) { if (UtcTime - lastOrderFilled < TimeSpan.FromDays(30)) { - throw new Exception($"{UtcTime} {orderEvent.Symbol} {UtcTime - lastOrderFilled}"); + throw new RegressionTestException($"{UtcTime} {orderEvent.Symbol} {UtcTime - lastOrderFilled}"); } } _lastOrderFilled[orderEvent.Symbol] = UtcTime; @@ -91,7 +91,7 @@ public override void OnEndOfAlgorithm() { // The number of insights is modified by the Portfolio Construction Model, // since it removes expired insights and insights from removed securities - throw new Exception($"The number of insights in the insight manager should be different of the number of all insights generated ({_generatedInsightsCount})"); + throw new RegressionTestException($"The number of insights in the insight manager should be different of the number of all insights generated ({_generatedInsightsCount})"); } }