public void AddExecutedOrder(Transaction transaction)
 {
     foreach (Order order in transaction.Orders)
     {
         if (order.Phase != Phase.Executed) continue;
         this._ExchangeDataManager.ExecutedOrders.Add(order);
         this._ExchangeDataManager.AddExecutedOrderSummaryItem(order);
     }
 }
        private void InitializeOrder(CommonOrder commonOrder)
        {
            Transaction transaction = null;
            Guid accountId = commonOrder.AccountId;
            Guid instrumentId = commonOrder.InstrumentId;

            if (!this.ExchangeSettingManager.Instruments.ContainsKey(instrumentId) || !this.ExchangeSettingManager.Accounts.ContainsKey(accountId))
                    return;

            Account account = this.ExchangeSettingManager.Accounts[accountId];
            InstrumentClient instrument = this.ExchangeSettingManager.Instruments[instrumentId];

            if (!this._Orders.ContainsKey(commonOrder.Id))
            {
                if (!this._Transactions.ContainsKey(commonOrder.TransactionId))
                {
                    transaction = new Transaction(commonOrder, account, instrument);

                    this._Transactions.Add(transaction.Id, transaction);

                    Order order = new Order(transaction, commonOrder);
                    this._Orders.Add(order.Id, order);
                    transaction.Add(order);
                }
            }
            else
            {
                transaction = this._Orders[commonOrder.Id].Transaction;

                if (this._Orders[commonOrder.Id].Phase == iExchange.Common.OrderPhase.Executed)
                    return;
                this._Orders[commonOrder.Id].Update(commonOrder);
            }
        }
예제 #3
0
        private void Process(CommonTransaction commonTransaction, bool isExecuted)
        {
            if (!this._Transactions.ContainsKey(commonTransaction.Id))
            {
                if (!this._Instruments.ContainsKey(commonTransaction.InstrumentId) || !this._Accounts.ContainsKey(commonTransaction.AccountId))
                    return;
                Account account = this._Accounts[commonTransaction.AccountId];
                InstrumentClient instrument = this._Instruments[commonTransaction.InstrumentId];
                Transaction transaction = new Transaction(commonTransaction, account, instrument);

                //Set Transaction.ContractSize
                if (transaction.ContractSize == 0)
                {
                    TradePolicyDetail tradePolicyDetail = this.SettingsManager.GetTradePolicyDetail(account.TradePolicyId, instrument.Id);
                    if (tradePolicyDetail != null)
                    {
                        transaction.ContractSize = tradePolicyDetail.ContractSize;
                    }
                }
                this._Transactions.Add(transaction.Id, transaction);
            }
            else
            {
                if (isExecuted && commonTransaction.SubType == iExchange.Common.TransactionSubType.Match)
                {
                    Transaction transaction = this._Transactions[commonTransaction.Id];
                    if (transaction.Phase == iExchange.Common.OrderPhase.Canceled || transaction.Phase == iExchange.Common.OrderPhase.Executed)
                    {
                        return;
                    }
                }
                if (this._Transactions[commonTransaction.Id].Phase == iExchange.Common.OrderPhase.Executed && isExecuted)
                    return;
                this._Transactions[commonTransaction.Id].Update(commonTransaction);
            }
        }
예제 #4
0
        private void RemoveTransaction(Transaction tran)
        {
            List<OrderTask> instanceOrders = new List<OrderTask>();

            foreach (Order order in tran.Orders)
            {
                order.ChangeStatus(OrderStatus.Canceled);

                foreach (OrderTask orderTask in this._App.InitDataManager.ProcessInstantOrder.OrderTasks)
                {
                    if (orderTask.OrderId == order.Id)
                    {
                        instanceOrders.Add(orderTask);
                        continue;
                    }
                }
            }

            this._App.InitDataManager.ProcessInstantOrder.RemoveInstanceOrder(instanceOrders);
        }
예제 #5
0
 private void RejectPlaceCallback(Transaction tran,TransactionError transactionError)
 {
     App.MainWindow.Dispatcher.BeginInvoke((Action)delegate()
     {
         if (transactionError == TransactionError.OK)
         {
             this._CommonDialogWin.ShowDialogWin("Reject Place Succeed", "Infromation");
         }
     });
 }
예제 #6
0
 private void RejectPlace(Transaction transaction)
 {
     ConsoleClient.Instance.CancelPlace(transaction, Manager.Common.CancelReason.CustomerCanceled, RejectPlaceCallback);
 }
예제 #7
0
        //Execute DQ Order/Lmt Order
        private void ExecuteCallback(Transaction tran,TransactionError transactionError)
        {
            App.MainWindow.Dispatcher.BeginInvoke((Action)delegate()
            {
                if (transactionError == TransactionError.OK)
                {
                    foreach (Order order in tran.Orders)
                    {
                        if (order.Status == OrderStatus.Deleting || order.Status == OrderStatus.Deleting)
                        {
                            order.ChangeStatus(OrderStatus.Deleted);
                        }
                    }
                    this.RemoveTransaction(tran);

                    this.TranPhaseManager.UpdateTransaction(tran);
                }
            });
        }
