private void AddOrderTaskEntity(Order order)
        {
            if (order.Transaction.OrderType == iExchange.Common.OrderType.MarketOnOpen || order.Transaction.OrderType == iExchange.Common.OrderType.MarketOnClose)
            {
                OrderTask orderTask = new OrderTask(order);
                orderTask.BaseOrder = order;
                orderTask.OrderStatus = OrderStatus.TimeArrived;
                MooMocOrderForInstrument mooMocOrderForInstrument = null;
                mooMocOrderForInstrument = this._MooMocOrderForInstrumentModel.MooMocOrderForInstruments.SingleOrDefault(P => P.Instrument.Id == order.Transaction.Instrument.Id);
                if (mooMocOrderForInstrument == null)
                {
                    mooMocOrderForInstrument = new MooMocOrderForInstrument();
                    InstrumentClient instrument = order.Transaction.Instrument;
                    mooMocOrderForInstrument.Instrument = instrument;
                    mooMocOrderForInstrument.Origin = instrument.Origin;
                    mooMocOrderForInstrument.Variation = 0;

                    this._MooMocOrderForInstrumentModel.MooMocOrderForInstruments.Add(mooMocOrderForInstrument);
                }
                if (orderTask.IsBuy == BuySell.Buy)
                {
                    mooMocOrderForInstrument.SumBuyLot += orderTask.Lot.Value;
                }
                else
                {
                    mooMocOrderForInstrument.SumSellLot += orderTask.Lot.Value;
                }
                mooMocOrderForInstrument.OrderTasks.Add(orderTask);
            }
            else if(order.Transaction.OrderType == iExchange.Common.OrderType.SpotTrade)
            {
                OrderTask orderTask = new OrderTask(order);
                orderTask.BaseOrder = order;

                this._ProcessInstantOrder.AddInstanceOrder(orderTask);
            }
            else
            {
                OrderTask orderTask = new OrderTask(order);
                orderTask.BaseOrder = order;

                this._OrderTaskModel.OrderTasks.Add(orderTask);
                orderTask.SetCellDataDefine(orderTask.OrderStatus);
            }
        }
        public void AddMooMocOrderForInstrument(OrderTask orderTask)
        {
            MooMocOrderForInstrument mooMocOrderForInstrument = null;
            mooMocOrderForInstrument = this.MooMocOrderForInstruments.SingleOrDefault(P => P.Instrument.Id == orderTask.Transaction.Instrument.Id);
            if (mooMocOrderForInstrument == null)
            {
                InstrumentClient instrument = orderTask.Transaction.Instrument;
                mooMocOrderForInstrument = new MooMocOrderForInstrument(instrument);
                this.MooMocOrderForInstruments.Add(mooMocOrderForInstrument);
            }

            mooMocOrderForInstrument.AddMooMocOrder(orderTask);
        }
 public void RemoveMooMocOrderForInstrument(MooMocOrderForInstrument mooMocOrderForInstrument)
 {
     this.MooMocOrderForInstruments.Remove(mooMocOrderForInstrument);
 }
 public void OnMooMocReject(MooMocOrderForInstrument mooMocOrderForInstrument)
 {
     foreach (OrderTask orderTask in mooMocOrderForInstrument.OrderTasks)
     {
         if (orderTask.IsSelected)
         {
             orderTask.SetPrice = orderTask.IsBuy == BuySell.Buy ? mooMocOrderForInstrument.Bid : mooMocOrderForInstrument.Ask;
             this.OnOrderRejectPlace(orderTask);
         }
     }
 }
        public void OnMooMocExecute(MooMocOrderForInstrument mooMocOrderForInstrument)
        {
            foreach(OrderTask orderTask in mooMocOrderForInstrument.OrderTasks)
            {
                if(orderTask.IsSelected)
                {
                    if (!this.IsCanExecutedMooMoc(orderTask)) continue;

                    this.Commit(orderTask, orderTask.SetPrice, (decimal)orderTask.Lot);
                }
            }
        }
 public void OnMooMocCancel(MooMocOrderForInstrument mooMocOrderForInstrument)
 {
     if (MessageBox.Show("Are you sure cancel the order?", "Alert", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         foreach (OrderTask orderTask in mooMocOrderForInstrument.OrderTasks)
         {
             if (orderTask.IsSelected)
             {
                 this.CancelTransaction(orderTask);
             }
         }
     }
 }
 public void OnMooMocApply(MooMocOrderForInstrument mooMocOrderForInstrument)
 {
     foreach (OrderTask orderTask in mooMocOrderForInstrument.OrderTasks)
     {
         if (orderTask.IsSelected)
         {
             InstrumentClient instrument = orderTask.Transaction.Instrument;
             if (instrument.IsNormal == (orderTask.IsBuy== BuySell.Buy))
             {
                 orderTask.SetPrice = mooMocOrderForInstrument.Ask;
             }
             else
             {
                 orderTask.SetPrice = mooMocOrderForInstrument.Bid;
             }
         }
     }
 }
 public void OnMooMocAccept(MooMocOrderForInstrument mooMocOrderForInstrument)
 {
     foreach (OrderTask orderTask in mooMocOrderForInstrument.OrderTasks)
     {
         if (orderTask.IsSelected)
         {
             this.OnOrderAcceptPlace(orderTask);
         }
     }
 }