static void generateCurves(LiveSystem system, IEnumerable <JMarket> markets, QDirectory directory, DateTime start, DateTime end, DataSource metricSource) { var symbols = convert(markets, market => new Symbol(market.name(), market.bigPointValue())); var parameters = new Parameters { { "systemId", system.id() }, { "RunMode", (double)RunMode.LIVE } }; var startLoading = DateTime.Now; Bomb.when(system.details().runInNativeCurrency(), () => "portfolio optimization requires systems to run in dollars, not native currency"); var bars = new SystemDbBarLoader(system.details().interval(), symbols, start, end); var simulator = new Simulator(new SystemArguments(symbols, parameters), bars, "QUEDGE"); var startProcessing = DateTime.Now; var perSecond = simulator.processBars(); saveMetric(system, "marketBarsPerSecond", metricSource, perSecond); var startMetricCalc = DateTime.Now; simulator.metrics(); saveMetric(system, "metricCalculationSeconds", metricSource, secondsSince(startMetricCalc)); saveMetric(system, "totalRunSeconds", metricSource, secondsSince(startProcessing)); simulator.writeCurveFiles(directory); saveMetric(system, "totaSeconds", metricSource, secondsSince(startLoading)); Db.commit(); }
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); } }