Exemplo n.º 1
0
        public void Cancel()
        {
            // 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
            o = new BuyLimit(sym, 200, 100, id++);
            ot.GotOrder(o);
            // cancel it
            ot.GotCancel(id - 1);
            // verify order is there
            Assert.IsTrue(ot.SentOrder(id - 1).isValid, "no valid order");
            // verify size/pending/cancel
            Assert.AreEqual(200, ot.Sent(id - 1), "not sent buy");
            Assert.AreEqual(0, ot.Filled(id - 1), "incorrect fill size buy");
            Assert.IsFalse(ot.isCompleted(id - 1), "wrongly completed");
            Assert.IsTrue(ot.isCanceled(id - 1), "not canceled");
            Assert.IsFalse(ot.isPending(id - 1), "wrongly pending");
            Assert.IsTrue(ot.isTracked(id - 1), "not tracked");

            // 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 sell order
            o = new SellLimit(sym, 200, 100, id++);
            ot.GotOrder(o);
            // fill it
            ot.GotCancel(id - 1);

            // verify order is there
            Assert.IsTrue(ot.SentOrder(id - 1).isValid, "no valid order");
            // verify size/pending/cancel
            Assert.AreEqual(0, ot.Filled(id - 1), "incorrect fill size sell");
            Assert.AreEqual(-200, ot.Sent(id - 1), "not sent sell");
            Assert.IsFalse(ot.isCompleted(id - 1), "wrongly completed");
            Assert.IsTrue(ot.isCanceled(id - 1), "not canceled");
            Assert.IsFalse(ot.isPending(id - 1), "wrongly pending");
            Assert.IsTrue(ot.isTracked(id - 1), "not tracked");
        }
Exemplo n.º 2
0
        void tl_gotOrderCancel(long number)
        {
            ord.GotCancel(number);

            if (ordergrid.InvokeRequired)
            {
                ordergrid.Invoke(new LongDelegate(tl_gotOrderCancel), new object[] { number });
            }
            else
            {
                int oidx = orderidx(number);                      // get row number of this order in the grid
                if ((oidx > -1) && (oidx < ordergrid.Rows.Count)) // if row number is valid
                {
                    ordergrid.Rows.RemoveAt(oidx);                // remove the canceled order
                }
            }
        }
Exemplo n.º 3
0
        private void ClientGotOrderCancelConfirmation(long oid)
        {
            int pos = OrderTable.Select(row => row.OrderId).ToList().IndexOf(oid);

            System.Windows.Application.Current.Dispatcher.Invoke(() =>
            {
                if (pos == -1)
                {
                    OnDebug("Order id " + oid.ToString() + " is not found in order table; possibly new order.");
                }
                else
                {
                    // order table
                    _ordertracker.GotCancel(oid);
                    OrderStatus status     = OrderStatus.Canceled;
                    OrderTable[pos].Status = EnumDescConverter.GetEnumDescription(status);
                }
            });
        }
Exemplo n.º 4
0
 public void GotCancel(long id)
 {
     ord.GotCancel(id);
     ShowItems(AccountActivity.NewCancel(id));
 }