コード例 #1
0
        public static List <TradeTranDTO> GetTradeList(string code, DateTime from, DateTime?to = null)
        {
            to = to.GetValueOrDefault(DateTime.Now).Date;
            var shortCode = StockHelper.GetShortCode(code);

            code = StockHelper.GetLongCode(code);

            List <TradeTranDTO> list = new List <TradeTranDTO>(100);
            var curr = from.Date;

            while (curr <= to)
            {
                var client = new RestClient();
                var csv    = client.GetString(string.Format(tradeTranurl, curr.ToString("yyyy-MM-dd"), code));
                if (!csv.IsNullOrEmpty() &&
                    csv.Length > 1000)
                {
                    csv = csv.Replace("\t", ",");
                    csv = csv.Replace("--", "0");
                    csv = csv.Replace("成交时间,成交价,价格变动,成交量(手),成交额(元),性质", "Time,Price,PriceChange,Qty,Amount,Vector");
                    list.Add(new TradeTranDTO()
                    {
                        StockCode = shortCode, InDate = curr, Detail = csv
                    });
                }
                curr = curr.AddDays(1);
            }
            return(list);
        }
コード例 #2
0
        public static ZhubiDTO GetZhubiDTO(string code, DateTime date)
        {
            var dto = ZhubiDAL.GetZhubi(code, date);

            if (dto == null)
            {
                var xls = SinaBiz.GetZhubi(code, date);
                if (!string.IsNullOrEmpty(xls))
                {
                    dto = new ZhubiDTO
                    {
                        StockCode = StockHelper.GetShortCode(code)
                        ,
                        InDate = date.Date
                        ,
                        Xls = xls
                    };
                    ZhubiDAL.Insert(dto);
                }
            }
            return(dto);
        }
コード例 #3
0
        public static ZhubiDTO GetZhubi(string code, DateTime date)
        {
            var sql = @"SELECT StockCode,Indate, `Xls`
FROM `svc`.`zhubi`
where stockcode = @StockCode and InDate = @InDate ";

            return(SqlHelper.GetEntity <ZhubiDTO>(sql,
                                                  SqlHelper.CreateParameter("@StockCode", StockHelper.GetShortCode(code))
                                                  , SqlHelper.CreateParameter("@InDate", date.ToString("yyyy-MM-dd"))));
        }
コード例 #4
0
ファイル: THSBiz.cs プロジェクト: dennynewegg/item
 public static List <StockFinanceEntity> DownloadFinance(StockEntity stock)
 {
     try
     {
         var    stockcode = stock.StockCode;
         string url       = string.Format("http://basic.10jqka.com.cn/{0}/xls/mainreport.xls", StockHelper.GetShortCode(stockcode));
         var    buffer    = new RestClient().GetData(url);
         if (buffer == null ||
             buffer.Length == 0)
         {
             return(null);
         }
         var path = "Finance\\" + stockcode + ".xls";
         if (File.Exists(path))
         {
             File.Delete(path);
         }
         Directory.CreateDirectory(Path.GetDirectoryName(path));
         File.WriteAllBytes(path, buffer);
         return(ReadFromExcel(stock, path));
     }
     catch (Exception ex)
     {
         ExceptionHelper.Handler(ex);
         return(null);
     }
 }