예제 #1
0
        public static void Main(string[] args)
        {
            // ========================Before placing new Order =============================

            MS_OE_REQUEST_TR _oetr= new MS_OE_REQUEST_TR();

            _oetr.TokenNo = 12546;
            _oetr.Volume = 1245;
            _oetr.Buy_SellIndicator = 256;
            _oetr.Price = 78965;

            Packetheader _pkt = new Packetheader ();

            GenerateHash( DataPacket.RawSerialize(_pkt).Concat(DataPacket.RawSerialize(_oetr)).ToArray(),1,123456);

            // =====================================================

            //^^^^^^^^^^^^^^^^^^^^^^ After Order Confirmation  ============

            double OrderNumber = 8974563214587;

            MS_OE_RESPONSE_TR _oertr = new MS_OE_RESPONSE_TR ();

            _oertr.TokenNo = 12546;
            _oertr.Volume = 1245;
            _oertr.Buy_SellIndicator = 256;
            _oertr.Price = 78965;
            _oertr.OrderNumber = OrderNumber;

            PFHolder _pf =	GetPFOnConfirmation (DataPacket.RawSerialize (_oertr));

            Console.WriteLine ("From Confirmation PFNumber " + _pf.PF + " CID " + _pf.CID );
            //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^=======================

            //^^^^^^^^^^^^^^^^^^^^^^ After any order event other than Order Confirmation  ============

            PFHolder _pf1 =	GetPFfromOrderNumber (OrderNumber);

            Console.WriteLine ("From other PFNumber " + _pf1.PF + " CID " + _pf1.CID );
            //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^=======================
        }
예제 #2
0
        private byte[] modifyfunction(MS_OM_REQUEST_TR obj)
        {
            var obj1 = new MS_OE_RESPONSE_TR()
            {
                TokenNo = obj.TokenNo,
                nnffield = obj.nnffield,
                TransactionCode = IPAddress.NetworkToHostOrder((short)(20074)),
                OrderNumber = obj.OrderNumber,
                Contr_dec_tr_Obj =
                {
                    InstrumentName = obj.Contr_dec_tr_Obj.InstrumentName,
                    Symbol = obj.Contr_dec_tr_Obj.Symbol,
                    ExpiryDate = obj.Contr_dec_tr_Obj.ExpiryDate,
                    StrikePrice = obj.Contr_dec_tr_Obj.StrikePrice,
                    OptionType = obj.Contr_dec_tr_Obj.OptionType
                },
                AccountNumber = obj.AccountNumber,
                Buy_SellIndicator = obj.Buy_SellIndicator,
                DisclosedVolume = obj.DisclosedVolume,
                Volume = obj.Volume,
                Price = obj.Price,
                Open_Close = obj.Open_Close,
                TraderId = obj.TraderId,
                BrokerId = Encoding.ASCII.GetBytes(obj.TraderId.ToString()),
            };
            concurrent.TryUpdate((long)1100100258 + count, obj1, obj1);
			Console.WriteLine ("20040 Volume"+IPAddress.HostToNetworkOrder(obj1.Volume));
            return DataPacket.RawSerialize(obj1);
        }
