Esempio n. 1
0
        public static void populateSymbolsPortfolios(SystemDetailsTable.SystemDetails details, out List <Symbol> symbols, out List <Trading.Results.Portfolio> portfolios)
        {
            var marketNames = list <string>(MsivBacktestTable.BACKTEST.markets(details.siv(), details.stoId()));

            symbols    = list(STO.symbols(marketNames));
            portfolios = list <sto.Portfolio, Trading.Results.Portfolio>(sto.Portfolio.portfolios(details.id()), j => new Trading.Results.Portfolio(j));
        }
Esempio n. 2
0
        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);
        }
Esempio n. 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);
        }