Example #1
0
        public static void Main(string[] args)
        {
            Directory.CreateDirectory(@"E:\logs");
            LogC.setOut("STOServer", @"E:\logs\STOServer." + processId() + ".log", true);
            LogC.setErr(@"E:\logs\STOServer." + processId() + ".error.log");
            AppDomain.CurrentDomain.UnhandledException += handleUncaughtExceptions;
            S3Cache.setDefaultSqsDbMode(true);
            if (!(hostname().StartsWith("NY") || hostname().StartsWith("LN")))
            {
                QHttpClient.turnOffProxy();
            }
            var runner = EC2Runner.fromUserData();

            S3Cache.setS3Cache(runner.s3Cache());
            var lastRunTime = 120;

            while (trueDat())
            {
                info("lastRunTime: " + lastRunTime);
                STORequest request = null;
                try {
                    lastRunTime = processNextMessage(runner, lastRunTime, out request);
                } catch (Exception e) {
                    LogC.err("failed " + request, e);
                    LogC.info("failed " + request, e);
                    continue;
                }
                info("finished " + request);
            }
        }
Example #2
0
            void runOneLocal()
            {
                LogC.info("running run " + start + " local to populate S3 cache");
                S3Cache.saveAllQueryResultsToS3(true);
                var s3Cache = runner.s3Cache();

                s3Cache.createBucket();
                S3Cache.setS3Cache(s3Cache);
                var runParameters = parameters(start);
                var symbolRanges  = dictionary(symbols, symbol => MsivBacktestTable.BACKTEST.range(systemId, symbol.name));
                var data          = new SystemDbBarLoader(details.interval(), symbols, symbolRanges);
                var simulator     = new Simulator.Simulator(new SystemArguments(symbols, portfolios, runParameters), data, "QUEDGE");

                simulator.processBars();
                simulator.shutdown();
                S3Cache.saveAllQueryResultsToS3(false);
            }
Example #3
0
        public static void Main(string[] inArgs)
        {
            var args = Arguments.arguments(inArgs, jStrings("symbols", "run", "systemId", "noShutdown", "useS3"));
            var id   = args.integer("systemId");
            var run  = args.integer("run");

            if (args.get("useS3", false))
            {
                // populate param cache before switching to s3 mode
                new Parameters {
                    { "systemId", id }, { "RunNumber", run }, { "RunMode", (double)RunMode.STO }
                }.load();
                LogC.info("using S3 Cache - " + id);
                S3Cache.setDefaultSqsDbMode(true);
                S3Cache.setS3Cache(new EC2Runner("" + id).s3Cache());
            }
            var shutdown = !args.get("noShutdown", false);
            var details  = SystemDetailsTable.DETAILS.details(id);

            List <Symbol> symbols;
            List <Trading.Results.Portfolio> portfolios;

            if (args.containsKey("symbols"))
            {
                var names = split(",", args.@string("symbols"));
                symbols    = list(STO.symbols(names));
                portfolios = list <Trading.Results.Portfolio>();
            }
            else
            {
                STO.populateSymbolsPortfolios(details, out symbols, out portfolios);
            }

            var data = STO.loader(details, symbols);

            STO.run(details.id(), symbols, portfolios, run, data, false, shutdown);
        }