Пример #1
0
        public async void SetRankingTabledata()
        {
            int i = 0;


            // List<Price> prices = Finance.Parse(await StorageControl.PCLLoadCommand());//登録データ読み込み
            Tabledata anser = await Models.RankingTabledata();//データの現在値を取得する



            RankingItemList.Add(new Tabledata
            {
                RankingValue = anser.RankingValue,
                Name         = anser.Name,     // "Sony",
                Dividend     = anser.Dividend, //保有数*
                //Itemprice = anser.Itemprice,// 2015,
                //Prev_day = anser.Prev_day,//前日比±**
                //Realprice = anser.Realprice,//現在値*// 1000,
                //RealValue = anser.RealValue,// 100,
                //Percent = anser.Percent,//前日比%**// "5"
            });


            i = ++i;
        }
Пример #2
0
        public static async Task <Tabledata> RankingTabledata()
        {
            int index = 0;
            int i     = 0;
            //Decimal PayAssetprice = 0;
            //Decimal TotalAssetprice = 0;
            //string NameMulti = "";
            //string TrgetWord = null, TrgetWord1 = null, TrgetWord2 = null;
            string RankingValue = null;
            string Name         = null;
            string Dividend     = null;



            string url        = "https://info.finance.yahoo.co.jp/ranking/?kd=8&tm=d&vl=a&mk=3&p=1";
            var    httpClient = new HttpClient();
            string str        = await httpClient.GetStringAsync(url);

            Tabledata tabledata = new Tabledata();



            string searchWord = "rankingTabledata yjM";        //検索する文字列 ="stoksPrice">
            string RankWore   = "txtcenter\">";

            int foundIndex = str.IndexOf(searchWord);    //始めの位置を探す

            //Rankingの検索開始位置
            int RankIndex = foundIndex + searchWord.Length;

            try
            {
                //次の位置を探す
                foundIndex = str.IndexOf(RankWore, RankIndex);

                for (; Convert.ToString(str[foundIndex + RankWore.Length + i]) != "<"; i++)
                {
                    if (foundIndex != -1)
                    {
                        RankingValue = RankingValue + str[foundIndex + RankWore.Length + i];//current value 順位
                    }
                }

                searchWord = "normal yjSt\">";        //検索する文字列 企業名
                foundIndex = str.IndexOf(searchWord); //始めの位置を探す
                i          = searchWord.Length;
                for (; Convert.ToString(str[foundIndex + i]) != "<"; i++)
                {
                    Name = Name + str[foundIndex + i];    //previous 前日比? ¥
                }


                searchWord = "txtright\">";                               //検索する文字列 配当金
                foundIndex = str.IndexOf(searchWord);                     //始めの位置を探す
                i          = searchWord.Length;                           //次のsearchWordに進める
                foundIndex = foundIndex + i;
                foundIndex = str.IndexOf(searchWord, foundIndex);         //始めの位置を探す
                for (; Convert.ToString(str[foundIndex + i]) != "<"; i++) //(-)下落
                {
                    Dividend = Dividend + str[foundIndex + i];            //(-)
                }



                i++;
                //for (; Convert.ToString(str[foundIndex + i]) != ")"; i++)
                //{
                //    PercentRatio = PercentRatio + str[foundIndex + i];//previous 前日比? %
                //}


                //if (RankingValue == "---")
                //{
                //    //tabledata.Realprice = 000;
                //}
                //else
                //{
                //    //tabledata.Realprice = Convert.ToDecimal(RankingValue);//現在値
                //}
                tabledata.RankingValue = RankingValue; //順位
                tabledata.Name         = Name;         //企業名
                tabledata.Dividend     = Dividend;     //配当金額
                //tabledata.Gain = (tabledata.Realprice - tabledata.Itemprice) * tabledata.Stocks;//損益
                //tabledata.RealValue = (tabledata.Stocks * tabledata.Realprice);//個別利益


                RankingValue = "";
                Name         = "";
                Dividend     = "";
                index        = index + 1;
            }
            catch (Exception)
            {
                //tabledata.Prev_day = "Close";
                //tabledata.Polar = "Gray";
            }


            return(tabledata);//polarity;
        }//class to end