public Simulator(SystemArguments args, BarLoader data, string topicPrefix) { newBarListeners = new LazyDictionary <Symbol, Action <Bar> >(symbol => doNothing); this.data = data; symbols = args.symbols; bridge = args.bridgeBase(topicPrefix); dateIndex = 0; processBarComplete += doNothing; interval = args.interval(); }
public static Simulator run(int systemId, IEnumerable <Symbol> symbols, IEnumerable <QPortfolio> portfolios, int runNumber, BarLoader data, bool dumpParamsOnly, bool shutdown) { var parameters = new Parameters { { "systemId", systemId }, { "RunMode", (double)RunMode.STO }, { "RunNumber", runNumber } }; try { parameters.runNumber(); LogC.err("" + parameters); if (dumpParamsOnly) { return(null); } var simulator = new Simulator(new SystemArguments(symbols, portfolios, parameters), data, "QUEDGE"); simulator.processBars(); if (shutdown) { simulator.shutdown(); } else { var metrics = simulator.metrics(); LogC.verbose(() => "skipping shutdown based on noShutdown parameter."); LogC.verbose(() => toShortString(metrics["ALL"])); } return(simulator); } catch (Exception e) { throw Bomb.toss("\nFailed in run " + runNumber + "\nUsing:\n" + parameters + "\n", e); } }