Beispiel #1
0
        /// <summary>
        /// Query Order Personal Download
        /// </summary>
        /// <param name="Segment"></param>
        /// <param name="MessageTag"></param>
        private static void QueryPersonalDownload(string Segment, uint MessageTag, ushort HFLFFlag)
        {
            if (HFLFFlag == (int)Enumerations.HFLFFlag.LFFlag) //Request Order, Trades and Limit
            {
                //Set reply and EOD flags to false
                UtilityLoginDetails.GETInstance.PersonalReplyReceived = false;
                UtilityLoginDetails.GETInstance.EndofdownloadReceived = false;
                GetInstance.ReplyMessageTxt = ConstantMessages.WaitOrderMessage;
                OrderRequestProcessor orderreqprocessor = null;
                OrderNomralRequest    orequest          = new OrderNomralRequest();
                orequest.Hour       = "0";
                orequest.Minute     = "0";
                orequest.Second     = "0";
                orequest.Filler     = Segment;
                orequest.MessageTag = MessageTag;
                orderreqprocessor   = new OrderRequestProcessor(new OrderNormalPersonalDownload());
                orderreqprocessor.ProcessRequest(orequest, (int)OrderTypeDownload.NormalOrders);
                autoReset.WaitOne();
                GetInstance.ReplyMessageTxt = ConstantMessages.WaitRetOrderMessage;
                StartNextDownload(Segment, MessageTag, (int)OrderTypeDownload.ReturnOrders);
                autoReset.WaitOne();
                GetInstance.ReplyMessageTxt = ConstantMessages.WaitStopLossMessage;
                StartNextDownload(Segment, MessageTag, (int)OrderTypeDownload.StopLossOrders);
                autoReset.WaitOne();
                GetInstance.ReplyMessageTxt = ConstantMessages.WaitRetStopLossMessage;
                StartNextDownload(Segment, MessageTag, (int)OrderTypeDownload.ReturnStopLossOrders);
                autoReset.WaitOne();
                GetInstance.ReplyMessageTxt = ConstantMessages.WaitTradeMessage;
                StartNextTradeDownload(Segment, MessageTag, null);
                autoReset.WaitOne();
                GetInstance.ReplyMessageTxt = ConstantMessages.WaitLimitMessage;
                StartNextLimitDownload(MessageTag, null);
                autoReset.WaitOne();
                GetInstance.ReplyMessageTxt = ConstantMessages.WaitGWLimitMessage;
                StartNextLimitDownload(MessageTag, UtilityLoginDetails.GETInstance.TraderId);
                autoReset.WaitOne();
            }
            else if (HFLFFlag == (int)Enumerations.HFLFFlag.HFFlag) // Request Only Trades and Limits
            {
                GetInstance.ReplyMessageTxt = ConstantMessages.WaitTradeMessage;
                StartNextTradeDownload(Segment, MessageTag, null);
                autoReset.WaitOne();
                GetInstance.ReplyMessageTxt = ConstantMessages.WaitLimitMessage;
                StartNextLimitDownload(MessageTag, null);
                autoReset.WaitOne();
                GetInstance.ReplyMessageTxt = ConstantMessages.WaitGWLimitMessage;
                StartNextLimitDownload(MessageTag, UtilityLoginDetails.GETInstance.TraderId);
                autoReset.WaitOne();
            }

            GetInstance.ReplyMessageTxt = ConstantMessages.CompletedMessage;
        }