예제 #8
0
 private void CancelTransactionCallback(Transaction tran,TransactionError transactionError)
 {
     App.MainWindow.Dispatcher.BeginInvoke((Action)delegate()
     {
         if (transactionError == TransactionError.OK)
         {
             foreach (Order order in tran.Orders)
             {
                 if (order.Status == OrderStatus.Deleting)
                 {
                     order.ChangeStatus(OrderStatus.Canceled);
                 }
             }
             this.RemoveTransaction(tran);
         }
         else
         {
             bool oDisablePopup = true;  //配置参数
             if (oDisablePopup)
             {
                 string sMsg = "";// this._Message.GetMessageForOrder("DealerCanceled");
                 this._CommonDialogWin.ShowDialogWin(sMsg, "Alert", 300, 200);
             }
         }
     });
 }
예제 #9
0
 //Call Back Event
 private void AcceptPlaceCallback(Transaction tran, TransactionError transactionError)
 {
     App.MainWindow.Dispatcher.BeginInvoke((Action)delegate()
     {
         if (transactionError == TransactionError.OK)
         {
             tran.Phase = Manager.Common.Phase.Placed;
             TranPhaseManager.UpdateTransaction(tran);
         }
     });
 }
예제 #10
0
 public void OnOrderRejectPlace(OrderTask orderTask)
 {
     if (orderTask.OrderStatus == OrderStatus.WaitAcceptRejectPlace)
     {
         string rejectOrderMsg = this.GetRejectOrderMessage(orderTask);
         this._RejectTran = orderTask.Transaction;
         this.ConfirmOrderDialogWin.ShowRejectOrderWin(rejectOrderMsg, orderTask,HandleAction.OnOrderRejectPlace);
     }
 }
        private void ProcessTransaction(string exchangeCode, CommonTransaction commonTransaction, bool isExecuted)
        {
            ExchangeSettingManager settingManager = this.GetExchangeSetting(exchangeCode);
            Dictionary<Guid, InstrumentClient> instruments = this.GetInstruments(exchangeCode);
            Dictionary<Guid, Account> accounts = this.GetAccount(exchangeCode);
            if (!this._Transactions.ContainsKey(commonTransaction.Id))
            {
                if (!instruments.ContainsKey(commonTransaction.InstrumentId) || !accounts.ContainsKey(commonTransaction.AccountId))
                    return;
                Account account = accounts[commonTransaction.AccountId];
                InstrumentClient instrument = instruments[commonTransaction.InstrumentId];
                Transaction transaction = new Transaction(commonTransaction, account, instrument);

                //Set Transaction.ContractSize
                if (transaction.ContractSize == 0)
                {
                    TradePolicyDetail tradePolicyDetail = settingManager.GetTradePolicyDetail(account.TradePolicyId, instrument.Id);
                    if (tradePolicyDetail != null)
                    {
                        transaction.ContractSize = tradePolicyDetail.ContractSize;
                    }
                }
                this._Transactions.Add(transaction.Id, transaction);
            }
            else
            {
                if (isExecuted && commonTransaction.SubType == iExchange.Common.TransactionSubType.Match)
                {
                    Transaction transaction = this._Transactions[commonTransaction.Id];
                    if (transaction.Phase == iExchange.Common.OrderPhase.Canceled || transaction.Phase == iExchange.Common.OrderPhase.Executed)
                    {
                        return;
                    }
                }
                if (this._Transactions[commonTransaction.Id].Phase == iExchange.Common.OrderPhase.Executed && isExecuted)
                    return;
                this._Transactions[commonTransaction.Id].Update(commonTransaction);
            }
        }
