Esempio n. 1
0
        public void testBarCanBeUpdatedFromATick()
        {
            O.freezeNow();
            var b = new Bar(1, 1, 1, 1);

            b = b.update(tick(2));
            AreEqual(new Bar(1, 2, 1, 2, O.now()), b);
            b = b.update(tick(0));
            AreEqual(new Bar(1, 2, 0, 0, O.now()), b);
        }
Esempio n. 2
0
        public void testCanGoLiveWithoutCloseTime()
        {
            var liveSystem = LIVE_SYSTEM;

            liveSystem.setQClassName(typeof(ExampleSymbolSystem).FullName);
            liveSystem.populateDetailsIfNeeded(false);
            liveSystem.insertParameter("lookback", "2");
            liveSystem.insertParameter("LeadBars", "0");

            MarketSessionTable.SESSION.update(SYMBOL.name, Session.DAY, "NO_CLOSE", 0);
            ExchangeSessionTable.EXCHANGE_SESSION.update(new Market(SYMBOL.name).exchange(), Session.DAY, "NO_CLOSE", 0);
            var args = new SystemArguments(SYMBOL, new Parameters {
                { "systemId", liveSystem.id() },
                { "RunMode", (double)RunMode.LIVE }
            });
            var simulator = makeSimulator(args);

            simulator.processBars(300);
            while (O.hasContent(simulator.allPositions()))
            {
                simulator.nextBar();
            }
            simulator.goLive();
            var time = simulator.currentDate().AddDays(1);

            O.freezeNow(time);
            noPosition(simulator);
            var current = new Bar(120, 120, 120, 120, time);

            tick(simulator, current, SYMBOL);
            hasPosition(simulator);
            time    = time.AddSeconds(1);
            current = current.update(new Tick(118, 1, time));
            tick(simulator, current, SYMBOL);
        }