def setUp(self): """ Set up configuration. """ #self.config = settings.TEST self.config = Config() self.testing = True
end_date, events_queue, session_type="backtest", name="strategy1", #benchmark=tickers[1], title=title) results = backtest.start_trading(testing=testing) #print(type(backtest)) return results if __name__ == "__main__": # Configuration data testing = False #config = settings.from_file(settings.DEFAULT_CONFIG_FILENAME, testing) conf = Config() ticker_list = ["AAPL", "ADI", "SPY"] ##bencht = "SPY" ##tickers = ["PEP", "PM"] filename = None eva = Evaluation() for t in ticker_list: tickers = [] tickers.append(t) #tickers.append(bencht) rt = run(conf, testing, tickers, filename) eva.add_result(t, rt) print("===================") df_csv = pd.DataFrame()
strategy = MovingAverageCrossStrategy(tickers[0], events_queue, short_window=100, long_window=300) # Set up the backtest backtest = TradingSession( config, strategy, tickers, initial_equity, start_date, end_date, events_queue, name="strategy1", title=title, benchmark=tickers[1], ) results = backtest.start_trading(testing=testing) return results if __name__ == "__main__": # Configuration data testing = False #config = settings.from_file(settings.DEFAULT_CONFIG_FILENAME, testing) conf = Config() tickers = ["AAPL", "SPY"] filename = None run(conf, testing, tickers, filename)