コード例 #1
0
        /// <summary>
        /// 获取SINA日线数据
        /// </summary>
        /// <param name="stockCode"></param>
        /// <param name="year"></param>
        /// <param name="jidu"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        public Dictionary <string, object> GetSINAKLineDay(string stockCode, int year, int jidu, string source = "SINA")
        {
            var html    = DataSourceSINA.GetInstance().GetLSJY(stockCode, year, jidu);
            var res     = NodeService.Get(CONST.NodeServiceUrl, "新浪", "GetDataFromHtml", new { ContentType = "SINA历史交易", Page = html });//
            var resDict = res as Dictionary <string, object>;

            return(resDict["PageData"] as Dictionary <string, object>);
        }
コード例 #2
0
        /// <summary>
        /// 获取SINA财务摘要数据
        /// </summary>
        /// <param name="stockCode"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        public object GetCWZY(string stockCode, string source = "SINA")
        {
            var res = new object();

            if ("SINA" == source.ToUpper() && !string.IsNullOrWhiteSpace(stockCode))//  //WebDataSource.GetDataFromHttpAgent("http://aifuwu.wang/API.ashx?c=WangJun.Stock.DataSourceSINA&m=GetCWZY&p=6018888");//
            {
                var html    = DataSourceSINA.GetInstance().GetCWZY(stockCode);
                var resDict = NodeService.Get(CONST.NodeServiceUrl, "新浪", "GetDataFromHtml", new { ContentType = "SINA财务摘要", Page = html });
                return(resDict);
            }

            return(res);
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="stockCode"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        public ArrayList GetRZRQ(string stockCode, string source = "SINA")
        {
            var res = new ArrayList();

            if ("SINA" == source.ToUpper() && !string.IsNullOrWhiteSpace(stockCode)) //
            {
                var rzrqHtml = DataSourceSINA.GetInstance().GetRZRQ(stockCode);
                var rzrqDict = NodeService.Get(CONST.NodeServiceUrl, "新浪", "GetDataFromHtml", new { ContentType = "SINA融资融券", Page = rzrqHtml });
                var pageData = (rzrqDict as Dictionary <string, object>)["PageData"] as Dictionary <string, object>;
                return(pageData["Rows"] as ArrayList);
            }
            return(res);
        }
コード例 #4
0
        public void SyncExcel()
        {
            var q = this.PrepareData();

            //var date = DateTime.Now;
            for (var date = DateTime.Now; new DateTime(2017, 1, 1) < date; date = date.AddDays(-1))
            {
                foreach (var stockCode in q)
                {
                    var stockName = this.stockCodeDict[stockCode];
                    if (!(date.DayOfWeek == DayOfWeek.Sunday || date.DayOfWeek == DayOfWeek.Saturday))
                    {
                        DataSourceSINA.GetInstance().DownloadExcel(date, stockCode, stockName);

                        LOGGER.Log(string.Format("{0}{1}{2}", stockCode, stockName, date));
                    }
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// 获取页面
        /// </summary>
        /// <param name="contentType"></param>
        /// <param name="stockcode"></param>
        /// <param name="url"></param>
        /// <param name="exData"></param>
        /// <returns></returns>
        public string GetPage(string contentType, string stockcode, string url = null, Dictionary <string, object> exData = null)
        {
            var html = string.Empty;

            if ("首页概览" == contentType)
            {
                html = this.GetSYGL(stockcode);
            }
            else if ("资金流向" == contentType)
            {
                html = this.GetJZLX(stockcode);
            }
            else if ("个股龙虎榜" == contentType)
            {
                html = this.GetGGLHB(stockcode);
            }
            else if ("个股龙虎榜明细" == contentType)
            {
                html = this.GetGGLHBMX(stockcode, url);
            }
            else if ("SINA个股历史交易" == contentType)
            {
                var sina = DataSourceSINA.GetInstance();
                var year = (int)exData["Year"];
                var jidu = (int)exData["JiDu"];
                html = sina.GetLSJY(stockcode, year, jidu);
            }
            else if ("SINA个股历史交易明细" == contentType)
            {
                var sina = DataSourceSINA.GetInstance();
                var year = (int)exData["Year"];
                var jidu = (int)exData["JiDu"];
                html = sina.GetLSJY(stockcode, year, jidu);
            }
            else if ("THS财经要闻列表" == contentType)
            {
            }
            return(html);
        }
コード例 #6
0
        /// <summary>
        /// 获取SINA股票雷达
        /// </summary>
        /// <returns></returns>
        public List <Dictionary <string, object> > GetStockRadar()
        {
            var tradingDate = Convertor.CalTradingDate(DateTime.Now, "00:00:00");
            var listHtml    = DataSourceSINA.GetInstance().GetStockRadar();
            var listData    = new List <Dictionary <string, object> >();

            foreach (var html in listHtml)
            {
                var resDict  = NodeService.Get(CONST.NodeServiceUrl, "新浪", "GetDataFromHtml", new { ContentType = "SINA股市雷达", Page = html }) as Dictionary <string, object>;
                var pageData = resDict["PageData"] as ArrayList;
                if (pageData is ArrayList)
                {
                    var itemList = pageData as ArrayList;
                    foreach (Dictionary <string, object> item in itemList)
                    {
                        var dict = item;
                        dict["异动时间"] = Convertor.CalTradingDate(DateTime.Now, item["异动时间"].ToString());
                        listData.Add(dict);
                    }
                }
            }

            return(listData);
        }
コード例 #7
0
        /// <summary>
        /// 下载大单数据
        /// </summary>
        public void GetDaDanData()
        {
            ///获取页码码数
            ///下载每一页数据
            ///查找最近一个交易日的数据是否存在,若存在则不下载
            ///

            var mongo     = DataStorage.GetInstance(DBType.MongoDB);
            var webSource = DataSourceSINA.GetInstance();
            var pageCount = 0;// webSource.GetDaDanPageCount();

            if (0 == pageCount)
            {
                pageCount = int.Parse(WebDataSource.GetDataFromHttpAgent(string.Format("http://aifuwu.wang/API.ashx?c=WangJun.Stock.DataSourceSINA&m=GetDaDanPageCount")));
            }
            var dbName         = CONST.DB.DBName_StockService;
            var collectionName = CONST.DB.CollectionName_DaDan;
            ///数据检查
            var lastTradingDate = Convertor.CalTradingDate(DateTime.Now, "00:00:00");

            ///删除根据日期创建的临时表格
            ///将数据写入表格
            ///将这个数据转移到大表中
            #region 存储临时数据
            var tempCollectionName = collectionName + string.Format("{0:yyyyMMdd}", DateTime.Now);
            mongo.Remove(dbName, tempCollectionName, "{}");
            #endregion

            var methodName = "GetDaDanData";
            var status     = TaskStatusManager.Get(methodName);
            var startIndex = (status.ContainsKey("PageIndex")) ? int.Parse(status["PageIndex"].ToString()) : 0;
            var totalCount = 0;
            for (int i = startIndex; i < pageCount; i++)
            {
                var html = "";// webSource.GetDaDan(i);

                if (string.IsNullOrWhiteSpace(html))
                {
                    html = WebDataSource.GetDataFromHttpAgent(string.Format("http://aifuwu.wang/API.ashx?c=WangJun.Stock.DataSourceSINA&m=GetDaDan&p={0}", i));
                }

                var res = NodeService.Get(CONST.NodeServiceUrl, "新浪", "GetDataFromHtml", new { ContentType = "SINA大单", Page = html });

                if (res is Dictionary <string, object> )
                {
                    var item = new
                    {
                        PageData    = (res as Dictionary <string, object>)["PageData"],
                        ContentType = "SINA大单",
                        CreateTime  = DateTime.Now,
                        TradingDate = Convertor.CalTradingDate(DateTime.Now, "00:00:00"),
                        PageIndex   = i,
                        PageCount   = pageCount,
                    };
                    LOGGER.Log(string.Format("SINA大单保存 {0} {1}", i, pageCount));

                    var arrayList = item.PageData as ArrayList;
                    ///数据二维化,计算可以计算的,剩下的再想办法计算
                    for (int k = 0; k < arrayList.Count; k++)
                    {
                        totalCount++;
                        var arrItem  = arrayList[k] as Dictionary <string, object>;
                        var svItem2D = new
                        {
                            StockCode   = arrItem["StockCode"],
                            StockName   = arrItem["StockName"],
                            TickTime    = arrItem["交易时间"],
                            Price       = arrItem["成交价"],
                            Turnover    = arrItem["成交量"],
                            PrevPrice   = arrItem["之前价格"],
                            Kind        = arrItem["成交类型"],
                            TradingTime = Convertor.CalTradingDate(item.TradingDate, arrItem["交易时间"].ToString()),
                            TradingDate = item.TradingDate,
                            CreateTime  = item.CreateTime,
                            PageIndex   = i,
                            PageCount   = pageCount,
                            RowIndex    = k
                        };
                        mongo.Save3(dbName, tempCollectionName, svItem2D);
                        TaskStatusManager.Set(methodName, new { ID = methodName, PageIndex = i, PageCount = pageCount, Status = "已下载", CreateTime = DateTime.Now });

                        LOGGER.Log(string.Format("SINA大单2D保存 {0} {1} {2}", i, k, pageCount));
                    }
                }
                ThreadManager.Pause(seconds: 2);
            }
            TaskStatusManager.Set(methodName, new { ID = methodName, Status = "队列处理完毕", CreateTime = DateTime.Now });
            var countInDB = mongo.Count(CONST.DB.DBName_StockService, tempCollectionName, "{}");
            if (totalCount == countInDB)
            {
                LOGGER.Log(string.Format("准备转移数据"));
                ///数据检查是否完毕,完备后插入
                //DataStorage.MoveCollection(mongo, CONST.DB.DBName_StockService, tempCollectionName, "{}", mongo, CONST.DB.DBName_StockService, CONST.DB.CollectionName_DaDan, false);
            }
            else
            {
                LOGGER.Log(string.Format("数据对不上 {0} {1}", totalCount, countInDB));
            }
        }