Beispiel #1
0
 internal static void objIndicesBroadCastProcessor_OnBroadCastRecievedNew(IdicesDetailsMain objIndexMain)
 {
     try
     {
         if (SelectedExchange == Enumerations.Order.Exchanges.BSE.ToString())
         {
             if (objIndexMain != null && ObjIndicesCollection.Count > 0)
             {
                 IdicesDetailsMain item = objIndexMain;
                 //foreach (var item in objIndexMain.listindMain)
                 {
                     int?index = null;
                     if (ObjIndicesCollection.Any(x => x.IndexCode == item.IndexCode))
                     {
                         index = ObjIndicesCollection.Where(i => i.IndexCode == item.IndexCode).Select(x => ObjIndicesCollection.IndexOf(x)).FirstOrDefault();
                     }
                     if (index != null)
                     {
                         ObjIndicesCollection[(int)index].IndexValue         = SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict[item.IndexCode].IndexValue / Math.Pow(10, 2);
                         ObjIndicesCollection[(int)index].IndexHigh          = SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict[item.IndexCode].IndexHigh / Math.Pow(10, 2);
                         ObjIndicesCollection[(int)index].IndexLow           = SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict[item.IndexCode].IndexLow / Math.Pow(10, 2);
                         ObjIndicesCollection[(int)index].IndexOpen          = SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict[item.IndexCode].IndexOpen / Math.Pow(10, 2);
                         ObjIndicesCollection[(int)index].PreviousIndexClose = SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict[item.IndexCode].PreviousIndexClose / Math.Pow(10, 2);
                         if (ObjIndicesCollection[(int)index].IndexValue != 0 && ObjIndicesCollection[(int)index].PreviousIndexClose != 0)
                         {
                             if (Math.Round(Convert.ToDouble((ObjIndicesCollection[(int)index].IndexValue - ObjIndicesCollection[(int)index].PreviousIndexClose) / ObjIndicesCollection[(int)index].PreviousIndexClose * 100), 2) > 0)
                             {
                                 ObjIndicesCollection[(int)index].perChange = string.Format("{0}{1}", "+", Math.Round(Convert.ToDouble((ObjIndicesCollection[(int)index].IndexValue - ObjIndicesCollection[(int)index].PreviousIndexClose) / ObjIndicesCollection[(int)index].PreviousIndexClose * 100), 2).ToString("0.00"));
                                 //ColorFont = "Red";
                             }
                             else
                             {
                                 ObjIndicesCollection[(int)index].perChange = string.Format("{0}", Math.Round(Convert.ToDouble((ObjIndicesCollection[(int)index].IndexValue - ObjIndicesCollection[(int)index].PreviousIndexClose) / ObjIndicesCollection[(int)index].PreviousIndexClose * 100), 2).ToString("0.00"));
                             }
                         }
                         //ObjIndicesCollection[(int)index].chngInValue = SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict[item.IndexCode].IndexChangeValue;
                         if (ObjIndicesCollection[(int)index].IndexValue != 0 && ObjIndicesCollection[(int)index].PreviousIndexClose != 0)
                         {
                             ObjIndicesCollection[(int)index].chngInValue = $"{ObjIndicesCollection[(int)index].IndexValue - ObjIndicesCollection[(int)index].PreviousIndexClose:0.00}";
                         }
                     }
                 }
                 // NotifyStaticPropertyChanged(nameof(ObjIndicesCollection));
             }
         }
     }
     catch (Exception ex)
     {
         ExceptionUtility.LogError(ex);
     }
 }
