Exemple #1
0
 private static void Initialize_Fields(ScripDetails objscrip, ref MarketWatchModel item, int DecimalPoint, int ScripCode)
 {
     try
     {
         if (objscrip != null)
         {
             item.BuyQualtity1  = objscrip.BuyQtyL;
             item.BuyRate1      = objscrip.BuyRateL / Math.Pow(10, DecimalPnt);
             item.SellQuantity1 = objscrip.SellQtyL;
             item.SellRate1     = objscrip.SellRateL / Math.Pow(10, DecimalPnt);
             item.LTP1          = objscrip.lastTradeRateL / Math.Pow(10, DecimalPnt);
             item.NoofBidBuy1   = objscrip.NoOfBidBuyL;
             item.NoOfBidSell1  = objscrip.NoOfBidSellL;
             item.OpenRateL     = objscrip.openRateL / Math.Pow(10, DecimalPnt);
             item.CloseRateL    = objscrip.closeRateL / Math.Pow(10, DecimalPnt);
             item.HighRateL     = objscrip.highRateL / Math.Pow(10, DecimalPnt);
             item.LowRateL      = objscrip.lowRateL / Math.Pow(10, DecimalPnt);
             item.TotBuyQtyL    = objscrip.totBuyQtyL;
             item.TotSellQtyL   = objscrip.totSellQtyL;
             item.WtAvgRateL    = objscrip.wtAvgRateL / Math.Pow(10, DecimalPnt);
             item.CtValue       = objscrip.TrdValue / Math.Pow(10, DecimalPnt);
             item.CtVolume      = objscrip.TrdVolume;
         }
         else
         {
             item.BuyQualtity1  = 0;
             item.BuyRate1      = 0;
             item.SellQuantity1 = 0;
             item.SellRate1     = 0;
             item.LTP1          = 0;
             item.NoofBidBuy1   = 0;
             item.NoOfBidSell1  = 0;
             item.OpenRateL     = 0;
             item.CloseRateL    = 0;
             item.HighRateL     = 0;
             item.LowRateL      = 0;
             item.TotBuyQtyL    = 0;
             item.TotSellQtyL   = 0;
             item.WtAvgRateL    = 0;
             item.CtVolume      = 0;
             item.CtValue       = 0;
         }
         item.IsVisible = true;
         //if (MasterSharedMemory.objDicDP.ContainsKey(ScripCode))
         //{
         //    item.FiftyTwoHigh = MasterSharedMemory.objDicDP[ScripCode].WeeksHighprice / Math.Pow(10, DecimalPnt);
         //    item.FiftyTwoLow = MasterSharedMemory.objDicDP[ScripCode].WeeksLowprice / Math.Pow(10, DecimalPnt);
         //}
         //else
         {
             item.FiftyTwoHigh = 0;
             item.FiftyTwoLow  = 0;
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #2
0
        public static void objBroadCastProcessor_OnBroadCastRecievedNew(ScripDetails objScripDetails)
        {
            try
            {
                int scripCode = objScripDetails.ScriptCode;
                //ScripDetails objScripDetails = BroadcastMasterMemory.objScripDetailsConDict.Where(x => x.Key == scripCode).Select(x => x.Value).FirstOrDefault();
                if (objScripDetails != null && ObjTouchlineDataCollection.Count > 0)
                {
                    List <int> list = new List <int>();
                    list = ObjTouchlineDataCollection.Where(i => i.Scriptcode1 == scripCode).Select(x => ObjTouchlineDataCollection.IndexOf(x)).ToList();

                    for (int i = 0; i < list.Count; i++)
                    {
                        UpdateGrid(list[i], objScripDetails);
                    }
                }
                // BestFiveVM.objBroadCastProcessor_OnBroadCastRecieved(scripCode);
            }
            catch (Exception ex)
            {
                ExceptionUtility.LogError(ex);
                return;
            }
        }
        private void UpdateScripTicker(object objreceiveBytes)
        {
            byte[] receiveBytes = objreceiveBytes as byte[];
            int    offset       = 0;

            if (receiveBytes == null)
            {
                return;
            }
            Int32 msgtype = Swap32(BitConverter.ToInt32(receiveBytes, offset));

            offset += sizeof(Int32);

            try
            {
                Int32 reservefieldL1 = Swap32(BitConverter.ToInt32(receiveBytes, offset));
                offset += sizeof(Int32);
                Int32 sequenceNoS = Swap32(BitConverter.ToInt32(receiveBytes, offset));
                offset += sizeof(Int32);
                offset += sizeof(Int16); // Not Processsed Reservefield_us
                Int16 hourS = Swap16(BitConverter.ToInt16(receiveBytes, offset));
                offset += sizeof(Int16);
                Int16 minS = Swap16(BitConverter.ToInt16(receiveBytes, offset));
                offset += sizeof(Int16);
                Int16 secS = Swap16(BitConverter.ToInt16(receiveBytes, offset));
                offset += sizeof(Int16);
                Int16 mSecS = Swap16(BitConverter.ToInt16(receiveBytes, offset));
                starttime = hourS + ":" + minS + ":" + secS + ":" + mSecS;
                offset   += sizeof(Int16);
                Int16 fillerS = Swap16(BitConverter.ToInt16(receiveBytes, offset));
                offset += sizeof(Int16);
                Int16 tradingSessionS = Swap16(BitConverter.ToInt16(receiveBytes, offset));
                offset += sizeof(Int16);
                Int16 noofRecsS = Swap16(BitConverter.ToInt16(receiveBytes, offset));
                offset += sizeof(Int16);
                short noRecS;
                for (noRecS = 0; noRecS < noofRecsS; noRecS++)
                {
                    //Code For COunters
                    //CountbeforeMaterFilter++;
                    ScripDetails buysellObj = new ScripDetails();
                    if (offset < receiveBytes.Length)
                    {
                        Int32 scripCodeL = Swap32(BitConverter.ToInt32(receiveBytes, offset));
                        offset += sizeof(Int32);

                        Int32 noOfTradesL = Swap32(BitConverter.ToInt32(receiveBytes, offset));
                        offset += sizeof(Int32);

                        Int32 tradedVolumeL = Swap32(BitConverter.ToInt32(receiveBytes, offset));
                        offset += sizeof(Int32);

                        Int32 tradedValueL = Swap32(BitConverter.ToInt32(receiveBytes, offset));
                        offset += sizeof(Int32);

                        List <byte> lst = new List <byte>();
                        lst.Add(receiveBytes[offset]);
                        lst.Add(new byte());
                        char Unit_c;
                        Unit_c = BitConverter.ToChar(lst.ToArray <byte>(), 0);
                        // return cc.ToString();

                        // char Unit_c = BitConverter.ToChar(receiveBytes[offset]);//(TmpDataPtr1[DataPtr]);
                        offset += sizeof(byte);

                        //char Trend_c = (TmpDataPtr1[DataPtr]);
                        offset += sizeof(byte);

                        //char SunShine_c = (TmpDataPtr1[DataPtr]); //for sunshine flag which is not used.
                        offset += sizeof(byte);

                        //char AlNnFlag_c = (TmpDataPtr1[DataPtr]);
                        offset += sizeof(byte);

                        Int16 marketTypeS = Swap16(BitConverter.ToInt16(receiveBytes, offset));
                        offset += sizeof(Int16);

                        Int16 sessionNoS = Swap16(BitConverter.ToInt16(receiveBytes, offset));
                        offset += sizeof(Int16);

                        Int32 ltphr = receiveBytes[offset];
                        offset += sizeof(byte); // Not Processsed   Hour_c;
                        Int32 ltpmin = receiveBytes[offset];
                        offset += sizeof(byte); // Not Processsed   Min_c;
                        Int32 ltpsec = receiveBytes[offset];
                        offset += sizeof(byte); // Not Processsed   Sec_c;

                        string ltpmsec = string.Empty;

                        ltpmsec += receiveBytes[offset];
                        offset  += sizeof(byte);  // Not Processsed   LTPMillisec_c[3];
                        ltpmsec += receiveBytes[offset];
                        offset  += sizeof(byte);  // Not Processsed   LTPMillisec_c[3];
                        ltpmsec += receiveBytes[offset];
                        offset  += sizeof(byte);  // Not Processsed   LTPMillisec_c[3];
                        offset  += sizeof(byte);  // Not Processsed   ReserveField_c[3];
                        offset  += sizeof(byte);  // Not Processsed   ReserveField_c[3];
                        offset  += sizeof(short); // Not Processsed    Filler_s1;
                        offset  += sizeof(short); // Not Processsed    No_of_PricePoints_s;
                        offset  += sizeof(Int64); // Not Processsed    ReserveField_ll;

                        Int32 closePriceL = Swap32(BitConverter.ToInt32(receiveBytes, offset));
                        offset += sizeof(Int32);

                        Int32 lastTradeQtyL = Swap32(BitConverter.ToInt32(receiveBytes, offset));
                        offset += sizeof(Int32);

                        Int32 lastTradeRateL = Swap32(BitConverter.ToInt32(receiveBytes, offset));
                        offset += sizeof(Int32);

                        Int32 openRateL             = DecryptInt32(lastTradeRateL, receiveBytes, ref offset);
                        Int32 closeRateL            = DecryptInt32(lastTradeRateL, receiveBytes, ref offset);
                        Int32 highRateL             = DecryptInt32(lastTradeRateL, receiveBytes, ref offset);
                        Int32 lowRateL              = DecryptInt32(lastTradeRateL, receiveBytes, ref offset);
                        Int32 reserveFieldL         = DecryptInt32(lastTradeRateL, receiveBytes, ref offset);
                        Int32 indicativeEqPriceL    = DecryptInt32(lastTradeRateL, receiveBytes, ref offset);
                        Int32 indicativeEqQuantityL = DecryptInt32(lastTradeQtyL, receiveBytes, ref offset);
                        Int32 totBuyQtyL            = DecryptInt32(lastTradeQtyL, receiveBytes, ref offset);
                        Int32 totSellQtyL           = DecryptInt32(lastTradeQtyL, receiveBytes, ref offset);
                        Int32 lowerCktLmtL          = DecryptInt32(lastTradeRateL, receiveBytes, ref offset);
                        Int32 upperCktLmtL          = DecryptInt32(lastTradeRateL, receiveBytes, ref offset);
                        Int32 wtAvgRateL            = DecryptInt32(lastTradeRateL, receiveBytes, ref offset);

                        buysellObj.ScriptCode_BseToken_NseToken = scripCodeL;
                        buysellObj.lastTradeRateL = lastTradeRateL;
                        buysellObj.openRateL      = openRateL;
                        buysellObj.closeRateL     = closeRateL;
                        buysellObj.highRateL      = highRateL;
                        buysellObj.lowRateL       = lowRateL;
                        buysellObj.totBuyQtyL     = totBuyQtyL;
                        buysellObj.totSellQtyL    = totSellQtyL;
                        buysellObj.wtAvgRateL     = wtAvgRateL;
                        buysellObj.Unit_c         = Unit_c.ToString();

                        buysellObj.lastTradeQtyL   = lastTradeQtyL;
                        buysellObj.TrdVolume       = tradedVolumeL;
                        buysellObj.TrdValue        = tradedValueL;
                        buysellObj.LowerCtLmt      = lowerCktLmtL;
                        buysellObj.UprCtLmt        = upperCktLmtL;
                        buysellObj.NoOfTrades      = noOfTradesL;
                        buysellObj.IndicateEqPrice = indicativeEqPriceL;
                        buysellObj.IndicateEqQty   = indicativeEqQuantityL;
                        buysellObj.LastTradeTime   = string.Format("{0:00}", ltphr) + string.Format("{0:00}", ltpmin) + string.Format("{0:00}", ltpsec); //ltpmin.ToString() + ltpsec.ToString();

                        List <BestFive> lstBstFive = new List <BestFive>(5);

                        for (int i = 0; i < 5; i++)
                        {
                            short conv = BitConverter.ToInt16(receiveBytes, offset);
                            if (Swap16(conv) != 32766)
                            {
                                if (i == 0)
                                {
                                    BestFive bfObj1 = new BestFive
                                    {
                                        BuyRateL    = DecryptInt32(lastTradeRateL, receiveBytes, ref offset),
                                        BuyQtyL     = DecryptInt32(lastTradeQtyL, receiveBytes, ref offset),
                                        NoOfBidBuyL = DecryptInt32(lastTradeQtyL, receiveBytes, ref offset),
                                        FillerBuyL  = DecryptInt32(lastTradeQtyL, receiveBytes, ref offset),
                                    };

                                    lstBstFive.Add(bfObj1);
                                    buysellObj.BuyRateL    = bfObj1.BuyRateL;
                                    buysellObj.BuyQtyL     = bfObj1.BuyQtyL;
                                    buysellObj.NoOfBidBuyL = bfObj1.NoOfBidBuyL;
                                    buysellObj.FillerBuyL  = bfObj1.FillerBuyL;
                                    //lstBstFive.Add(buysellObj);
                                    //Code For COunters
                                    //buysellObj.startTime = starttime;
                                }
                                else
                                {
                                    BestFive bfObj1 = new BestFive();

                                    try
                                    {
                                        bfObj1.BuyRateL = DecryptInt32(lstBstFive[i - 1].BuyRateL,
                                                                       receiveBytes, ref offset);
                                        bfObj1.BuyQtyL = DecryptInt32(lstBstFive[i - 1].BuyQtyL, receiveBytes,
                                                                      ref offset);
                                        bfObj1.NoOfBidBuyL = DecryptInt32(lstBstFive[i - 1].NoOfBidBuyL,
                                                                          receiveBytes, ref offset);
                                        bfObj1.FillerBuyL = DecryptInt32(lstBstFive[i - 1].FillerBuyL,
                                                                         receiveBytes, ref offset);
                                        //Code For COunters
                                        //bfObj1.startTime = starttime;
                                        lstBstFive.Add(bfObj1);
                                    }
                                    catch (Exception e)
                                    {
                                        ExceptionUtility.LogError(e);
                                        MessageBox.Show(e.Message);
                                    }
                                }
                            }
                            else
                            {
                                offset += sizeof(short);

                                for (int j = 0; j < 5 - i; j++)
                                {
                                    BestFive bfObj = new BestFive();
                                    //Code For COunters
                                    // bfObj.startTime = starttime;
                                    lstBstFive.Add(bfObj);
                                }
                                break;
                            }
                        }

                        for (int i = 0; i < 5; i++)
                        {
                            if (Swap16(BitConverter.ToInt16(receiveBytes, offset)) != -32766)
                            {
                                if (i == 0)
                                {
                                    lstBstFive[i].SellRateL = DecryptInt32(lastTradeRateL, receiveBytes,
                                                                           ref offset);
                                    lstBstFive[i].SellQtyL = DecryptInt32(lastTradeQtyL, receiveBytes,
                                                                          ref offset);
                                    lstBstFive[i].NoOfBidSellL = DecryptInt32(lastTradeQtyL, receiveBytes,
                                                                              ref offset);
                                    lstBstFive[i].FillerSellL = DecryptInt32(lastTradeQtyL, receiveBytes,
                                                                             ref offset);
                                    buysellObj.SellRateL    = lstBstFive[i].SellRateL;
                                    buysellObj.SellQtyL     = lstBstFive[i].SellQtyL;
                                    buysellObj.NoOfBidSellL = lstBstFive[i].NoOfBidSellL;
                                    buysellObj.FillerSellL  = lstBstFive[i].FillerSellL;
                                    //Code For COunters
                                    //buysellObj.startTime=lstBstFive[i].startTime;
                                }
                                else
                                {
                                    lstBstFive[i].SellRateL = DecryptInt32(lstBstFive[i - 1].SellRateL,
                                                                           receiveBytes, ref offset);
                                    lstBstFive[i].SellQtyL = DecryptInt32(lstBstFive[i - 1].SellQtyL,
                                                                          receiveBytes, ref offset);
                                    lstBstFive[i].NoOfBidSellL = DecryptInt32(
                                        lstBstFive[i - 1].NoOfBidSellL, receiveBytes, ref offset);
                                    lstBstFive[i].FillerSellL = DecryptInt32(lstBstFive[i - 1].FillerSellL,
                                                                             receiveBytes, ref offset);
                                    //Code For COunters
                                    // buysellObj.startTime = starttime;
                                }
                            }
                            else
                            {
                                offset += sizeof(short);
                                break;
                            }
                        }

                        buysellObj.listBestFive = lstBstFive;
                        if (BroadcastMasterMemory.objScripDetailsConDict.ContainsKey(buysellObj.ScriptCode_BseToken_NseToken))
                        {
                            BroadcastMasterMemory.objScripDetailsConDict[buysellObj.ScriptCode_BseToken_NseToken] = buysellObj;
                        }
                        else
                        {
                            BroadcastMasterMemory.objScripDetailsConDict.TryAdd(buysellObj.ScriptCode_BseToken_NseToken, buysellObj);
                        }
                        //BestFiveWindowVM.UpdateBestWindow(lstBstFive1);
                        if (OnMessageTransmitted != null)
                        {
                            OnMessageTransmitted(buysellObj.ScriptCode_BseToken_NseToken);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ExceptionUtility.LogError(e);
                MessageBox.Show(e.Message);
            }
        }
Exemple #4
0
        private static void UpdateGrid(int index, ScripDetails _BstFive)
        {
            //if (this.ObjTouchlineDataCollection[index].IsVisible)
            //{
            //Code For COunters
            // int c;
            // CountUpdatedperView++;
            DecimalPnt = CommonFunctions.GetDecimal(ObjTouchlineDataCollection[index].Scriptcode1);
            int    num         = ObjTouchlineDataCollection[index].BuyQualtity1;
            double num2        = ObjTouchlineDataCollection[index].BuyRate1;
            int    num3        = ObjTouchlineDataCollection[index].SellQuantity1;
            double num4        = ObjTouchlineDataCollection[index].SellRate1;
            double ltpPrevious = ObjTouchlineDataCollection[index].LTP1;

            //Code For COunters
            //c=++ this.ObjTouchlineDataCollection[index].Counter;
            // WriteLog objWriteLog=new WriteLog();
            // objWriteLog.ScriptCode=ObjTouchlineDataCollection[index].ScriptId1;
            // objWriteLog.startTime=_BstFive.startTime;
            // objWriteLog.Count = c;
            // objWriteLog.BuyQtyL = _BstFive.BuyQtyL;
            // objWriteLog.BuyRateL = _BstFive.BuyRateL;
            // objWriteLog.SellQtyL = _BstFive.SellRateL;
            // objWriteLog.SellRateL = _BstFive.SellRateL;
            // objWriteLog.lastTradeRateL = _BstFive.lastTradeRateL;
            // objWriteLog.NoOfBidBuyL = _BstFive.NoOfBidBuyL;
            // objWriteLog.NoOfBidSellL = _BstFive.NoOfBidSellL;
            // objWriteLog.openRateL = _BstFive.openRateL;
            // objWriteLog.closeRateL = _BstFive.closeRateL;
            //_listWriteinFile.TryAdd(objWriteLog.Count, objWriteLog);
            //if (calculatetime)
            //{
            //    this.ObjTouchlineDataCollection[index].StartTime = _BstFive.startTime;
            //    calculatetime = false;
            //}
            //if (calculatetime1)
            //{
            //    this.ObjTouchlineDataCollection[index].StartTime1 = _BstFive.startTime;
            //    calculatetime1 = false;
            //      using (StreamWriter writer = new StreamWriter(@"E:\Deepshikha\IML.csv", false))
            //    {
            //        foreach (WriteLog line in _listWriteinFile.Values)
            //            writer.WriteLine(line.ScriptCode + ": " + line.startTime + ": " + line.Count + ": " + line.BuyQtyL + ": " +
            //                line.BuyRateL + ": " + line.SellQtyL + ": " + line.SellRateL
            //                + line.lastTradeRateL + ": " + line.NoOfBidBuyL + ": " +
            //                line.NoOfBidSellL + ": " + line.openRateL + ": " + line.closeRateL);
            //    }
            //}

            ObjTouchlineDataCollection[index].BuyQualtity1  = _BstFive.BuyQtyL;
            ObjTouchlineDataCollection[index].BuyRate1      = _BstFive.BuyRateL / Math.Pow(10, DecimalPnt);
            objTouchlineDataCollection[index].SellQuantity1 = _BstFive.SellQtyL;
            objTouchlineDataCollection[index].SellRate1     = _BstFive.SellRateL / Math.Pow(10, DecimalPnt);
            ObjTouchlineDataCollection[index].LTP1          = _BstFive.lastTradeRateL / Math.Pow(10, DecimalPnt);
            ObjTouchlineDataCollection[index].NoofBidBuy1   = _BstFive.NoOfBidBuyL;
            ObjTouchlineDataCollection[index].NoOfBidSell1  = _BstFive.NoOfBidSellL;
            ObjTouchlineDataCollection[index].OpenRateL     = _BstFive.openRateL / Math.Pow(10, DecimalPnt);
            ObjTouchlineDataCollection[index].CloseRateL    = _BstFive.closeRateL / Math.Pow(10, DecimalPnt);
            ObjTouchlineDataCollection[index].HighRateL     = _BstFive.highRateL / Math.Pow(10, DecimalPnt);
            ObjTouchlineDataCollection[index].LowRateL      = _BstFive.lowRateL / Math.Pow(10, DecimalPnt);
            ObjTouchlineDataCollection[index].TotBuyQtyL    = _BstFive.totBuyQtyL;
            ObjTouchlineDataCollection[index].TotSellQtyL   = _BstFive.totSellQtyL;
            ObjTouchlineDataCollection[index].WtAvgRateL    = _BstFive.wtAvgRateL / Math.Pow(10, DecimalPnt);
            ObjTouchlineDataCollection[index].CtVolume      = _BstFive.TrdVolume;
            ObjTouchlineDataCollection[index].CtValue       = _BstFive.TrdValue / Math.Pow(10, DecimalPnt);
            double LTP = ObjTouchlineDataCollection[index].LTP1;

            //   ObjTouchlineDataCollection.ListChanged += ObjTouchlineDataCollection_ListChanged;
            //if (!this.ObjTouchlineDataCollection[index].FirstTickExecuted)
            //{
            //    this.ObjTouchlineDataCollection[index].FirstTickExecuted = true;
            //}

            if (ObjTouchlineDataCollection[index].BuyQualtity1 != 0 && num != 0)
            {
                if (num < ObjTouchlineDataCollection[index].BuyQualtity1)
                {
                    ObjTouchlineDataCollection[index].PrevBuyQualtity1           = UtilityLoginDetails.GETInstance.UpTrendColorGlobal;
                    ObjTouchlineDataCollection[index].ForegroundColorBuyQuantity = "White";
                }
                else if (num > ObjTouchlineDataCollection[index].BuyQualtity1)
                {
                    ObjTouchlineDataCollection[index].PrevBuyQualtity1           = UtilityLoginDetails.GETInstance.DownTrendColorGlobal;
                    ObjTouchlineDataCollection[index].ForegroundColorBuyQuantity = "White";
                }

                else if (num == ObjTouchlineDataCollection[index].BuyQualtity1)
                {
                    ObjTouchlineDataCollection[index].ForegroundColorBuyQuantity = "White";
                    if (index % 2 != 0)
                    {
                        ObjTouchlineDataCollection[index].PrevBuyQualtity1 = "#FF333972";
                    }
                    else
                    {
                        ObjTouchlineDataCollection[index].PrevBuyQualtity1 = "#FF333972";
                    }
                }
            }
            else
            {
                ObjTouchlineDataCollection[index].ForegroundColorBuyQuantity = "White";
                if (index % 2 != 0)
                {
                    ObjTouchlineDataCollection[index].PrevBuyQualtity1 = "#FF333972";
                }
                else
                {
                    ObjTouchlineDataCollection[index].PrevBuyQualtity1 = "#FF333972";
                }
            }
            if (ObjTouchlineDataCollection[index].BuyRate1 != 0 && num2 != 0)
            {
                if (num2 < ObjTouchlineDataCollection[index].BuyRate1)
                {
                    ObjTouchlineDataCollection[index].PrevBuyRate1      = UtilityLoginDetails.GETInstance.UpTrendColorGlobal;
                    ObjTouchlineDataCollection[index].ForegroundBuyRate = "White";
                }
                else if (num2 > ObjTouchlineDataCollection[index].BuyRate1)
                {
                    ObjTouchlineDataCollection[index].PrevBuyRate1      = UtilityLoginDetails.GETInstance.DownTrendColorGlobal;
                    ObjTouchlineDataCollection[index].ForegroundBuyRate = "White";
                }
                else if (num2 == ObjTouchlineDataCollection[index].BuyRate1)
                {
                    ObjTouchlineDataCollection[index].ForegroundBuyRate = "White";
                    if (index % 2 != 0)
                    {
                        ObjTouchlineDataCollection[index].PrevBuyRate1 = "#FF333972";
                    }
                    else
                    {
                        ObjTouchlineDataCollection[index].PrevBuyRate1 = "#FF333972";
                    }
                }
            }
            else
            {
                ObjTouchlineDataCollection[index].ForegroundBuyRate = "White";
                if (index % 2 != 0)
                {
                    ObjTouchlineDataCollection[index].PrevBuyRate1 = "#FF333972";
                }
                else
                {
                    ObjTouchlineDataCollection[index].PrevBuyRate1 = "#FF333972";
                }
            }
            if (ObjTouchlineDataCollection[index].SellQuantity1 != 0 && num3 != 0)
            {
                if (num3 < ObjTouchlineDataCollection[index].SellQuantity1)
                {
                    ObjTouchlineDataCollection[index].PrevSellQuantity1 = UtilityLoginDetails.GETInstance.UpTrendColorGlobal;
                    ObjTouchlineDataCollection[index].ForegroundSellQ   = "White";
                }
                else if (num3 > ObjTouchlineDataCollection[index].SellQuantity1)
                {
                    ObjTouchlineDataCollection[index].PrevSellQuantity1 = UtilityLoginDetails.GETInstance.DownTrendColorGlobal;
                    ObjTouchlineDataCollection[index].ForegroundSellQ   = "White";
                }
                else if (num3 == ObjTouchlineDataCollection[index].SellQuantity1)
                {
                    ObjTouchlineDataCollection[index].ForegroundSellQ = "White";
                    if (index % 2 != 0)
                    {
                        ObjTouchlineDataCollection[index].PrevSellQuantity1 = "#FF333972";
                    }
                    else
                    {
                        ObjTouchlineDataCollection[index].PrevSellQuantity1 = "#FF333972";
                    }
                }
            }
            else
            {
                ObjTouchlineDataCollection[index].ForegroundSellQ = "White";
                if (index % 2 != 0)
                {
                    ObjTouchlineDataCollection[index].PrevSellQuantity1 = "#FF333972";
                }
                else
                {
                    ObjTouchlineDataCollection[index].PrevSellQuantity1 = "#FF333972";
                }
            }
            if (ObjTouchlineDataCollection[index].SellRate1 != 0 && num4 != 0)
            {
                if (num4 < ObjTouchlineDataCollection[index].SellRate1)
                {
                    ObjTouchlineDataCollection[index].PrevSellRate1   = UtilityLoginDetails.GETInstance.UpTrendColorGlobal;
                    ObjTouchlineDataCollection[index].ForegroundSellR = "White";
                }
                else if (num4 > ObjTouchlineDataCollection[index].SellRate1)
                {
                    ObjTouchlineDataCollection[index].PrevSellRate1   = UtilityLoginDetails.GETInstance.DownTrendColorGlobal;
                    ObjTouchlineDataCollection[index].ForegroundSellR = "White";
                }
                else if (num4 == ObjTouchlineDataCollection[index].SellRate1)
                {
                    ObjTouchlineDataCollection[index].ForegroundSellR = "White";
                    if (index % 2 != 0)
                    {
                        ObjTouchlineDataCollection[index].PrevSellRate1 = "#FF333972";
                    }
                    else
                    {
                        ObjTouchlineDataCollection[index].PrevSellRate1 = "#FF333972";
                    }
                }
            }
            else
            {
                ObjTouchlineDataCollection[index].ForegroundSellR = "White";
                if (index % 2 != 0)
                {
                    ObjTouchlineDataCollection[index].PrevSellRate1 = "#FF333972";
                }
                else
                {
                    ObjTouchlineDataCollection[index].PrevSellRate1 = "#FF333972";
                }
            }
            if (ltpPrevious == 0 && ObjTouchlineDataCollection[index].LTP1 != 0)
            {
                if (ObjTouchlineDataCollection[index].LTP1 > ObjTouchlineDataCollection[index].CloseRateL)
                {
                    ObjTouchlineDataCollection[index].PrevLTP1      = UtilityLoginDetails.GETInstance.UpTrendColorGlobal;
                    ObjTouchlineDataCollection[index].ForegroundLTP = "White";
                }
                else if (ObjTouchlineDataCollection[index].LTP1 < ObjTouchlineDataCollection[index].CloseRateL)
                {
                    ObjTouchlineDataCollection[index].PrevLTP1      = UtilityLoginDetails.GETInstance.DownTrendColorGlobal;
                    ObjTouchlineDataCollection[index].ForegroundLTP = "White";
                }
                else
                {
                    ObjTouchlineDataCollection[index].ForegroundLTP = "White";
                    ObjTouchlineDataCollection[index].PrevLTP1      = "#FF333972";
                }
            }
            else if (ObjTouchlineDataCollection[index].LTP1 != 0 && ltpPrevious != 0)
            {
                if (ltpPrevious < ObjTouchlineDataCollection[index].LTP1)
                {
                    ObjTouchlineDataCollection[index].PrevLTP1      = UtilityLoginDetails.GETInstance.UpTrendColorGlobal;
                    ObjTouchlineDataCollection[index].ForegroundLTP = "White";
                }
                else if (ltpPrevious > ObjTouchlineDataCollection[index].LTP1)
                {
                    ObjTouchlineDataCollection[index].PrevLTP1      = UtilityLoginDetails.GETInstance.DownTrendColorGlobal;
                    ObjTouchlineDataCollection[index].ForegroundLTP = "White";
                }
                else if (ltpPrevious == ObjTouchlineDataCollection[index].LTP1)
                {
                    ObjTouchlineDataCollection[index].ForegroundLTP = "White";
                    if (index % 2 != 0)
                    {
                        ObjTouchlineDataCollection[index].PrevLTP1 = "#FF333972";
                    }
                    else
                    {
                        ObjTouchlineDataCollection[index].PrevLTP1 = "#FF333972";
                    }
                }
            }
            else
            {
                ObjTouchlineDataCollection[index].ForegroundLTP = "White";
                if (index % 2 != 0)
                {
                    ObjTouchlineDataCollection[index].PrevLTP1 = "#FF333972";
                }
                else
                {
                    ObjTouchlineDataCollection[index].PrevLTP1 = "#FF333972";
                }
            }

            /*
             * if (LTP != 0 && ObjTouchlineDataCollection[index].CloseRateL != 0)
             * {
             *  if (LTP > ObjTouchlineDataCollection[index].CloseRateL)
             *  {
             *      ObjTouchlineDataCollection[index].PrevLTP1 = App.UpTrendColorGlobal;
             *      ObjTouchlineDataCollection[index].ForegroundLTP = "White";
             *  }
             *  else if (LTP < ObjTouchlineDataCollection[index].CloseRateL)
             *  {
             *      ObjTouchlineDataCollection[index].PrevLTP1 = App.DownTrendColorGlobal;
             *      ObjTouchlineDataCollection[index].ForegroundLTP = "White";
             *  }
             *  else if (LTP == ObjTouchlineDataCollection[index].CloseRateL)
             *  {
             *      ObjTouchlineDataCollection[index].ForegroundLTP = "White";
             *      if (index % 2 != 0)
             *      {
             *          ObjTouchlineDataCollection[index].PrevLTP1 = "#FF333972";
             *      }
             *      else
             *      {
             *          ObjTouchlineDataCollection[index].PrevLTP1 = "#FF333972";
             *      }
             *  }
             * }
             * else
             * {
             *  ObjTouchlineDataCollection[index].ForegroundLTP = "White";
             *  if (index % 2 != 0)
             *  {
             *      ObjTouchlineDataCollection[index].PrevLTP1 = "#FF333972";
             *  }
             *  else
             *  {
             *      ObjTouchlineDataCollection[index].PrevLTP1 = "#FF333972";
             *  }
             *
             * }*/

            if (LTP != 0 && ObjTouchlineDataCollection[index].FiftyTwoHigh != 0)
            {
                if (LTP > ObjTouchlineDataCollection[index].FiftyTwoHigh)
                {
                    // ObjTouchlineDataCollection[index].FiftyTwoHighBColor = App.UpTrendColorGlobal;
                    ObjTouchlineDataCollection[index].FiftyTwoHigh = LTP;
                    MasterSharedMemory.objDicDP[ObjTouchlineDataCollection[index].Scriptcode1].WeeksHighprice         = _BstFive.lastTradeRateL;
                    MasterSharedMemory.objDicDP[ObjTouchlineDataCollection[index].Scriptcode1].Dateof52weeksHighprice = CommonFunctions.GetDate().ToString("ddMMyyyy");//DateTime.ParseExact(DateTime.Now.ToString("dd/MM/yyyy"), "dd/MM/yyyy", CultureInfo.InvariantCulture).ToString("ddMMyyyy");
                }
            }

            if (LTP != 0 && ObjTouchlineDataCollection[index].FiftyTwoLow != 0)
            {
                if (LTP < ObjTouchlineDataCollection[index].FiftyTwoLow)
                {
                    //ObjTouchlineDataCollection[index].FiftyTwoLowBColor = App.DownTrendColorGlobal;
                    ObjTouchlineDataCollection[index].FiftyTwoLow = LTP;
                    MasterSharedMemory.objDicDP[ObjTouchlineDataCollection[index].Scriptcode1].WeeksLowprice         = _BstFive.lastTradeRateL;
                    MasterSharedMemory.objDicDP[ObjTouchlineDataCollection[index].Scriptcode1].Dateof52weeksLowprice = CommonFunctions.GetDate().ToString("ddMMyyyy");//DateTime.ParseExact(DateTime.Now.ToString("dd/MM/yyyy"), "dd/MM/yyyy", CultureInfo.InvariantCulture).ToString("ddMMyyyy");
                }
            }

            //}
        }
Exemple #5
0
        private static List <int> CookTouchLineData(string name)
        {
            List <int> objScripCodeFromSettingsSendLst = new List <int>();

            //int ScripCode = 0;
            string[] strArray;
            try
            {
                if (name == null)
                {
                    strArray = ObjCommon.ReaDFromCSV();
                }
                else
                {
                    string UserDefinedPath = Path.Combine(masterPath.ToString(), name);
                    strArray = File.ReadAllLines(UserDefinedPath + ".csv");
                }
                SubscribeScripMemory.objSubscribeScrip.Clear();
                SubscribeList.SubscribeScrip s = new SubscribeScrip();
                //strArray.GetLength(0);
                for (int i = 0; i < strArray.GetLength(0); i++)
                {
                    string[] strArray2 = strArray[i].Split(new char[] { ',' });
                    if (strArray2.Length == 2)
                    {
                        objScripCodeFromSettingsSendLst.Add(Convert.ToInt32(strArray2[1]));
                    }
                    else
                    {
                        objScripCodeFromSettingsSendLst.Add(Convert.ToInt32(CommonFunctions.GetScripCode(strArray2[0])));
                    }
                    MarketWatchModel item     = new MarketWatchModel();
                    ScripDetails     objscrip = new ScripDetails();
                    item.Index     = i;
                    item.ScriptId1 = strArray2[0];
                    if (strArray2.Length == 2)
                    {
                        item.Scriptcode1 = Convert.ToInt32(strArray2[1]);
                    }
                    else
                    {
                        item.Scriptcode1 = Convert.ToInt32(CommonFunctions.GetScripCode(strArray2[0]));
                    }
                    DecimalPnt = CommonFunctions.GetDecimal(item.Scriptcode1);
                    //DecimalPoint =  CommonFunctions.GetDecimal(item.Scriptcode1),
                    //objscrip = BroadcastMasterMemory.objScripDetailsConDict.Where(x => x.Key == item.Scriptcode1).Select(x => x.Value).FirstOrDefault();
                    s.ScripCode_l  = item.Scriptcode1;
                    s.UpdateFlag_s = 1;
                    if (SubscribeScripMemory.objSubscribeScrip.ContainsKey(s.ScripCode_l))
                    {
                    }
                    else
                    {
                        SubscribeScripMemory.objSubscribeScrip.TryAdd(s.ScripCode_l, s);
                    }
                    BroadcastReceiver.ScripDetails Br = BroadcastMaster.BroadcastMasterMemory.objScripDetailsConDict.Where(x => x.Key == item.Scriptcode1).Select(x => x.Value).FirstOrDefault();
                    objscrip            = MainWindowVM.UpdateScripDataFromMemory(Br);
                    objscrip.ScriptCode = item.Scriptcode1;
                    Initialize_Fields(objscrip, ref item, DecimalPnt, item.Scriptcode1);
                    ObjTouchlineDataCollection.Add(item);
                    objBroadCastProcessor_OnBroadCastRecievedNew(objscrip);
                }
            }
            catch (Exception ex)
            {
                ExceptionUtility.LogError(ex);
            }
            SearchTemplist = ObjTouchlineDataCollection.Cast <MarketWatchModel>().ToList();
            return(objScripCodeFromSettingsSendLst);
        }