예제 #3
0
        public byte[] logicclass(MS_OM_REQUEST_TR obj_1ms)
        {
			return tradeconferm(obj_1ms);
            if (_concurrentDataDictionary.TryGetValue(IPAddress.HostToNetworkOrder(obj_1ms.TokenNo), out _TempFP) == true)
            {


                if (IPAddress.HostToNetworkOrder(obj_1ms.Buy_SellIndicator) == 1)
                {
                    if (IPAddress.HostToNetworkOrder(obj_1ms.Price) <= _concurrentDataDictionary[IPAddress.HostToNetworkOrder(obj_1ms.TokenNo)].MAXBID)
                    {
                        MS_OE_RESPONSE_TR obj_21 = new MS_OE_RESPONSE_TR
                        {
                            TransactionCode = IPAddress.NetworkToHostOrder((short)20073),
                            ReasonCode = IPAddress.NetworkToHostOrder((short)0),
                            BookType = IPAddress.NetworkToHostOrder((short)1),
                            GoodTillDate = IPAddress.NetworkToHostOrder(0),
                            st_ord_flg_obj = new ST_ORDER_FLAGS
                            {
                                STOrderFlagIn = GetBitsToByteValue(0, 0, 0, 1, 0, 0, 0, 0),
                                STOrderFlagOut = GetBitsToByteValue(0, 0, 0, 0, 0, 0, 0, 0),
                            },
                            obj_add_order_flg = new ADDITIONAL_ORDER_FLAGS
                            {
                                Reserved1 = 2
                            },
                            TokenNo = obj_1ms.TokenNo,
                            Contr_dec_tr_Obj =
                            {
                                InstrumentName = obj_1ms.Contr_dec_tr_Obj.InstrumentName,
                                Symbol = obj_1ms.Contr_dec_tr_Obj.Symbol,
                                ExpiryDate = obj_1ms.Contr_dec_tr_Obj.ExpiryDate,
                                StrikePrice = obj_1ms.Contr_dec_tr_Obj.StrikePrice,
                                OptionType = obj_1ms.Contr_dec_tr_Obj.OptionType
                            },
                            AccountNumber = obj_1ms.AccountNumber,
                            Buy_SellIndicator = obj_1ms.Buy_SellIndicator,
                            DisclosedVolume = obj_1ms.DisclosedVolume,
                            Volume = obj_1ms.Volume,
                            Price = obj_1ms.Price,
                            Open_Close = obj_1ms.Open_Close,
							UserId = obj_1ms.UserId, //IPAddress.NetworkToHostOrder(30072),
                            BranchId = IPAddress.NetworkToHostOrder((short)4),
                            TraderId = IPAddress.NetworkToHostOrder(30072),
                            BrokerId = Encoding.ASCII.GetBytes("12468"),
                            Settlor = Encoding.ASCII.GetBytes("".ToUpper().PadRight(12)),
                            Pro_ClientIndicator = IPAddress.NetworkToHostOrder((short)2),
                            nnffield = obj_1ms.nnffield,
                        };
                        obj_1ms.Pro_ClientIndicator = IPAddress.NetworkToHostOrder((short)2);
                        _concortdict[IPAddress.NetworkToHostOrder(obj_1ms.TokenNo)][IPAddress.NetworkToHostOrder(obj_1ms.Buy_SellIndicator)].AddOrUpdate(IPAddress.NetworkToHostOrder((long)obj_1ms.OrderNumber), obj_21, (k, d) => obj_21);
						return modifyfunction(obj_1ms);
                    }
                    else if (IPAddress.HostToNetworkOrder(obj_1ms.Price) > _concurrentDataDictionary[IPAddress.HostToNetworkOrder(obj_1ms.TokenNo)].MAXBID)
                    {
                        MS_OE_RESPONSE_TR orresponce = new MS_OE_RESPONSE_TR();
                        _concortdict[IPAddress.NetworkToHostOrder(obj_1ms.TokenNo)][IPAddress.NetworkToHostOrder(obj_1ms.Buy_SellIndicator)].TryRemove(IPAddress.NetworkToHostOrder((long)obj_1ms.OrderNumber), out orresponce);
                        return tradeconferm(obj_1ms);
                    }
                }
                else if (IPAddress.HostToNetworkOrder(obj_1ms.Buy_SellIndicator) == 2)
                {
                    if (IPAddress.HostToNetworkOrder(obj_1ms.Price) >= _concurrentDataDictionary[IPAddress.HostToNetworkOrder(obj_1ms.TokenNo)].MINASK)
                    {
                        return modifyfunction(obj_1ms);
                    }
                    else if (IPAddress.HostToNetworkOrder(obj_1ms.Price) < _concurrentDataDictionary[IPAddress.HostToNetworkOrder(obj_1ms.TokenNo)].MINASK)
                    {
                        return tradeconferm(obj_1ms);
                    }
                }
            }
            byte[] buff = { };
            return buff;
        }
