public void testStartsWithNoPositions() { O.freezeNow("2001/01/01 16:01:00"); var rediBlid1 = new QTopic("some.redi.topic." + BLID1); var rediBlid2 = new QTopic("some.redi.topic." + BLID2); var rediBlid3 = new QTopic("some.redi.topic." + BLID3); var aimBlid1 = new QTopic("some.aim.topic." + BLID1); var aimBlid2 = new QTopic("some.aim.topic." + BLID2); var fakeGui = new FakePositionTrackerGui(); var tracker = new PositionTracker(fakeGui, new QTopic("some.redi.topic.*"), new QTopic("some.aim.topic.*")); tracker.initialize(); IsTrue(O.isEmpty(tracker.ids())); fakeGui.requireRowCount(0); rediBlid1.send(fields("REDI", BLID1, 5, 4, "2001/01/01 16:00:00")); fakeGui.requireRowCount(1); fakeGui.requireStatus(fakeGui.row(0), PositionTracker.Status.UNMATCHED); rediBlid1.send(fields("REDI", BLID1, 6, 4, "2001/01/01 16:00:01")); fakeGui.requireRowCount(1); fakeGui.requireStatus(fakeGui.row(0), PositionTracker.Status.UNMATCHED); aimBlid1.send(fields("AIM", BLID1, 6, 4, "2001/01/01 16:00:03")); waitMatches(6, () => tracker.buyCount("AIM", BLID1)); waitMatches(4, () => tracker.sellCount("AIM", BLID1)); fakeGui.requireRowCount(1); fakeGui.requireStatus(fakeGui.row(0), PositionTracker.Status.MATCHED); aimBlid1.send(fields("AIM", BLID1, 7, 5, "2001/01/01 16:00:04")); fakeGui.requireRowCount(1); fakeGui.requireStatus(fakeGui.row(0), PositionTracker.Status.UNMATCHED); waitMatches(0, () => tracker.skipped); rediBlid1.send(fields("REDI", BLID1, 7, 5, "2001/01/01 16:00:06")); aimBlid2.send(fields("AIM", BLID2, 8, 6, "2001/01/01 16:00:08")); fakeGui.requireRowCount(2); fakeGui.requireStatus(fakeGui.row(0), PositionTracker.Status.MATCHED); fakeGui.requireStatus(fakeGui.row(1), PositionTracker.Status.UNMATCHED); rediBlid2.send(fields("REDI", BLID2, 8, 5, "2001/01/01 16:00:09")); fakeGui.requireRowCount(2); fakeGui.requireStatus(fakeGui.row(0), PositionTracker.Status.MATCHED); fakeGui.requireStatus(fakeGui.row(1), PositionTracker.Status.UNMATCHED); rediBlid3.send(fields("REDI", BLID3, 8, 5, "2000/12/31 23:59:59")); waitMatches(1, () => tracker.skipped); fakeGui.requireRowCount(2); rediBlid2.send(fields("REDI", BLID2, 8, 6, "2001/01/01 16:00:10")); fakeGui.requireRowCount(2); fakeGui.requireStatus(fakeGui.row(0), PositionTracker.Status.MATCHED); fakeGui.requireStatus(fakeGui.row(1), PositionTracker.Status.MATCHED); }
[Test] public void testOneSubscribe() { OrderTable.prefix = "PREFIX"; O.freezeNow("2009/07/10 13:00:00"); var liveSystem = OneSystemTest <EmptySystem> .fakeLiveSystem(new Parameters(), false); liveSystem.removeAllLiveMarkets(); insertMarket("FOO", 0); liveSystem.addLiveMarket("FOO", "2009/07/07", null); insertMarket("BAR", 0); liveSystem.addLiveMarket("BAR", "2009/07/07", null); var fooTopic = new QTopic("PREFIX.TestSystem1.1.0.daily.Slow.FOO.heartbeat"); O.timerManager().isInterceptingTimersForTest = true; O.timerManager().intercept("2009/07/10 13:00:00", "gui update"); var map = new StatusTreeMap(new FakeStatusMapGUI(), O.list(liveSystem)); map.setIsEqualSizes(false); var systemNode = O.the(map.nodes()); AreEqual("TestSystem1", systemNode.text); var pvNode = O.the(systemNode.children()); AreEqual("Slow", pvNode.text); var symbolNodes = O.dictionaryFromValues(O.convert(pvNode.children(), child => child as LiveMarketNode), child => child.id); AreEqual(1d, symbolNodes["FOO"].size); AreEqual(0, symbolNodes["FOO"].ticksReceived); AreEqual(1d, symbolNodes["BAR"].size); var message = new Fields(); message.put("timestamp", "2009/07/10 12:59:59"); message.put("lastTickProcessed", "2009/07/10 12:59:58"); message.put("ticksReceived", "200"); message.put("hostname", "hullabaloo"); fooTopic.send(message); Objects.timerManager().intercept("2009/07/10 13:00:01", "second gui update"); O.timerManager().runTimers("2009/07/10 13:00:00"); waitMatches(200d, () => symbolNodes["FOO"].ticksReceived); // you just }