예제 #12
0
        private void RemoveTransaction(Transaction tran)
        {
            List<OrderTask> instanceOrders = new List<OrderTask>();
            List<OrderTask> lmtOrders = new List<OrderTask>();
            List<OrderTask> mooMocOrders = new List<OrderTask>();
            MooMocOrderForInstrument mooMocOrderForInstrument = null;

            foreach (Order order in tran.Orders)
            {
                if (order.Transaction.OrderType == OrderType.SpotTrade)
                {
                    foreach (OrderTask orderTask in this._App.ExchangeDataManager.ProcessInstantOrder.OrderTasks)
                    {
                        if (orderTask.OrderId == order.Id)
                        {
                            instanceOrders.Add(orderTask);
                        }
                    }
                }
                else if(order.Transaction.OrderType == OrderType.Limit || order.Transaction.OrderType == OrderType.Stop)
                {
                    foreach (OrderTask orderTask in this._App.ExchangeDataManager.ProcessLmtOrder.OrderTasks)
                    {
                        if (orderTask.OrderId == order.Id)
                        {
                            lmtOrders.Add(orderTask);
                        }
                    }
                }
                else if (order.Transaction.OrderType == OrderType.MarketOnOpen || order.Transaction.OrderType == OrderType.MarketOnClose)
                {
                    if (mooMocOrderForInstrument == null)
                    {
                        mooMocOrderForInstrument = this._App.ExchangeDataManager.MooMocOrderForInstrumentModel.MooMocOrderForInstruments.SingleOrDefault(P => P.Instrument.Id == order.Transaction.Instrument.Id);
                    }
                    if (mooMocOrderForInstrument != null)
                    {
                        OrderTask orderTask = mooMocOrderForInstrument.OrderTasks.SingleOrDefault(P => P.OrderId == order.Id);

                        if (orderTask == null) continue;
                        mooMocOrders.Add(orderTask);
                    }
                }
            }
            this._App.ExchangeDataManager.ProcessInstantOrder.RemoveInstanceOrder(instanceOrders);
            this._App.ExchangeDataManager.ProcessLmtOrder.RemoveLmtOrder(lmtOrders);
            if (mooMocOrderForInstrument == null) return;

            mooMocOrderForInstrument.RemoveMooMocOrder(mooMocOrders);

            if (mooMocOrderForInstrument.OrderTasks.Count == 0)
            {
                this._App.ExchangeDataManager.MooMocOrderForInstrumentModel.RemoveMooMocOrderForInstrument(mooMocOrderForInstrument);
            }
        }
예제 #13
0
        //Execute DQ Order/Lmt Order
        private void ExecuteCallback(Transaction tran, TransactionResult transactionResult)
        {
            App.MainFrameWindow.Dispatcher.BeginInvoke((Action)delegate()
            {
                if (transactionResult == null) return;
                if (transactionResult.TransactionError == TransactionError.OK)
                {
                    foreach (Order order in tran.Orders)
                    {
                        if (order.Status == OrderStatus.Deleting || order.Status == OrderStatus.Deleting)
                        {
                            order.ChangeStatus(OrderStatus.Deleted);
                        }

                        if (this.OnExecuteOrderNotifyEvent != null)
                        {
                        }
                    }
                    this.RemoveTransaction(tran);

                    this.TranPhaseManager.UpdateTransaction(tran);
                }
            });
        }
예제 #14
0
 public void OnOrderRejectPlace(OrderTask orderTask)
 {
     if (orderTask.OrderStatus == OrderStatus.WaitAcceptRejectPlace
     || orderTask.OrderStatus == OrderStatus.WaitAcceptRejectCancel
     || orderTask.OrderStatus == OrderStatus.WaitOutPriceDQ
     || orderTask.OrderStatus == OrderStatus.WaitOutLotDQ
     || (orderTask.OrderStatus == OrderStatus.WaitNextPrice && orderTask.Transaction.OrderType == OrderType.Limit))
     {
         string rejectOrderMsg = this.GetRejectOrderMessage(orderTask);
         this._RejectTran = orderTask.Transaction;
         this.ConfirmOrderDialogWin.ShowRejectOrderWin(rejectOrderMsg, orderTask,HandleAction.OnOrderRejectPlace);
     }
 }
예제 #15
0
        public void AddOrderToGroupNetPosition(Transaction transaction)
        {
            foreach (Order order in transaction.Orders)
            {
                if (order.Phase != Phase.Executed) continue;

                GroupNetPositionModel groupNetPostionModel = this._ExchangeDataManager.ReportDataManager.GetGroupNetPositionModel(order.ExchangeCode);
                if (groupNetPostionModel == null) continue;

                groupNetPostionModel.AddOrderToGroupNetPosition(order);
            }
        }
예제 #16
0
 public void UpdateTransaction(Transaction transaction)
 {
     foreach (Order order in transaction.Orders)
     {
         switch (transaction.Phase)
         {
             case Phase.Placing:
                 order.Status = OrderStatus.WaitAcceptRejectPlace;
                 break;
             case Phase.Placed:
                 CheckWhenOrderArrive(true, order);
                 if (order.Status == OrderStatus.WaitServerResponse) return;
                 CheckWhenOrderArrive(true, order);
                 break;
             case Phase.Executed:
                 order.Status = OrderStatus.Executed;
                 break;
             case Phase.Canceled:
                 order.Status = OrderStatus.Canceled;
                 break;
             case Phase.Deleted:
                 order.Status = OrderStatus.Deleted;
                 this.DeleteOrderFromOpenInterestSummaryGrid(order);
                 break;
             case Phase.Completed:
                 break;
         }
     }
 }