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 void Main(string[] args) { var arguments = Arguments.arguments(args, jStrings("markets", "start", "end", "out", "calculator", "interval")); var names = split(",", arguments.@string("markets")); var symbols = list(STO.symbols(names)); if (arguments.containsKey("calculator")) { var calculator = Type.GetType(arguments.@string("calculator")); each(symbols, symbol => symbol.overrideSlippageCalculator(calculator)); } var start = arguments.get("start", ""); var end = arguments.get("end", ""); var outFile = new QFile(arguments.@string("out")); var range = new Range(isEmpty(start) ? null : Dates.date(start), isEmpty(end) ? null : Dates.date(end)); var loader = new SystemDbBarLoader(Interval.lookup(arguments.@string("interval")), symbols, dictionary(symbols, s => range)); var csv = new Csv(); var columns = list("date"); columns.AddRange(convert(symbols, s => s.name)); csv.addHeader(jList(columns)); for (var i = 0; i < loader.numDates(); i++) { var time = loader.date(i); var record = list(ymdHuman(time)); var slippages = loader.currentSlippages(time); each(symbols, s => record.Add(slippages.ContainsKey(s) ? slippages[s].ToString("N12") : "NA")); csv.add(jList(record)); } csv.overwrite(outFile); }
public static void Main(string[] args) { var arguments = Arguments.arguments(args, jStrings("system", "prefix")); var system = arguments.get("system"); var prefix = arguments.get("prefix", PREFIX_DEFAULT); LogC.setOut("Tomahawk", Systematic.logsDir().file("Tomahawk." + system + ".log").path(), true); LogC.useJavaLog = true; LogC.info("running system " + system + ", process " + processId()); var liveSystems = accept(list <LiveSystem>(MsivLiveHistory.LIVE.liveSystems()), ls => ls.siv().system().Equals(system)); each(liveSystems, liveSystem => { Bomb.when(liveSystem.details().runInNativeCurrency(), () => "not allowed to run live systems in native currency"); var markets = list <Market>(liveSystem.markets()); var symbols = convert(markets, market => new Symbol(market.name(), market.bigPointValue())); var systemId = liveSystem.id(); var parameters = new Parameters { { "systemId", systemId }, { "RunMode", (double)RunMode.LIVE } }; Bomb.when(isEmpty(symbols), () => "No markets for " + systemId); var systemArguments = new SystemArguments(symbols, parameters); var start = date(systemArguments.interval().isDaily() ? BloombergSecurity.BBG_START_HISTORICAL : BloombergSecurity.BBG_START_INTRADAY); if (parameters.has("DaysBack")) { start = now().AddDays(-parameters.get <int>("DaysBack")); } var loader = new SystemDbBarLoader(liveSystem.details().interval(), symbols, start); var simulator = new Simulator(systemArguments, loader, prefix); simulator.processBars(); simulator.goLive(); }); sleep(Int32.MaxValue); }
public void testNBarFade() { O.freezeNow("2009/03/10"); var symbol = new Symbol("RE.TEST.TY.1C", 1000); var args = new SystemArguments(symbol, new Parameters { { "systemId", 133486 }, { "RunMode", (double)RunMode.RIGHTEDGE }, { "LeadBars", 50 }, { "ATRLen", 5 }, { "nDays", 6 }, { "nATRentry", 1.5 }, { "exitATRmultiple", 1 }, { "stopAfStep", 0.02 }, { "stopAfMax", 0.2 }, { "entryBarWindow", 2 }, { "closeBetter", 1 }, { "riskDollars", 100000000 } }); var loader = new SystemDbBarLoader(Interval.DAILY, O.list(symbol), date("2003/01/01")); var simulator = new Simulator(args, loader, OrderTable.prefix); simulator.processBars(); }