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]); }
long tl_gotSrvFillRequest(Order o) { if (o.id == 0) { o.id = _idt.AssignId; } ost.sendorder(o); return((long)MessageTypes.OK); }
public void TestOverSellDrop() { 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", 100, 300)); // over sell ost.sendorder(new SellMarket("TST", 500)); // verify that only flat was sent Assert.AreEqual(1, oc); Assert.AreEqual(-300, lasto.size); }
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 flat and adjustment were sent Assert.AreEqual(2, oc); Assert.AreEqual(200, lasto.size); }
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); }