示例#1
0
 public void TestNormal()
 {
     lasto = new OrderImpl();
     oc = 0;
     ost = new OversellTracker();
     ost.SendOrderEvent += new OrderDelegate(ost_SendOrderEvent);
     ost.SendDebugEvent += new DebugDelegate(rt.d);
     // take a position
     ost.GotPosition(new PositionImpl("TST"));
     // over sell
     ost.sendorder(new SellMarket("TST", 500));
     // verify that was sent
     Assert.AreEqual(1, oc);
     Assert.AreEqual(-500, lasto.size);
 }
示例#2
0
        public void TestOverBuyAdjust()
        {
            lasto = new OrderImpl();
            oc = 0;
            ost = new OversellTracker();
            ost.SendOrderEvent += new OrderDelegate(ost_SendOrderEvent);
            ost.SendDebugEvent += new DebugDelegate(rt.d);

            ost.Split = true;
            // take a position
            ost.GotPosition(new PositionImpl("TST", 100, -300));
            // over sell
            ost.sendorder(new BuyMarket("TST", 500));
            // verify that only flat was sent
            Assert.AreEqual(2, oc);
            Assert.AreEqual(200, lasto.size);
        }
示例#3
0
        public void SplitWithPartialFillRoundMinsize100()
        {
            lasto = new OrderImpl();
            oc = 0;
            ost = new OversellTracker();
            ost.SendOrderEvent += new OrderDelegate(ost_SendOrderEvent);
            ost.SendDebugEvent += new DebugDelegate(rt.d);
            ost.MinLotSize = 100;

            ost.Split = true;
            // take a position
            ost.GotPosition(new PositionImpl("TST", 100, 58));
            // over sell
            Order o = new SellMarket("TST", 100);
            o.id = 1;
            ost.sendorder(o);
            // verify that flat and adjustment were sent
            Assert.AreEqual(1, oc);
            Assert.AreEqual(-100, lasto.size);
        }
示例#4
0
        public void SplitCancelCopy()
        {
            lasto = new OrderImpl();
            oc = 0;
            cancels.Clear();
            ost = new OversellTracker();
            ost.SendOrderEvent += new OrderDelegate(ost_SendOrderEvent);
            ost.SendDebugEvent += new DebugDelegate(rt.d);
            ost.SendCancelEvent += new LongDelegate(ost_SendCancelEvent);

            ost.Split = true;
            // take a position
            ost.GotPosition(new PositionImpl("TST", 100, 300));
            // over sell
            Order o = new SellMarket("TST", 500);
            o.id = 5;
            ost.sendorder(o);
            // verify that only flat was sent
            Assert.AreEqual(2, oc);
            Assert.AreEqual(-200, lasto.size);
            // make sure we've not canceled
            Assert.AreEqual(0, cancels.Count);
            // cancel original order
            ost.sendcancel(5);
            // ensure two cancels sent
            Assert.AreEqual(2, cancels.Count);
            // ensure different cancels
            Assert.AreEqual(5, cancels[0]);
            Assert.AreNotEqual(5, cancels[1]);

            // do it again

            // take a position
            ost.GotPosition(new PositionImpl("TST", 100, 300));

            // over sell
            o = new SellMarket("TST", 500);
            o.id = 10;
            ost.sendorder(o);
            // verify that only flat was sent
            Assert.AreEqual(4, oc);
            Assert.AreEqual(-200, lasto.size);
            // make sure we've not canceled
            Assert.AreEqual(2, cancels.Count);
            // cancel original order
            ost.sendcancel(10);
            // ensure two cancels sent
            Assert.AreEqual(4, cancels.Count);
            // ensure different cancels
            Assert.AreEqual(10, cancels[2]);
            Assert.AreNotEqual(10, cancels[3]);


        }