Beispiel #2
0
        /// <summary>
        /// Called when Cancel button is clicked. Deletes selected pending order
        /// </summary>
        private void Cancel_ClickButton()
        {
            try
            {
                //if (SelectedValue != null)
                if (SelectedValue != null && SelectedValue.Count > 0)
                {
                    if (MessageBox.Show("Do you really want to delete this Order?", "Delete Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                    {
                        foreach (var item in SelectedValue)
                        {
#if BOW
                            OrderProcessor.SendDeleteOrderRequest(OrderDictionary.Select(x => x.Value).Where(x => x.OrderRemarks == item.OEREmarks).FirstOrDefault());
#elif TWS
                            //OrderProcessor.SendDeleteOrderRequest(item.MessageTag);
                            OrderRequestProcessor oOrderRequestProcessor = new OrderRequestProcessor(new DeleteOrder());
                            OrderModel            oOrderModel            = new OrderModel();
                            MemoryManager.OrderDictionary.TryGetValue(item.OrderKey, out oOrderModel);
                            if (oOrderModel != null)
                            {
                                oOrderRequestProcessor.ProcessRequest(oOrderModel);
                            }
                            else
                            {
                                MessageBox.Show("Can't find order");
                            }
#endif
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Please Select the Order to Cancel", "Cancel Order", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
            catch (Exception ex)
            {
                ExceptionUtility.LogError(ex);
            }
        }
        private void SubmitOrder()
        {
            int count = selecteBulkScripList.Count;
            try
            {
                //if (SelectedValue != null)
                for (int index = 0; index < count; index++)
                {
                    PendingOrder oPendingOrder = new PendingOrder();
                    oPendingOrder = (PendingOrder)selecteBulkScripList[index];
                    //bool validate = ValidateUserInputs(oPendingOrder.SCode, oPendingOrder.TotalQty, oPendingOrder.RevQty, oPendingOrder.Rate, oPendingOrder.ClientID, oPendingOrder.ProtectionPercent);
                    //if (!validate)
                    //{
                    //    return;
                    //}
                    //foreach (var item in SelectedValue)
                    //{
#if BOW
                    //OrderProcessor.GetOrderDataFromOrderID(SelectedValue.FirstOrDefault());                  
                    OrderProcessor.GetOrderDataFromOrderID(SelectedValue.FirstOrDefault());
#elif TWS
                    //OrderProcessor.GetOrderDataByMessageTag(SelectedValue.FirstOrDefault());
                    OrderRequestProcessor oOrderRequestProcessor = new OrderRequestProcessor(new ModifyOrder());
                    OrderModel oOrderModel;
                    string key = Convert.ToString(oPendingOrder.SCode) + "_" + oPendingOrder.OrdID;
                    MemoryManager.OrderDictionary.TryGetValue(key, out oOrderModel);


                    if (oOrderModel != null)
                    {
                        OrderModel oTempOrderModel = new OrderModel();
                        var DecimalPoint = CommonFunctions.GetDecimal(System.Convert.ToInt32(oOrderModel.ScripCode), "BSE", CommonFunctions.GetSegmentID(oOrderModel.ScripCode));
                        bool validate = true;
                        if (string.IsNullOrEmpty(txtNewPrice) && string.IsNullOrEmpty(OCOTrgRatetxt))
                        {
                            txtReply = "Enter Either of the rates";
                            return;
                        }

                        if (!string.IsNullOrEmpty(txtNewPrice))
                        {
                            if (!string.IsNullOrEmpty(OCOTrgRatetxt))
                            {
                                validate = ValidateUserInputs(oPendingOrder.SCode, oPendingOrder.TotalQty, oPendingOrder.RevQty, txtNewPrice, oPendingOrder.ClientID, oPendingOrder.ProtectionPercent, OCOTrgRatetxt, oOrderModel, ref Validate_Message);
                            }
                            else
                            {
                                validate = ValidateUserInputs(oPendingOrder.SCode, oPendingOrder.TotalQty, oPendingOrder.RevQty, txtNewPrice, oPendingOrder.ClientID, oPendingOrder.ProtectionPercent, oPendingOrder.OCOTrgRate, oOrderModel, ref Validate_Message);
                            }

                            //validate = ValidateUserInputs(oPendingOrder.SCode, oPendingOrder.TotalQty, oPendingOrder.RevQty, txtNewPrice, oPendingOrder.ClientID, oPendingOrder.ProtectionPercent, OCOTrgRatetxt, oOrderModel, ref Validate_Message);
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(OCOTrgRatetxt))
                            {
                                validate = ValidateUserInputs(oPendingOrder.SCode, oPendingOrder.TotalQty, oPendingOrder.RevQty, oPendingOrder.Rate, oPendingOrder.ClientID, oPendingOrder.ProtectionPercent, OCOTrgRatetxt, oOrderModel, ref Validate_Message);
                            }
                            else
                            {
                                validate = ValidateUserInputs(oPendingOrder.SCode, oPendingOrder.TotalQty, oPendingOrder.RevQty, oPendingOrder.Rate, oPendingOrder.ClientID, oPendingOrder.ProtectionPercent, oPendingOrder.OCOTrgRate, oOrderModel, ref Validate_Message);
                            }
                            //validate = ValidateUserInputs(oPendingOrder.SCode, oPendingOrder.TotalQty, oPendingOrder.RevQty, oPendingOrder.Rate, oPendingOrder.ClientID, oPendingOrder.ProtectionPercent, OCOTrgRatetxt, oOrderModel, ref Validate_Message);
                        }

                      

                        if (!validate)
                        {
                            txtReply = Validate_Message;
                            return;
                        }

                        oTempOrderModel.OrderAction = "U";
                        oTempOrderModel.OriginalQty = oOrderModel.OriginalQty;
                        oTempOrderModel.RevealQty = oOrderModel.RevealQty;
                        oTempOrderModel.OrderType = oOrderModel.OrderType;
                        //Convert Price in Long and send to processing
                        if (oTempOrderModel.OrderType == "G")//oTempOrderModel.OrderType == "STOPLOSSMKT")
                        {
                            oTempOrderModel.Price = 0;
                        }
                        else//for limit
                        {
                            if (!string.IsNullOrEmpty(txtNewPrice))
                                oTempOrderModel.Price = Convert.ToInt64(Convert.ToDouble(txtNewPrice) * Math.Pow(10, DecimalPoint));//Convert.ToInt32(Ratetxt);
                            else
                                oTempOrderModel.Price = Convert.ToInt64(Convert.ToDouble(oPendingOrder.Rate) * Math.Pow(10, DecimalPoint));

                            //oTempOrderModel.Price = Convert.ToInt64(Convert.ToDouble(txtNewPrice) * Math.Pow(10, DecimalPoint));
                        }
                        oTempOrderModel.Exchange = Enumerations.Order.Exchanges.BSE.ToString();
                        oTempOrderModel.ScreenId = (int)Enumerations.WindowName.Pending_Order;
                        oTempOrderModel.OrderRetentionStatus = oOrderModel.OrderRetentionStatus;
                        oTempOrderModel.ClientId = oOrderModel.ClientId;
                        oTempOrderModel.OrderType = oOrderModel.OrderType;
                        if (oTempOrderModel.OrderType == "G")
                        {
                            oTempOrderModel.ProtectionPercentage = Convert.ToString(Convert.ToInt32(Convert.ToDecimal(oOrderModel.ProtectionPercentage) * 100));
                        }
                        else
                        {
                            oTempOrderModel.ProtectionPercentage = "0";
                        }
                        oTempOrderModel.OrderId = oOrderModel.OrderId;
                        oTempOrderModel.BuySellIndicator = oOrderModel.BuySellIndicator;
                        oTempOrderModel.OrderKey = key;
                        oTempOrderModel.ScripCode = oOrderModel.ScripCode;
                        oTempOrderModel.Segment = CommonFunctions.GetSegmentID(oOrderModel.ScripCode);
                        oTempOrderModel.SegmentFlag = CommonFunctions.SegmentFlag(oTempOrderModel.Segment); //(int)Enum.Parse(typeof(Enumerations.Order.ScripSegment), oTempOrderModel.Segment);
                        oTempOrderModel.ClientType = oOrderModel.ClientType;
                        oTempOrderModel.ParticipantCode = oOrderModel.ParticipantCode;
                        oTempOrderModel.Symbol = oOrderModel.Symbol;
                        if (oOrderModel.IsOCOOrder == true)
                        {
                            oTempOrderModel.IsOCOOrder = true;
                            if (!string.IsNullOrEmpty(OCOTrgRatetxt))
                                oTempOrderModel.TriggerPrice = Convert.ToInt64(Convert.ToDouble(OCOTrgRatetxt) * Math.Pow(10, DecimalPoint));
                            else
                                oTempOrderModel.TriggerPrice = Convert.ToInt64(Convert.ToDouble(oPendingOrder.OCOTrgRate) * Math.Pow(10, DecimalPoint));
                        }

                        oTempOrderModel.BuySellIndicator = oOrderModel.BuySellIndicator;
                        oTempOrderModel.MarketLot = oOrderModel.MarketLot;
                        oTempOrderModel.TickSize = oOrderModel.TickSize;
                        oTempOrderModel.Group = oOrderModel.Group;
                        oOrderRequestProcessor.ProcessRequest(oTempOrderModel);
                    }
                    else
                    {
                        //MessageBox.Show("Can't find order");
                        txtReply = "Can't find order";
                    }
                    BulkChnageOrderEvent.WaitOne();

                }
#endif

            }
            catch (Exception ex)
            {
                ExceptionUtility.LogError(ex);
            }
        }