예제 #4
0
		public byte[] tradeconferm_manual2(MS_OE_RESPONSE_TR obj)
		{
			var obj1 = new MS_TRADE_CONFIRM_TR()
			{

				TransactionCode = IPAddress.NetworkToHostOrder((short)(20222)),
				ResponseOrderNumber = obj.OrderNumber,

				Contr_dec_tr_Obj =
				{
					InstrumentName = obj.Contr_dec_tr_Obj.InstrumentName,
					Symbol = obj.Contr_dec_tr_Obj.Symbol,
					ExpiryDate = obj.Contr_dec_tr_Obj.ExpiryDate,
					StrikePrice = obj.Contr_dec_tr_Obj.StrikePrice,
					OptionType = obj.Contr_dec_tr_Obj.OptionType,

				},
				AccountNumber = obj.AccountNumber,
				Buy_SellIndicator = obj.Buy_SellIndicator,
				DisclosedVolume = obj.DisclosedVolume,
				FillQuantity =IPAddress.NetworkToHostOrder(IPAddress.HostToNetworkOrder(obj.Volume)-25),

				Price =IPAddress.NetworkToHostOrder(R_obj.Next(10000,100000)), //obj.Price,
				OpenClose = obj.Open_Close,
				TraderId = obj.TraderId,
				BrokerId = obj.BrokerId,
				Token = obj.TokenNo,
				VolumeFilledToday = obj.VolumeFilledToday,
				RemainingVolume = obj.TotalVolumeRemaining,
				FillNumber = IPAddress.NetworkToHostOrder(FillNumber),

				FillPrice=IPAddress.NetworkToHostOrder(R_obj.Next(10000,100000)),

			};
			FillNumber += 1;
			//Console.WriteLine ("FillQuantity1  "+IPAddress.HostToNetworkOrder(obj.Volume));
			Console.WriteLine ("Buy_SellIndicator 20222 = "+IPAddress.HostToNetworkOrder(obj.Buy_SellIndicator));

			return DataPacket.RawSerialize(obj);
		}
예제 #5
0
		private byte[] cancelfunction(MS_OM_REQUEST_TR obj)
		{
			var obj1 = new MS_OE_RESPONSE_TR()
			{
				TransactionCode = IPAddress.NetworkToHostOrder((short)(20075)),
				OrderNumber = obj.OrderNumber,
				Contr_dec_tr_Obj =
				{
					InstrumentName = obj.Contr_dec_tr_Obj.InstrumentName,
					Symbol = obj.Contr_dec_tr_Obj.Symbol,
					ExpiryDate = obj.Contr_dec_tr_Obj.ExpiryDate,
					StrikePrice = obj.Contr_dec_tr_Obj.StrikePrice,
					OptionType = obj.Contr_dec_tr_Obj.OptionType
				},
				AccountNumber = obj.AccountNumber,
				Buy_SellIndicator = obj.Buy_SellIndicator,
				DisclosedVolume = obj.DisclosedVolume,
				Volume = obj.Volume,
				Price = obj.Price,
				Open_Close = obj.Open_Close,
				TraderId = obj.TraderId,
				BrokerId = obj.BrokerId,
				nnffield = obj.nnffield,
				TokenNo = obj.TokenNo
			};
			MS_OE_RESPONSE_TR b = new MS_OE_RESPONSE_TR();
			concurrent.TryRemove((long)DoubleEndianChange(obj.OrderNumber), out b);
			return DataPacket.RawSerialize(obj1);
		}
