예제 #1
0
        public void Update(MarketStock marketStock)
        {
            var sql = @"update marketstock set code = @code, name = @name, pinyin = @pinyin, market = @market, typeid = @typeid, ignored = @ignored, comment = @comment, updatetime = @updatetime where code = @code;";

            var parameters = new IDataParameter[]
            {
                new MySqlParameter("@code", marketStock.Code),
                new MySqlParameter("@name", marketStock.Name),
                new MySqlParameter("@pinyin", marketStock.PinYin),
                new MySqlParameter("@market", marketStock.Market),
                new MySqlParameter("@typeid", marketStock.TypeId),
                new MySqlParameter("@ignored", marketStock.Ignored),
                new MySqlParameter("@comment", marketStock.Comment),
                new MySqlParameter("@updatetime", DateTime.Now),
            };

            var returnCode = this.DbRequest.ExecuteNonQuery(this.ConnectionString, sql, parameters, CommandType.Text);
        }
예제 #2
0
        public void Create(MarketStock marketStock)
        {
            var sql = @"insert into marketstock(code, name, pinyin, market, typeid, ignored, comment)
                                    values(@code, @name, @pinyin, @market, @typeid, @ignored, @comment);";

            var parameters = new IDataParameter[]
            {
                new MySqlParameter("@code", marketStock.Code),
                new MySqlParameter("@name", marketStock.Name),
                new MySqlParameter("@pinyin", marketStock.PinYin),
                new MySqlParameter("@market", marketStock.Market),
                new MySqlParameter("@typeid", marketStock.TypeId),
                new MySqlParameter("@ignored", marketStock.Ignored),
                new MySqlParameter("@comment", marketStock.Comment),
            };

            var returnCode = this.DbRequest.ExecuteNonQuery(this.ConnectionString, sql, parameters, CommandType.Text);
        }
예제 #3
0
파일: Program.cs 프로젝트: wbqsln/HitStock
        static StockPriceHistory CreateNewPriceItem(MarketStock stock, DateTime today)
        {
            // 从数据源获取最新的价格数据
            var pulse = _crawler.FetchRealtimePrice(stock.Market, stock.Code);

            if (pulse == null)
            {
                return null;
            }

            var priceItem = new StockPriceHistory()
            {
                Code = stock.Code,
                Name = stock.Name,
                Date = today,
                OpenPrice = pulse.F5_TodayOpenPrice ?? 0,
                Price = pulse.F3_CurrentPrice ?? 0,
                HighestPrice = pulse.F33_HighestPriceInToday ?? 0,
                LowestPrice = pulse.F34_LowestPriceInToday ?? 0,
                CeilingPrice = pulse.F47_CeilingPrice ?? 0,
                FloorPrice = pulse.F48_FloorPrice ?? 0,
                YesterdayClosePrice = pulse.F4_YesterdayClosePrice ?? 0,
                PriceChangePercent = pulse.F32_PriceChangePercent ?? 0,
                PriceShakePercent = pulse.F43_PriceShakePercent,
                ExchangeRate = pulse.F38_ExchangeHandsRatePercent ?? 0,
                ExchangeAmountInHands = pulse.F6_ExchangedNumbersInHands ?? 0,
                ExchangeAmountInRMB = pulse.F37_ExchangeAmountInRMBTenThousand ?? 0,
                PB = pulse.F46_PB ?? 0,
                PE = pulse.F39_DynamicPE ?? 0,
                FlowableMarketValue = pulse.F44_FlowableValue ?? 0,
                TotalMarketValue = pulse.F45_TotalValue ?? 0,
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now,
            };

            return priceItem;
        }
예제 #4
0
 private void RefreshAction08(MarketStock stock)
 {
     //高管档案: http://hq.emoney.cn/f10/Wf10/ggda/300104.html
     throw new NotImplementedException();
 }
예제 #5
0
 private void RefreshAction07(MarketStock stock)
 {
     // todo: 预先获取一个股票的最新获取过的报告期日期,本次初始化获取直接设置为NULL
     var config = CrawlerConfig.GetConfig();
     var crawler = new CompanyMajorShareholderCrawler(stock.Market, stock.Code, null, config.SnowballCookies, new DateTime(2015, 1, 1));
     var majorShareholderList = crawler.CrawlObject();
     if (majorShareholderList != null && majorShareholderList.Count > 0)
     {
         _bizCompanyMatrix.UpdateStockMatrix_Major_Shareholder(stock.Code, majorShareholderList);
     }
     else
     {
         _bizCompanyMatrix.UpdateStockMatrix_Major_Shareholder(stock.Code, null);
     }
 }
예제 #6
0
 private void RefreshAction06(MarketStock stock)
 {
     //流通股东户数: https://xueqiu.com/S/SZ300104/LTGD     https://xueqiu.com/stock/f10/otsholder.json?symbol=SZ300104&page=1&size=4&_=1460208432061
     throw new NotImplementedException();
 }
