Beispiel #1
0
 public void insertInto(LiveSystem system)
 {
     foreach (var entry in data)
     {
         system.insertParameter(entry.Key, entry.Value);
     }
 }
Beispiel #2
0
        public void testIntraDayLiveBars()
        {
            var siv5Minute = new Siv("TestSystem1", "second", "1.0");
            var liveSystem = new LiveSystem(siv5Minute, FAST);

            liveSystem.insertParameter("LeadBars", "0");
            var args      = arguments(O.list(SYMBOL, SYMBOL2), liveSystem, RunMode.LIVE, typeof(EmptySystem));
            var loader    = new FakeBarLoader(SYMBOL, SYMBOL2);
            var simulator = loader.simulator(args, OrderTable.prefix);

            try {
                Action <int, int> bar = (close, minutesAfter9) => {
                    var barTime = Dates.minutesAhead(minutesAfter9, Dates.date("2008/09/08 09:00:00"));
                    loader.add(SYMBOL, close, close, close, close, barTime);
                    loader.add(SYMBOL2, close, close, close, close, barTime);
                    simulator.nextBar();
                };
                Action <Symbol, int, string> doTick = (symbol, price, time) => {
                    O.freezeNow("2008/09/08 " + time);
                    tick(simulator, new Bar(0, price, 0, price, O.now()), symbol);
                };
                bar(5, 0);
                O.freezeNow("2008/09/08 09:00:00");
                simulator.goLive();
                doTick(SYMBOL, 26, "09:00:00");
                doTick(SYMBOL2, 28, "09:00:00");
                doTick(SYMBOL, 25, "09:00:00");
                doTick(SYMBOL2, 29, "09:00:00");
                simulator.waitForBar();
                var system  = simulator.theSymbolSystem <EmptySystem>(SYMBOL);
                var system2 = simulator.theSymbolSystem <EmptySystem>(SYMBOL2);
                AreEqual(new Bar(26, 26, 25, 25, date("2008/09/08 09:00:00")), system.bar);
                AreEqual(new Bar(28, 29, 28, 29, date("2008/09/08 09:00:00")), system2.bar);
                O.freezeNow("2008/09/08 09:00:01");
                doTick(SYMBOL, 42, "09:00:01");
                doTick(SYMBOL, 57, "09:00:01");
                doTick(SYMBOL, 15, "09:00:01");
                system.placeOrder(SYMBOL.buy("somethin", Order.market(), 1, FillOrKill.FILL_KILL));
                simulator.waitForBar(); // if it blows up in orderFilled here, it filled orders during live intraday bar (incorrect)
                IsTrue(O.isEmpty(system.allPositions()));
                AreEqual(new Bar(42, 57, 15, 15, date("2008/09/08 09:00:01")), system.bar);
                AreEqual(new Bar(28, 29, 28, 29, date("2008/09/08 09:00:00")), system2.bar);
                AreEqual(3, system.bars.count());
                AreEqual(2, system2.bars.count());
            } finally {
                simulator.clearTimer();
            }
        }