Ejemplo n.º 1
0
 private void ProcessOrder(OrderTask orderTask)
 {
     if (orderTask.OrderStatus == OrderStatus.WaitOutPriceLMT || orderTask.OrderStatus == OrderStatus.WaitOutLotLMT
     || orderTask.OrderStatus == OrderStatus.WaitOutLotLMTOrigin)
     {
         if (this.IsPriceExceedMaxMin(orderTask.BestPrice) == true && orderTask.OrderStatus == OrderStatus.WaitOutLotLMT)
         {
             //Waiting for Dealer Accept/Reject
             orderTask.ChangeStatus(OrderStatus.WaitOutPriceLMT);
             //this.mainWindow.oDealingConsole.PlaySound(SoundOption.LimitDealerIntervene);
         }
         else
         {
             if (orderTask.Transaction.OrderType == OrderType.Market)
             {
                 orderTask.SetPrice = orderTask.BestPrice;
             }
             //Commit Transaction
             //if (this.lotChanged) lot = this.lot.toString();
             this.Commit(orderTask,string.Empty,(decimal)orderTask.Lot);
         }
     }
 }
Ejemplo n.º 2
0
        public void OnOrderWait(OrderTask orderTask)
        {
            if (orderTask.OrderStatus == OrderStatus.WaitOutPriceLMT
                || orderTask.OrderStatus == OrderStatus.WaitOutLotLMT
                || orderTask.OrderStatus == OrderStatus.WaitOutLotLMTOrigin)
            {
                orderTask.ChangeStatus(OrderStatus.WaitNextPrice);
                orderTask.ResetHit();
                Guid[] orderIds = new Guid[] { orderTask.OrderId };
                ConsoleClient.Instance.ResetHit(orderIds);

                if (this.OnOrderWaitNofityEvent != null)
                {
                    this.OnOrderWaitNofityEvent(orderTask);
                }
            }
        }
Ejemplo n.º 3
0
        private void Commit(OrderTask orderTask, string executePrice, decimal lot)
        {
            orderTask.ChangeStatus(OrderStatus.WaitServerResponse);
            orderTask.BaseOrder.ChangeStatus(OrderStatus.WaitServerResponse);

            string buyPrice = string.Empty;
            string sellPrice = string.Empty;
            executePrice = string.IsNullOrEmpty(executePrice) ? orderTask.SetPrice:executePrice;

            if(orderTask.IsBuy == BuySell.Buy)
            {
                buyPrice = executePrice;
            }
            else
            {
                sellPrice = executePrice;
            }

            switch(orderTask.Transaction.Type)
            {
                case TransactionType.Single:
                    foreach (Order order in orderTask.Transaction.Orders)
                    {
                        order.ChangeStatus(OrderStatus.WaitServerResponse);
                    }
                    break;
                case TransactionType.Pair:
                    foreach (Order orderTemp in orderTask.Transaction.Orders)
                    {
                        if (orderTemp.Id != orderTask.OrderId)
                        {
                            orderTemp.ChangeStatus(OrderStatus.WaitServerResponse);
                            executePrice = orderTemp.SetPrice;

                            if (orderTemp.BuySell == BuySell.Buy)
                                buyPrice = (executePrice == null) ? "" : executePrice.ToString();
                            else
                                sellPrice = (executePrice == null) ? "" : executePrice.ToString();
                            break;
                        }
                    }
                    break;
                case TransactionType.OneCancelOther:
                    foreach (Order orderTemp in orderTask.Transaction.Orders)
                    {
                        if (orderTemp.Id != orderTask.OrderId)
                        {
                            orderTemp.ChangeStatus(OrderStatus.Deleting);
                        }
                    }
                    break;
            }
            //if (!order.id) alert("The order is not valid!");
            LogOrder logEntity = LogEntityConvert.GetLogOrderEntity(orderTask, OperationType.OnOrderExecute, "ExecuteOrder");
            ConsoleClient.Instance.Execute(orderTask.Transaction, buyPrice, sellPrice, (decimal)orderTask.Lot, orderTask.OrderId, logEntity, ExecuteCallback);
        }
Ejemplo n.º 4
0
        public void OnOrderWait(OrderTask orderTask)
        {
            try
            {
                if (orderTask.OrderStatus == OrderStatus.WaitOutPriceLMT
                    || orderTask.OrderStatus == OrderStatus.WaitOutLotLMT
                    || orderTask.OrderStatus == OrderStatus.WaitOutLotLMTOrigin)
                {
                    orderTask.ChangeStatus(OrderStatus.WaitNextPrice);
                    orderTask.ResetHit();
                    Guid[] orderIds = new Guid[] { orderTask.OrderId };
                    ConsoleClient.Instance.ResetHit(orderTask.ExchangeCode, orderIds);

                    if (this.OnOrderWaitNofityEvent != null)
                    {
                        this.OnOrderWaitNofityEvent(orderTask);
                    }
                }
            }
            catch (Exception ex)
            {
                string logData = "OrderHandle.OnOrderWait:Error:" + returnLine;
                logData += ex.ToString();
                this.WriteLog(logData);
            }
        }