예제 #7
0
        private void RefreshAction05(MarketStock stock)
        {
            // todo: 预先获取一个股票的最新获取过的报告期日期,本次初始化获取直接设置为NULL
            var config = CrawlerConfig.GetConfig();
            var crawler = new CompanyShareholderNumCrawler(stock.Market, stock.Code, null, config.SnowballCookies);
            var shareholderNumReportList = crawler.CrawlObject();
            if (shareholderNumReportList != null && shareholderNumReportList.Count > 0)
            {
                var propertyJson = JsonConvert.SerializeObject(shareholderNumReportList);
                _bizCompanyMatrix.UpdateStockMatrix_Shareholder_Num(stock.Code, propertyJson);
            }
            else
            {
                _bizCompanyMatrix.UpdateStockMatrix_Shareholder_Num(stock.Code, null);
            }

            Thread.Sleep(50);
        }
예제 #8
0
 private void RefreshAction04(MarketStock stock)
 {
     //大宗交易历史: http://data.eastmoney.com/dzjy/detail/300104.html
     throw new NotImplementedException();
 }
예제 #9
0
        private void RefreshAction03(MarketStock stock)
        {
            var programFolder = new DirectoryInfo(Environment.CurrentDirectory).Parent.Parent.FullName;
            var jsonFilePath = Path.Combine(programFolder, "phantomjs\\outputtmpfiles\\profit-forcast", stock.Code + ".json");
            var notExistedStockJsonFilePath = Path.Combine(programFolder, "phantomjs\\outputtmpfiles\\profit-forcast", "failed-" + stock.Code + ".json");

            if (File.Exists(jsonFilePath))
            {
                var crawler = new CompanyPerformanceForcastCrawler(jsonFilePath);
                var crawled_forcast_list = crawler.CrawlObject();
                if (crawled_forcast_list != null && crawled_forcast_list.Count > 0)
                {
                    _bizCompanyMatrix.UpdateStockMatrix_Season_Profit_Report(stock.Code, crawled_forcast_list);
                    // 删除已读取的文件
                    File.Delete(jsonFilePath);
                }
            }
            else if(File.Exists(notExistedStockJsonFilePath))
            {
                File.Delete(notExistedStockJsonFilePath);
            }

            //if (hitCount > 0)
            //{
            //    MessageBox.Show(string.Format("预期抓取:{0}个股季报,实际完成:{1}个文件,并更新到数据库,读取过的文件已被删除。", WholeMarketStockCodeList.Count, hitCount));
            //}
            //else
            //{
            //    MessageBox.Show("错误提示:没有找到任何JSON文件。");
            //}
        }
예제 #10
0
        private void RefreshAction02(MarketStock stock)
        {
            var programFolder = new DirectoryInfo(Environment.CurrentDirectory).Parent.Parent.FullName;
            var jsonFilePath = Path.Combine(programFolder, "phantomjs\\outputtmpfiles\\company-detail", stock.Code + ".json");
            var notExistedStockJsonFilePath = Path.Combine(programFolder, "phantomjs\\outputtmpfiles\\company-detail", "failed-" + stock.Code + ".json");

            if(File.Exists(jsonFilePath))
            {
                var crawler = new CompanyDetailInfoCrawler(jsonFilePath);
                var detailInfo = crawler.CrawlObject();
                if (detailInfo != null)
                {
                    var propertyJson = JsonConvert.SerializeObject(detailInfo);
                    _bizCompanyMatrix.UpdateStockMatrix_DetailInfo(stock.Code, propertyJson);
                }
                else
                {
                    _bizCompanyMatrix.UpdateStockMatrix_DetailInfo(stock.Code, null);
                }
                // 删除已提取过的文件
                File.Delete(jsonFilePath);
            }
            else if(File.Exists(notExistedStockJsonFilePath))
            {
                _bizCompanyMatrix.UpdateStockMatrix_DetailInfo(stock.Code, null);
                // 删除已提取过的文件
                File.Delete(notExistedStockJsonFilePath);
            }
        }
예제 #11
0
        private void RefreshAction01(MarketStock stock)
        {
            var config = CrawlerConfig.GetConfig();
            var crawler = new CompanyBasicInfoCrawler(stock.Market, stock.Code, config.SnowballCookies);
            var basicInfo = crawler.CrawlObject();
            if (basicInfo != null)
            {
                var propertyJson = JsonConvert.SerializeObject(basicInfo);
                _bizCompanyMatrix.UpdateStockMatrix_BasicInfo(stock.Code, propertyJson);
            }
            else
            {
                _bizCompanyMatrix.UpdateStockMatrix_BasicInfo(stock.Code, null);
            }

            Thread.Sleep(200);
        }