示例#1
0
        public void testPositionPublish()
        {
            var counter = positionPublishCounter();

            // get a position in "simulation"
            processBar(1, 3.5, 0, 2);
            hasOrders(buy("enter long", stop(3.5), 100, fillOrKill()));
            fill(0, 3.0);
            // now we are live
            processTick(3.5);
            AreEqual(100, counter.getOne <int>("beginValue"));
            AreEqual(100, counter.getOne <int>("liveValue"));
            AreEqual(O.hostname(), counter.getOne <string>("hostname"));
            var beginTime = counter.getOne <string>("beginTimestamp");
            var liveTime  = counter.getOne <string>("liveTimestamp");

            counter.clear();
            // this way we should get a new timestamp
            util.Dates.freezeNow(util.Dates.secondsAhead(1, util.Dates.now()));
            processTick(3.5);
            counter.requireNoMessages();
            hasOrders(
                sell("exit long", market(), 100, fillOrKill()),
                sell("exit long 2", market(), 100, fillOrKill())
                );
            fill(0, 2.0);
            O.sleep(100);
            AreNotEqual(liveTime, counter.getOne <string>("liveTimestamp"));
            AreEqual(beginTime, counter.getOne <string>("beginTimestamp"));
            AreEqual(100, counter.getOne <int>("beginValue"));
            AreEqual(0, counter.getOne <int>("liveValue"));
        }