//public static List<StockKLine> parseKLineArrayXq(String str) { // JObject jo = (JObject)JsonConvert.DeserializeObject(str); // bool ret = (jo["success"].Equals("true")); // if (ret) { // List<StockKLine> kLines = new List<StockKLine>(); // JArray arr = JArray.Parse(jo["chartlist"].ToString()); // for (int i = 0; i < arr.Count; i++) { // StockKLine kl = parseKLineDataXq(arr[i].ToString()); // kLines.Add(kl); // } // return kLines; // } // return null; //} //private static StockKLine parseKLineDataXq(String str) { // JObject jo = (JObject)JsonConvert.DeserializeObject(str); // if (jo != null) { // StockKLine kLine = new StockKLine(); // kLine.highestPrice = double.Parse(jo["high"].ToString()); // kLine.lowestPrice = double.Parse(jo["low"].ToString()); // kLine.openPrice = double.Parse(jo["open"].ToString()); // kLine.latestPrice = double.Parse(jo["close"].ToString()); // kLine.volume = long.Parse(jo["volume"].ToString()); // kLine.date = jo["time"].ToString(); // return kLine; // } // return null; //} public static List <StockKLine> parseKLineArrayBaidu(String str) { JObject jo = (JObject)JsonConvert.DeserializeObject(str); bool ret = (jo["errorMsg"].ToString().Equals("SUCCESS")); if (ret) { List <StockKLine> kLines = new List <StockKLine>(); if (jo.Property("mashData") != null) { JArray arr = JArray.Parse(jo["mashData"].ToString()); for (int i = 0; i < arr.Count; i++) { StockKLine kl = parseKLineDataBaidu(arr[i].ToString()); kLines.Add(kl); } } kLines.Reverse(); return(kLines); } return(null); }
public static List <StockKLine> parseKLineArray(String str) { if (str == null) { return(null); } string[] wrapper = str.Split('\"'); if (wrapper.Length < 2) { return(null); } string[] arr = wrapper[1].Split('\n'); if (arr.Length < 3) { return(null); } List <StockKLine> kLines = new List <StockKLine>(); for (int i = 2; i < arr.Length; i++) { StockKLine kl = parseKLineData(arr[i]); if (kl == null) { continue; } kLines.Add(kl); } return(kLines); }
private static StockKLine parseKLineData(String str) { string[] arr = str.Split(' '); if (arr.Length < 6) { return(null); } StockKLine kl = new StockKLine(); kl.date = arr[0]; kl.openPrice = double.Parse(arr[1]); kl.latestPrice = double.Parse(arr[2]); kl.highestPrice = double.Parse(arr[3]); kl.lowestPrice = double.Parse(arr[4]); kl.volume = long.Parse((arr[5].Split('\\'))[0]); return(kl); }
public static StockKLine getMonthKLineByYearMonth(List <StockKLine> klArr, string year, string month) { StockKLine kl = null; if (klArr != null && klArr.Count > 0) { for (int i = 0; i < klArr.Count; i++) { if (DateUtil.matchYearMonth(klArr[i].date, year, month)) { kl = klArr[i]; break; } } } return(kl); }
private static StockKLine parseKLineDataBaidu(String str) { JObject jo = (JObject)JsonConvert.DeserializeObject(str); if (jo != null) { StockKLine kLine = new StockKLine(); kLine.highestPrice = double.Parse(jo["kline"]["high"].ToString()); kLine.lowestPrice = double.Parse(jo["kline"]["low"].ToString()); kLine.openPrice = double.Parse(jo["kline"]["open"].ToString()); kLine.latestPrice = double.Parse(jo["kline"]["close"].ToString()); kLine.volume = long.Parse(jo["kline"]["volume"].ToString()); kLine.date = jo["date"].ToString(); return(kLine); } return(null); }
public static double calcBonusRefValue(string stockID, string year, string season) { double bonus = 0; if (getDistribBonus(stockID, year, season, out bonus)) { List <StockKLine> mk = StockDataCenter.getInstance().getMonthKLine(stockID); if (mk == null) { return(0.0); } string targetMonth = convertMonthBySeason(season); StockKLine kl = StockDataUtil.getMonthKLineByYearMonth(mk, year, targetMonth); return(bonus / kl.latestPrice); } return(0.0); }
public static double calcCostRefValueForQuarter(string stockID, string year, string season) { double costRefVal = 0.0; StockReportData rd = StockDBVisitor.getInstance().getStockReportData(stockID, year, season); int qt = int.Parse(season); if (rd == null) { return(0.0); } double eps = rd.eps; if (qt > 1) { int prevQuarter = qt - 1; StockReportData prevRd = StockDBVisitor.getInstance().getStockReportData(stockID, year, prevQuarter.ToString()); if (prevRd != null) { eps -= prevRd.eps; } } //string str = StockDataCollector.queryMonthlyKLineData(stockID); List <StockKLine> mk = StockDataCenter.getInstance().getMonthKLine(stockID); //StockDataConvertor.parseKLineArray(str); if (mk == null) { return(0.0); } string targetMonth = convertMonthBySeason(season); StockKLine kl = StockDataUtil.getMonthKLineByYearMonth(mk, year, targetMonth); int quarter = int.Parse(season); if (kl != null) { costRefVal = eps / kl.latestPrice; } return(costRefVal); }
private StockKLine ConvertToDayLine(IStockRealTime realTimeData) { StockKLine data = new StockKLine(); // 日期与时间 data.Time = realTimeData.Time.Date; // 今开 data.Open = realTimeData.TodayOpen; // 最高 data.High = realTimeData.High; // 最低 data.Low = realTimeData.Low; // 收盘 data.Close = realTimeData.Current; // 成交量 data.Volume = realTimeData.Volume; // 成交额 data.Amount = realTimeData.Amount; return data; }
public static double calcCostRefValue(string stockID, string year, string season) { double costRefVal = 0.0; StockReportData rd = StockDBVisitor.getInstance().getStockReportData(stockID, year, season); List <StockKLine> mk = StockDataCenter.getInstance().getMonthKLine(stockID); if (mk == null) { return(0.0); } string targetMonth = convertMonthBySeason(season); StockKLine kl = StockDataUtil.getMonthKLineByYearMonth(mk, year, targetMonth); int quarter = int.Parse(season); if (rd != null && kl != null) { costRefVal = (rd.eps / kl.latestPrice) / quarter * 4; } return(costRefVal); }
public static double calcPBCostValue(string stockID, string year, string quarter) { double costRefVal = 0.0; double pe = 0.0; StockReportData rd = StockDBVisitor.getInstance().getStockReportData(stockID, year, quarter); if (rd == null) { return(double.MaxValue); } List <StockKLine> mk = StockDataCenter.getInstance().getMonthKLine(stockID); if (mk == null) { return(double.MaxValue); } string targetMonth = convertMonthBySeason(quarter); StockKLine kl = StockDataUtil.getMonthKLineByYearMonth(mk, year, targetMonth); if (kl == null) { return(double.MaxValue); } pe = kl.latestPrice / rd.eps; StockProfitData pd = StockDBVisitor.getInstance().getStockProfitData(stockID, year, quarter); if (pd == null) { return(double.MaxValue); } costRefVal = pe * pd.roe; return(costRefVal); }