예제 #6
0
        public void SIGN_ON_REQUEST_OUT(byte[] buffer)  //--2301
        {
			lock(_oblock)
			{
            byte[] buf = { };
            buffer = buffer.Skip(26).ToArray();
            //IPAddress.HostToNetworkOrder (BitConverter.ToInt16 (buffer, 0))

            if (buffer.Length != 40)
            {
                var _checkval = (MS_SYSTEM_INFO_REQ)DataPacket.RawDeserialize(buffer, typeof(MS_SYSTEM_INFO_REQ));



                int trcode = IPAddress.NetworkToHostOrder(_checkval.header_obj.TransactionCode);

                switch (trcode)
                {
                    case 2300:
                        MS_SIGNON obj = (MS_SIGNON)DataPacket.RawDeserialize(buffer, typeof(MS_SIGNON));
                        obj.header_obj.TransactionCode = IPAddress.NetworkToHostOrder((short)2301);
                        obj.header_obj.ErrorCode = IPAddress.NetworkToHostOrder((short)0);
                        obj.BrokerStatus = Convert.ToByte('A');
                        obj.MemberType = IPAddress.NetworkToHostOrder((short)2);
                        obj.ClearingStatus = Convert.ToByte('A');
                        buf = Logic.Instance.GetPF(DataPacket.RawSerialize(obj));
                        sendbuffer(buf);
                        break;
                    case 1600:
                        MS_SYSTEM_INFO_REQ obj1 = (MS_SYSTEM_INFO_REQ)DataPacket.RawDeserialize(buffer, typeof(MS_SYSTEM_INFO_REQ));
                        MS_SYSTEM_INFO_DATA objdata = new MS_SYSTEM_INFO_DATA();
                        objdata.SolicitorPeriod = IPAddress.NetworkToHostOrder((short)0);
                        objdata.header_obj.AlphaChar = obj1.header_obj.AlphaChar;
                        objdata.header_obj.TransactionCode = IPAddress.NetworkToHostOrder((short)1601);
                        objdata.header_obj.TimeStamp1 = obj1.header_obj.TimeStamp1;
                        objdata.header_obj.TimeStamp2 = obj1.header_obj.TimeStamp2;
                        objdata.header_obj.Timestamp = obj1.header_obj.Timestamp;
                        objdata.header_obj.ErrorCode = obj1.header_obj.ErrorCode;
                        objdata.header_obj.LogTime = obj1.header_obj.LogTime;
                        objdata.header_obj.MessageLength = obj1.header_obj.MessageLength;
                        objdata.header_obj.TraderId = obj1.header_obj.TraderId;
                        objdata.st_obj.Normal = IPAddress.NetworkToHostOrder((short)0);
                        objdata.st_ex_obj.Normal = IPAddress.NetworkToHostOrder((short)0);
                        objdata.st_pl_obj.Normal = IPAddress.NetworkToHostOrder((short)0);
                        objdata.UpdatePortfolio = Convert.ToByte('a');
                        objdata.MarketIndex = 0;
                        objdata.DefaultSettlementPeriod_normal = IPAddress.NetworkToHostOrder((short)0);
                        objdata.DefaultSettlementPeriod_spot = IPAddress.NetworkToHostOrder((short)0);
                        objdata.DefaultSettlementPeriod_auction = IPAddress.NetworkToHostOrder((short)0);
                        objdata.CompetitorPeriod = IPAddress.NetworkToHostOrder((short)0);
                        objdata.SolicitorPeriod = IPAddress.NetworkToHostOrder((short)0);
                        objdata.WarningPercent = IPAddress.NetworkToHostOrder((short)0);
                        objdata.VolumeFreezePercent = IPAddress.NetworkToHostOrder((short)0);
                        objdata.SnapQuoteTime = IPAddress.NetworkToHostOrder((short)0);
                        objdata.Reserved1 = IPAddress.NetworkToHostOrder((short)0);
                        objdata.BoardLotQuantity = IPAddress.NetworkToHostOrder(0);
                        objdata.TickSize = IPAddress.NetworkToHostOrder(0);
                        objdata.MaximumGtcDays = IPAddress.NetworkToHostOrder((short)0);
                        objdata.st_stoc_obj.Reserved = Convert.ToByte('r');
                        objdata.st_stoc_obj.Reserved2 = Convert.ToByte('r');
                        objdata.DisclosedQuantityPercentAllowed = IPAddress.NetworkToHostOrder((short)0);
                        objdata.RiskFreeInterestRate = IPAddress.NetworkToHostOrder((short)0);
                        buf = Logic.Instance.GetPF(DataPacket.RawSerialize(objdata));
                        int lth = buf.Length;
                        sendbuffer(buf);
                        break;
				case 20000:
						var obj_1 = (MS_OE_REQUEST_TR)DataPacket.RawDeserialize (buffer, typeof(MS_OE_REQUEST_TR));
					//UDP_Reciever.Instance.Subscribe = IPAddress.NetworkToHostOrder (obj_1.TokenNo);
					Console.WriteLine ("**********************************************************************\n\n\n\n");
					Console.WriteLine (" TransactionCode recieved  \t" + trcode + "\t buffer.Length " + buffer.Length + "\t Buy_SellIndicator = " + IPAddress.HostToNetworkOrder (obj_1.Buy_SellIndicator) + "\tTokenNo=" + IPAddress.HostToNetworkOrder (obj_1.TokenNo)+" Price :"+IPAddress.HostToNetworkOrder(obj_1.Price));
					Console.WriteLine ("**********************************************************************\n\n\n\n");

					UDP_RecieverData.Instance.Subscribe = IPAddress.HostToNetworkOrder (obj_1.TokenNo);
					var obj_2 = new MS_OE_RESPONSE_TR {
						TransactionCode = IPAddress.NetworkToHostOrder ((short)20073),
						ReasonCode = IPAddress.NetworkToHostOrder ((short)0),
						BookType = IPAddress.NetworkToHostOrder ((short)1),
						GoodTillDate = IPAddress.NetworkToHostOrder (0),
						st_ord_flg_obj = new ST_ORDER_FLAGS {
							STOrderFlagIn = GetBitsToByteValue (0, 0, 0, 1, 0, 0, 0, 0),
							STOrderFlagOut = GetBitsToByteValue (0, 0, 0, 0, 0, 0, 0, 0),
						},
						obj_add_order_flg = new ADDITIONAL_ORDER_FLAGS {
							Reserved1 = 2
						},
						TokenNo = obj_1.TokenNo,
						Contr_dec_tr_Obj = {
							InstrumentName = obj_1.Contr_dec_tr_Obj.InstrumentName,
							Symbol = obj_1.Contr_dec_tr_Obj.Symbol,
							ExpiryDate = obj_1.Contr_dec_tr_Obj.ExpiryDate,
							StrikePrice = obj_1.Contr_dec_tr_Obj.StrikePrice,
							OptionType = obj_1.Contr_dec_tr_Obj.OptionType
						},
						AccountNumber = obj_1.AccountNumber,
						Buy_SellIndicator = obj_1.Buy_SellIndicator,
						DisclosedVolume = obj_1.DisclosedVolume,
						Volume = obj_1.Volume,//IPAddress.NetworkToHostOrder(obj_1), //obj_1.Volume,
						Price = obj_1.Price,
						Open_Close = obj_1.Open_Close,
						UserId = obj_1.UserId, //IPAddress.NetworkToHostOrder (30072),
						BranchId = IPAddress.NetworkToHostOrder ((short)4),
						TraderId = obj_1.UserId, //IPAddress.NetworkToHostOrder (30072),
						BrokerId = Encoding.ASCII.GetBytes ("12468"),
						Settlor = Encoding.ASCII.GetBytes ("".ToUpper ().PadRight (12)),
						Pro_ClientIndicator = IPAddress.NetworkToHostOrder ((short)2),
						nnffield = obj_1.nnffield,

					};
					Console.WriteLine ("20000 Volume"+IPAddress.HostToNetworkOrder(obj_2.Volume));
					obj_2.Pro_ClientIndicator = IPAddress.NetworkToHostOrder ((short)2);
					count += 1;
					obj_2.OrderNumber = DoubleEndianChange (Convert.ToInt64 (DateTime.Now.ToString ("HHmmssfff")) + count);
					//  obj_2.OrderNumber =(long) DoubleEndianChange( 1100100258 + count);
					//Console.WriteLine(" Buy_SellIndicator  "+IPAddress.HostToNetworkOrder(obj_2.Buy_SellIndicator));
					concurrent.TryAdd ((long)1100100258 + count, obj_2);
					sendbuffer (Logic.Instance.GetPF (DataPacket.RawSerialize (obj_2)));
					if (!UDP_RecieverData.Instance.TokenData.ContainsKey (IPAddress.HostToNetworkOrder (obj_1.TokenNo))) {
						UDP_RecieverData.Instance.TokenData [IPAddress.HostToNetworkOrder (obj_1.TokenNo)] = new FinalPrice ();
					}
						FinalPrice _objFinal=new FinalPrice();
					if (UDP_RecieverData.Instance.TokenData.ContainsKey (IPAddress.HostToNetworkOrder (obj_1.TokenNo))) {
							
						_objFinal = UDP_RecieverData.Instance.TokenData [IPAddress.HostToNetworkOrder (obj_1.TokenNo)];
					}
					if (IPAddress.HostToNetworkOrder (obj_1.Buy_SellIndicator) == 1 && IPAddress.HostToNetworkOrder (obj_1.Price) == 0)
					{
						Console.WriteLine (" 20000 Client Price  0:"+IPAddress.HostToNetworkOrder (obj_1.Price)
								+" Market Bid Price "+ _objFinal.MAXBID
								+" Market Ask Price "+ _objFinal.MINASK
								+"Buy_SellIndicator "+IPAddress.HostToNetworkOrder (obj_1.Buy_SellIndicator)
							);
						obj_2.Price =IPAddress.NetworkToHostOrder( _objFinal.MINASK);
						sendbuffer (Logic.Instance.GetPF (tradeconferm_manual (obj_2)));
						return;
					}
					else if (IPAddress.HostToNetworkOrder (obj_1.Buy_SellIndicator) == 2 && IPAddress.HostToNetworkOrder (obj_1.Price) == 0)
					{
							Console.WriteLine (" 20000 Client Price  0:"+IPAddress.HostToNetworkOrder (obj_1.Price)
								+" Market Bid Price "+ _objFinal.MAXBID
								+" Market Ask Price "+ _objFinal.MINASK
								+"Buy_SellIndicator "+IPAddress.HostToNetworkOrder (obj_1.Buy_SellIndicator)
								+"Tokenno"+IPAddress.HostToNetworkOrder (obj_1.TokenNo)
							);
						obj_2.Price =IPAddress.NetworkToHostOrder( _objFinal.MAXBID);
						sendbuffer (Logic.Instance.GetPF (tradeconferm_manual (obj_2)));
						return;
					}
					if (IPAddress.HostToNetworkOrder (obj_1.Buy_SellIndicator) == 1) {
						if (IPAddress.HostToNetworkOrder (obj_1.Price) >= _objFinal.MINASK && _objFinal.MINASK>0) {
								Console.WriteLine (" 20000 Client Price without && if:"+IPAddress.HostToNetworkOrder (obj_1.Price)
									+" Market Bid Price "+ _objFinal.MAXBID
									+" Market Ask Price "+ _objFinal.MINASK
									+"Buy_SellIndicator "+IPAddress.HostToNetworkOrder (obj_1.Buy_SellIndicator)
									+"Tokenno"+IPAddress.HostToNetworkOrder (obj_1.TokenNo)
								);
								obj_2.Price =IPAddress.NetworkToHostOrder( _objFinal.MINASK);
							sendbuffer (Logic.Instance.GetPF (tradeconferm_manual (obj_2)));
							}
		
					}

					if (IPAddress.HostToNetworkOrder (obj_1.Buy_SellIndicator) == 2) {

							if (IPAddress.HostToNetworkOrder (obj_1.Price) <= _objFinal.MAXBID) {

								Console.WriteLine (" 20000 Client Price without && if:"+IPAddress.HostToNetworkOrder (obj_1.Price)
									+" Market Bid Price "+ _objFinal.MAXBID
									+" Market Ask Price "+ _objFinal.MINASK
									+"Buy_SellIndicator "+IPAddress.HostToNetworkOrder (obj_1.Buy_SellIndicator)
									+"Tokenno"+IPAddress.HostToNetworkOrder (obj_1.TokenNo)
								);
								obj_2.Price =IPAddress.NetworkToHostOrder( _objFinal.MAXBID);
								sendbuffer (Logic.Instance.GetPF (tradeconferm_manual (obj_2)));

						}
					}



				
                        break;
				case 20040:
						var obj_1ms = (MS_OM_REQUEST_TR)DataPacket.RawDeserialize (buffer, typeof(MS_OM_REQUEST_TR));
					if (UDP_RecieverData.Instance.TokenData.ContainsKey (IPAddress.HostToNetworkOrder (obj_1ms.TokenNo))) {
						var _MobjFinal = UDP_RecieverData.Instance.TokenData [IPAddress.HostToNetworkOrder (obj_1ms.TokenNo)];
					
						sendbuffer (Logic.Instance.GetPF (modifyfunction (obj_1ms)));
						if (IPAddress.HostToNetworkOrder (obj_1ms.Buy_SellIndicator) == 1) {

								if (IPAddress.HostToNetworkOrder (obj_1ms.Price) >= _MobjFinal.MINASK && _MobjFinal.MINASK > 0) {
									Console.WriteLine ("Client Price 20040 :" + IPAddress.HostToNetworkOrder (obj_1ms.Price) 
										+ " Market Ask Price " + _MobjFinal.MINASK
										+"Buy_SellIndicator "+IPAddress.HostToNetworkOrder (obj_1ms.Buy_SellIndicator)
										+"TokenNO "+IPAddress.HostToNetworkOrder (obj_1ms.TokenNo)
									);
									obj_1ms.Price =IPAddress.NetworkToHostOrder( _MobjFinal.MINASK);
								sendbuffer (Logic.Instance.GetPF (tradeconferm_Mod (obj_1ms)));
							} 
						} else {

								if (IPAddress.HostToNetworkOrder (obj_1ms.Price) <= _MobjFinal.MAXBID) {

									Console.WriteLine ("Client Price 20040 :" + IPAddress.HostToNetworkOrder (obj_1ms.Price) 
										+ " Market Ask Price " + _MobjFinal.MAXBID
										+"Buy_SellIndicator "+IPAddress.HostToNetworkOrder (obj_1ms.Buy_SellIndicator)
										+"TokenNO "+IPAddress.HostToNetworkOrder (obj_1ms.TokenNo)
									);
									obj_1ms.Price =IPAddress.NetworkToHostOrder( _MobjFinal.MAXBID);
								sendbuffer (Logic.Instance.GetPF (tradeconferm_Mod (obj_1ms)));
							} 
						}

						//Console.WriteLine (" 20074 "+DoubleEndianChange(obj_1ms.OrderNumber));

					}

                        break;
                    case 20070:
                        var obj_1cal = (MS_OM_REQUEST_TR)DataPacket.RawDeserialize(buffer, typeof(MS_OM_REQUEST_TR));
					sendbuffer(Logic.Instance.GetPF(cancelfunction(obj_1cal)));
						Console.WriteLine (" 20075 "+DoubleEndianChange(obj_1cal.OrderNumber)+" Tokenno"+IPAddress.HostToNetworkOrder (obj_1cal.TokenNo));
					break;

				case 2100:
					MS_SPD_OE_REQUEST msoespd = (MS_SPD_OE_REQUEST)DataPacket.RawDeserialize (buffer, typeof(MS_SPD_OE_REQUEST));
					msoespd.OrderNumber1 = DoubleEndianChange (Convert.ToInt64 (DateTime.Now.ToString ("HHmmssfff")) + count);
                        //    msoespd.OrderNumber1 = DoubleEndianChange(1110111258 + count);
                       /* if (count % 2 == 0)
                        {
                            msoespd.header_obj.TransactionCode = IPAddress.NetworkToHostOrder((short)2127);
                            sendbuffer(Logic.Instance.GetPF(DataPacket.RawSerialize(msoespd)));
                            return;
                        }*/
					++count;
					Console.WriteLine ("BuySell1 "+IPAddress.HostToNetworkOrder(msoespd.BuySell1));
					Console.WriteLine ("leg2 BuySell2 "+IPAddress.HostToNetworkOrder(msoespd.leg2.BuySell2));
                        msoespd.header_obj.TransactionCode = IPAddress.NetworkToHostOrder((short)2124);
                        sendbuffer(Logic.Instance.GetPF(DataPacket.RawSerialize(msoespd)));

                        tradeconfermiocistleg(msoespd);//
					sendbuffer(Logic.Instance.GetPF(tradeconfermioc2ndleg(msoespd)));

                        //sendbuffer(Logic.Instance.GetPF(tradeconfermioc2ndleg(msoespd)));
					//sendbuffer (Logic.Instance.GetPF (tradeconferm_manual (msoespd)));
                        break;
                }
            }
            else
            {
                var _checkval = (Message_Header)DataPacket.RawDeserialize(buffer, typeof(Message_Header));
                int trcode = IPAddress.NetworkToHostOrder(_checkval.TransactionCode);
            }
        }
		}