Beispiel #2
0
        private static void populateGrid()
        {
            // MainWindowVM.indicesBroadCast -= objIndicesBroadCastProcessor_OnBroadCastRecievedNew;
            if (SelectedExchange == Enumerations.Order.Exchanges.BSE.ToString())
            {
                foreach (var item in MasterSharedMemory.objMasterDicSyb)
                {
                    AllIndicesModel oAllIndicesModel = new AllIndicesModel();
                    oAllIndicesModel.IndexCode = item.Key;
                    oAllIndicesModel.IndexId   = item.Value.IndexID;
                    bool hasNonEmptyObject = MasterSharedMemory.objSpnIndicesDic.Values.Any(x => x.IndexCode == item.Key);
                    if (hasNonEmptyObject)
                    {
                        oAllIndicesModel.IndexName = MasterSharedMemory.objSpnIndicesDic.Values.Where(x => x.IndexCode == item.Key).Select(x => x.RebrandedLongName_ca).FirstOrDefault();
                    }
                    else
                    {
                        oAllIndicesModel.IndexName = item.Value.IndexID;
                    }

                    if (SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict.Keys.Contains(oAllIndicesModel.IndexCode))
                    {
                        oAllIndicesModel.IndexValue         = SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict[oAllIndicesModel.IndexCode].IndexValue / Math.Pow(10, 2);
                        oAllIndicesModel.IndexHigh          = SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict[oAllIndicesModel.IndexCode].IndexHigh / Math.Pow(10, 2);
                        oAllIndicesModel.IndexLow           = SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict[oAllIndicesModel.IndexCode].IndexLow / Math.Pow(10, 2);
                        oAllIndicesModel.IndexOpen          = SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict[oAllIndicesModel.IndexCode].IndexOpen / Math.Pow(10, 2);
                        oAllIndicesModel.PreviousIndexClose = SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict[oAllIndicesModel.IndexCode].PreviousIndexClose / Math.Pow(10, 2);
                        oAllIndicesModel.chngInValue        = $"{oAllIndicesModel.IndexValue - oAllIndicesModel.PreviousIndexClose:0.00}";
#if TWS
                        if (oAllIndicesModel.IndexValue != 0 && oAllIndicesModel.PreviousIndexClose != 0)
                        {
                            if (Math.Round(Convert.ToDouble((oAllIndicesModel.IndexValue - oAllIndicesModel.PreviousIndexClose) / oAllIndicesModel.PreviousIndexClose * 100), 2) > 0)
                            {
                                oAllIndicesModel.perChange = string.Format("{0}{1}", "+", Math.Round(Convert.ToDouble((oAllIndicesModel.IndexValue - oAllIndicesModel.PreviousIndexClose) / oAllIndicesModel.PreviousIndexClose * 100), 2).ToString("0.00"));
                            }
                            else
                            {
                                oAllIndicesModel.perChange = string.Format("{0}", Math.Round(Convert.ToDouble((oAllIndicesModel.IndexValue - oAllIndicesModel.PreviousIndexClose) / oAllIndicesModel.PreviousIndexClose * 100), 2).ToString("0.00"));
                            }
                        }
#elif BOW
                        oAllIndicesModel.perChange = Convert.ToString(SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict[oAllIndicesModel.IndexCode].IndexChangeValue);
#endif
                    }

                    ObjIndicesCollection.Add(oAllIndicesModel);
                }
                //MainWindowVM.indicesBroadCast += objIndicesBroadCastProcessor_OnBroadCastRecievedNew;
                //public static void objBroadCastProcessor_OnBroadCastRecievedNew(ScripDetails objScripDetails)
                //{
                //    try
                //    {
                //        int scripCode = objScripDetails.ScriptCode_BseToken_NseToken;
                //        //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;
                //    }
                //}
                //foreach (var item in MasterSharedMemory.objMasterDicSyb)
                //{
                //    AllIndicesModel oAllIndicesModel = new AllIndicesModel();
                //    oAllIndicesModel.IndexCode = item.Key;
                //    oAllIndicesModel.IndexId = item.Value.IndexID;
                //    if (BroadcastMaster.BroadcastMasterMemory.objIndicesDetailsConDict.Keys.Contains(oAllIndicesModel.IndexCode))
                //    {
                //        oAllIndicesModel.IndexValue = BroadcastMaster.BroadcastMasterMemory.objIndicesDetailsConDict[oAllIndicesModel.IndexCode].IndexValue;
                //        oAllIndicesModel.IndexHigh = BroadcastMaster.BroadcastMasterMemory.objIndicesDetailsConDict[oAllIndicesModel.IndexCode].IndexHigh;
                //        oAllIndicesModel.IndexLow = BroadcastMaster.BroadcastMasterMemory.objIndicesDetailsConDict[oAllIndicesModel.IndexCode].IndexLow;
                //        oAllIndicesModel.IndexOpen = BroadcastMaster.BroadcastMasterMemory.objIndicesDetailsConDict[oAllIndicesModel.IndexCode].IndexOpen;
                //        oAllIndicesModel.PreviousIndexClose = BroadcastMaster.BroadcastMasterMemory.objIndicesDetailsConDict[oAllIndicesModel.IndexCode].PreviousIndexClose;
                //    }

                //    ObjIndicesCollection.Add(oAllIndicesModel);
                //}
            }
        }