Exemplo n.º 1
0
        public void Sent()
        {
            // reset everything
            id = 1;
            o  = new OrderImpl();
            ot = new OrderTracker();
            ot.SendDebugEvent  += new DebugDelegate(ot_SendDebugEvent);
            ot.VerboseDebugging = true;

            // verify no size/pending/cancel
            Assert.AreEqual(0, ot.Sent(id), "sent but not sent");
            Assert.IsFalse(ot.isCompleted(id), "completed but not sent");
            Assert.IsFalse(ot.isCanceled(id), "wrongly canceled");
            Assert.IsFalse(ot.isPending(id), "wrongly pending");
            Assert.IsFalse(ot.isTracked(id), "wrongly tracked");
            // send a buy order
            ot.GotOrder(new BuyLimit(sym, 100, 100, id++));
            // verify order is there
            Assert.IsTrue(ot.SentOrder(id - 1).isValid, "no valid order");
            // verify size/pending/cancel
            Assert.AreEqual(100, ot.Sent(id - 1), "not sent");
            Assert.AreEqual(0, ot.Filled(id - 1), "incorrect fill size");
            Assert.IsFalse(ot.isCompleted(id - 1), "completed but not filled");
            Assert.IsFalse(ot.isCanceled(id - 1), "wrongly canceled");
            Assert.IsTrue(ot.isPending(id - 1), "not pending");
            Assert.IsTrue(ot.isTracked(id - 1), "not tracked");
            Assert.IsTrue(ot.GetOrderId(0) == 1, "no id at idx");

            // do sell order

            // verify no size/pending/cancel
            Assert.AreEqual(0, ot.Sent(id), "sent but not sent");
            Assert.IsFalse(ot.isCompleted(id), "completed but not sent");
            Assert.IsFalse(ot.isCanceled(id), "wrongly canceled");
            Assert.IsFalse(ot.isPending(id), "wrongly pending");
            Assert.IsFalse(ot.isTracked(id), "wrongly tracked");
            // send a sell order
            ot.GotOrder(new SellLimit(sym, 100, 100, id++));
            // verify order is there
            Assert.IsTrue(ot.SentOrder(id - 1).isValid, "no valid order");
            // verify size/pending/cancel
            Assert.AreEqual(-100, ot.Sent(id - 1), "not sent");
            Assert.AreEqual(0, ot.Filled(id - 1), "incorrect fill size");
            Assert.IsFalse(ot.isCompleted(id - 1), "completed but not filled");
            Assert.IsFalse(ot.isCanceled(id - 1), "wrongly canceled");
            Assert.IsTrue(ot.isPending(id - 1), "not pending");
            Assert.IsTrue(ot.isTracked(id - 1), "not tracked");
        }