Beispiel #1
0
        private static JiduData RequestJiduData(string url)
        {
            JiduData        data       = new JiduData();
            string          content    = HttpUtils.HttpGetUrl(url, "gbk");
            HttpComp_Select compSelect = HttpParser.ParseSelectByName(content, "year");

            for (int i = 0; i < compSelect.Values.Count; i++)
            {
                data.years.Add(int.Parse(compSelect.Values[i]));
            }

            HttpComp_Table compTable = HttpParser.ParseTableById(content, "FundHoldSharesTable");

            if (compTable != null)
            {
                for (int i = compTable.Rows.Count - 1; i > 1; i--)
                {
                    List <string> row = compTable.Rows[i];
                    string[]      arr = parseKLineDataRow(row);
                    if (arr == null)
                    {
                        continue;
                    }
                    data.KLineData.Add(arr);
                }
            }
            return(data);
        }
Beispiel #2
0
        //private static List<string[]> RequestData(string code, bool isIndex, int lastUpdatedDate)
        //{
        //    JiduData jiduData = RequestData_Jidu(code, isIndex);
        //    List<string[]> klineData = new List<string[]>();

        //    bool continueReq = AddKLineData(klineData, jiduData.KLineData, lastUpdatedDate);
        //    if (!continueReq)
        //        return klineData;

        //    if (jiduData.Jidu > 1)
        //    {
        //        int firstyear = jiduData.years[0];
        //        continueReq = RequestData(klineData, code, isIndex, firstyear, jiduData.Jidu - 1, lastUpdatedDate);
        //        if (!continueReq)
        //            return klineData;
        //    }
        //    for (int i = 1; i < jiduData.years.Count; i++)
        //    {
        //        int year = jiduData.years[i];
        //        continueReq = RequestData(klineData, code, isIndex, year, 4, lastUpdatedDate);
        //        if (!continueReq)
        //            break;
        //    }
        //    return klineData;
        //}

        //private static List<string[]> RequestData(string code, int lastUpdatedDate, JiduData jiduData)
        //{
        //    List<string[]> klineData = new List<string[]>();

        //    bool continueReq = AddKLineData(klineData, jiduData.KLineData, lastUpdatedDate);
        //    if (!continueReq)
        //        return klineData;

        //    if (jiduData.Jidu > 1)
        //    {
        //        int firstyear = jiduData.years[0];
        //        continueReq = RequestIndex(klineData, code, firstyear, jiduData.Jidu - 1, lastUpdatedDate);
        //        if (!continueReq)
        //            return klineData;
        //    }
        //    for (int i = 1; i < jiduData.years.Count; i++)
        //    {
        //        int year = jiduData.years[i];
        //        continueReq = RequestIndex(klineData, code, year, 4, lastUpdatedDate);
        //        if (!continueReq)
        //            break;
        //    }
        //    return klineData;
        //}

        public static bool RequestData(List <string[]> klineData, string code, bool isIndex, int year, int startJidu, int lastUpdatedDate)
        {
            for (int i = startJidu; i > 0; i--)
            {
                Thread.Sleep(2000);
                JiduData jiduData = RequestData_Jidu(code, isIndex, year, i);
                if (jiduData == null)
                {
                    continue;
                }
                List <string[]> arr        = jiduData.KLineData;
                bool            isContinue = AddKLineData(klineData, arr, lastUpdatedDate);
                if (!isContinue)
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #3
0
        /// <summary>
        /// 数据格式:
        ///
        //20180205,3411.670,3487.721,3487.497,3406.241,21767375400,252198769276
        //20180206,3418.010,3440.124,3370.652,3364.216,28055547700,318818541762
        //20180207,3412.744,3425.538,3309.260,3304.007,26093971400,295264429885
        //20180208,3281.046,3307.162,3262.050,3225.712,20126249900,222348685287
        //20180209,3172.851,3180.110,3129.851,3062.743,25638917600,272095086839
        /// </summary>
        /// <param name="code"></param>
        /// <param name="lastUpdatedDate"></param>
        /// <returns></returns>
        public static List <string[]> RequestData(string code, bool isIndex, int lastUpdatedDate)
        {
            JiduData        jiduData  = RequestData_Jidu(code, isIndex);
            List <string[]> klineData = new List <string[]>();

            bool continueReq = AddKLineData(klineData, jiduData.KLineData, lastUpdatedDate);

            if (!continueReq)
            {
                return(klineData);
            }

            if (jiduData.Jidu > 1)
            {
                int firstyear = jiduData.years[0];
                continueReq = RequestData(klineData, code, isIndex, firstyear, jiduData.Jidu - 1, lastUpdatedDate);
                if (!continueReq)
                {
                    return(klineData);
                }
            }
            for (int i = 1; i < jiduData.years.Count; i++)
            {
                int year = jiduData.years[i];
                if (year < 2007)
                {
                    break;
                }
                continueReq = RequestData(klineData, code, isIndex, year, 4, lastUpdatedDate);
                if (!continueReq)
                {
                    break;
                }
            }
            return(klineData);
        }