Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public Simulator.Simulator newSimulator(Action <Collectible, PlotDefinition> addPlot)
        {
            var args = new SystemArguments(symbols(), parameters)
            {
                runInNativeCurrency = runInNativeCurrency
            };

            args.newPlotRequest += addPlot;
            return(new Simulator.Simulator(args, loader(args.interval()), "UNUSEDHOPEFULLY"));
        }
Ejemplo n.º 3
0
 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();
 }
Ejemplo n.º 4
0
 public Simulator(SystemArguments args, string topicPrefix) : this(args, new SystemDbBarLoader(args.interval(), args.symbols), topicPrefix)
 {
 }