예제 #1
0
        public List <OIDetails> LoadOptionsData(string _masterDatapathBasic, string _bnExpiryDate, string currentIndexValue, float Size, int count)
        {
            OIDetails        O       = GenerateOIData(currentIndexValue);
            List <OIDetails> objList = new List <OIDetails>();
            List <Types>     data    = GenerateIndexValues(O.underlyingValue, Size, count);
            string           Name    = "BANKNIFTY";

            if (Size == 50)
            {
                Name = "NIFTY";
            }

            foreach (var item in data[0].requiredValues)
            {
                if (item.ToString().Contains('.'))
                {
                    string _ceurl = _masterDatapathBasic.Replace("EXPIRYCODE", _bnExpiryDate).Replace("TYPECEPE", "CE").Replace("BANKNIFTY", Name).Replace("INDEXVALUE.00", item.ToString() + "0");
                    objList.Add(GenerateOIData(_ceurl));
                    string _peurl = _masterDatapathBasic.Replace("EXPIRYCODE", _bnExpiryDate).Replace("TYPECEPE", "PE").Replace("BANKNIFTY", Name).Replace("INDEXVALUE.00", item.ToString() + "0");
                    objList.Add(GenerateOIData(_peurl));
                }
                else
                {
                    string _ceurl = _masterDatapathBasic.Replace("EXPIRYCODE", _bnExpiryDate).Replace("TYPECEPE", "CE").Replace("BANKNIFTY", Name).Replace("INDEXVALUE", item.ToString());
                    objList.Add(GenerateOIData(_ceurl));
                    string _peurl = _masterDatapathBasic.Replace("EXPIRYCODE", _bnExpiryDate).Replace("TYPECEPE", "PE").Replace("BANKNIFTY", Name).Replace("INDEXVALUE", item.ToString());
                    objList.Add(GenerateOIData(_peurl));
                }
            }

            return(objList);
        }
예제 #2
0
        private OIDetails GenerateOIData(string nseurl)
        {
            //string text = System.IO.File.ReadAllText(@"D:\txtData.txt");
            OIDetails obj  = new OIDetails();
            string    text = GetHtmlString(nseurl);

            try

            {
                string[] text1 = text.Split(new[] { "valid" }, StringSplitOptions.None);
                string[] text2 = text1[1].Split(new[] { "symbolMapping" }, StringSplitOptions.None);
                string   data  = text2[0].ToString();
                string   s     = @""",""";
                s = s.Remove(s.Length - 1);
                string[] text3 = data.Split(new[] { s }, StringSplitOptions.None);

                foreach (var item in GetOIProperties())
                {
                    string result = text3.FirstOrDefault(n => n.Contains(item));
                    string text4  = result.Split(new[] { item }, StringSplitOptions.None)[1].Remove(0, 3);
                    obj.SavedTimeStamp = DateTime.Now;
                    if (item == "lastPrice")
                    {
                        obj.lastPrice = text4.Split('}')[0].Replace("\"", "");
                    }

                    if (item == "prevClose")
                    {
                        obj.prevClose = text4;
                    }

                    if (item == "openPrice")
                    {
                        obj.openPrice = text4;
                    }

                    if (item == "highPrice")
                    {
                        obj.highPrice = text4.Split('}')[0].Replace("\"", "");
                    }

                    if (item == "lowPrice")
                    {
                        obj.lowPrice = text4;
                    }

                    if (item == "closePrice")
                    {
                        obj.closePrice = text4;
                    }

                    if (item == "vwap")
                    {
                        obj.vwap = text4;
                    }

                    if (item == "underlyingValue")
                    {
                        obj.underlyingValue = text4;
                    }

                    if (item == "changeinOpenInterest")
                    {
                        obj.changeinOpenInterest = text4;
                    }

                    if (item == "prevClose")
                    {
                        obj.prevClose = text4;
                    }
                    if (item == "openInterest")
                    {
                        obj.openInterest = text4;
                    }

                    if (item == "pchangeinOpenInterest")
                    {
                        obj.pchangeinOpenInterest = text4;
                    }

                    if (item == "instrumentType")
                    {
                        obj.instrumentType = text4;
                    }

                    if (item == "strikePrice")
                    {
                        obj.strikePrice = text4;
                    }
                    if (item == "expiryDate")
                    {
                        obj.expiryDate = text4;
                    }

                    if (item == "optionType")
                    {
                        obj.optionType = text4;
                    }
                    if (item == "underlying")
                    {
                        obj.underlying = text4;
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(obj);
        }