/// <summary> /// Get the setup handler for this algorithm, depending on its use case. /// </summary> /// <param name="setupMethod">Setup handler</param> /// <returns>Instance of a setup handler:</returns> private static ISetupHandler GetSetupHandler(SetupHandlerEndpoint setupMethod) { var sh = default(ISetupHandler); if (IsLocal) { return(new ConsoleSetupHandler()); } switch (setupMethod) { //Setup console handler: case SetupHandlerEndpoint.Console: sh = new ConsoleSetupHandler(); Log.Trace("Engine.GetSetupHandler(): Selected Console Algorithm Setup Handler."); break; //Default, backtesting result handler: case SetupHandlerEndpoint.Backtesting: sh = new BacktestingSetupHandler(); Log.Trace("Engine.GetSetupHandler(): Selected Backtesting Algorithm Setup Handler."); break; case SetupHandlerEndpoint.PaperTrading: sh = new PaperTradingSetupHandler(); Log.Trace("Engine.GetSetupHandler(): Selected PaperTrading Algorithm Setup Handler."); break; } return(sh); }
public void HandlesErrorOnInitializeCorrectly() { var setupHandler = new BacktestingSetupHandler(); Assert.IsFalse(setupHandler.Setup(new SetupHandlerParameters(_dataManager.UniverseSelection, _algorithm, null, new BacktestNodePacket(), new TestResultHandler(), null, new BacktestingRealTimeHandler(), null, TestGlobals.DataProvider))); setupHandler.DisposeSafely(); Assert.AreEqual(1, setupHandler.Errors.Count); Assert.IsTrue(setupHandler.Errors[0].InnerException.Message.Equals("Some failure")); }