/// <summary> /// 1. 计算5分钟的数据, 看看最高值和最低值,以及目前值 /// 2. /// </summary> /// <param name="comparePrice"></param> /// <param name="compareDate"></param> /// <param name="coin"></param> /// <param name="toCoin"></param> /// <param name="nowOpen"></param> /// <returns></returns> public AnaylyzeData GetAnaylyzeData(string coin, string toCoin) { // 返回一个对象, 目前值, 5分钟最高值, 5分钟最低值,目前值得5分钟偏向(以最低值为准),5分钟列表,1分钟列表 AnaylyzeData data = new AnaylyzeData(); ResponseKline fiveRes = new AnaylyzeApi().kline(coin + toCoin, "5min", 1440); ResponseKline oneRes = new AnaylyzeApi().kline(coin + toCoin, "1min", 1440); data.FiveKlineData = fiveRes.data; data.OneKlineData = oneRes.data; data.NowPrice = oneRes.data[0].open; decimal highest = new decimal(0); decimal lowest = new decimal(99999999); foreach (var item in data.FiveKlineData) { if (item.open > highest) { highest = item.open; } if (item.open < lowest) { lowest = item.open; } } data.FiveHighestPrice = highest; data.FiveLowestPrice = lowest; data.NowLeanPercent = (data.NowPrice - lowest) / (highest - lowest); return(data); }
public async Task <object> StatisticsLine(string coin, string username = "******") { // 购买点 var buy = await SpotRecordBiz.ListTradePointOfBuy(username, coin); // 出售点 var sell = await SpotRecordBiz.ListTradePointOfSell(username, coin); // 走势 var zs = AnaylyzeApi.kline(coin + "usdt", "1min", 1440).data; var min = (decimal)9999999; var max = (decimal)0; foreach (var item in zs) { if (min > item.low) { min = item.low; } if (max < item.high) { max = item.high; } } return(new { zs, buy, sell, min, max }); }
public decimal AnalyzeNeedSell(decimal comparePrice, DateTime compareDate, string coin, string toCoin, out decimal nowOpen) { // 当前open nowOpen = 0; decimal higher = new decimal(0); try { ResponseKline res = new AnaylyzeApi().kline(coin + toCoin, "1min", 1440); nowOpen = res.data[0].open; List <FlexPoint> flexPointList = new List <FlexPoint>(); decimal openHigh = res.data[0].open; decimal openLow = res.data[0].open; long idHigh = 0; long idLow = 0; int lastHighOrLow = 0; // 1 high, -1: low foreach (var item in res.data) { if (Utils.GetDateById(item.id) < compareDate) { continue; } if (item.open > higher) { higher = item.open; } } } catch (Exception ex) { Console.WriteLine("1111111111111111111111 over"); } return(higher); }
/// <summary> /// 分析价位走势 /// </summary> /// <param name="coin"></param> /// <param name="toCoin"></param> public List <FlexPoint> Analyze(string coin, string toCoin, out decimal nowOpen) { nowOpen = 0; try { ResponseKline res = new AnaylyzeApi().kline(coin + toCoin, "1min", 1440); nowOpen = res.data[0].open; List <FlexPoint> flexPointList = new List <FlexPoint>(); decimal openHigh = res.data[0].open; decimal openLow = res.data[0].open; long idHigh = res.data[0].id; long idLow = res.data[0].id; int lastHighOrLow = 0; // 1 high, -1: low foreach (var item in res.data) { if (item.open > openHigh) { openHigh = item.open; idHigh = item.id; } if (item.open < openLow) { openLow = item.open; idLow = item.id; } // 相差了6%, 说明是一个节点了。 if (openHigh >= openLow * (decimal)1.06) { if (idHigh > idLow && lastHighOrLow != 1) { flexPointList.Add(new FlexPoint() { isHigh = true, open = openHigh, id = idHigh }); lastHighOrLow = 1; openHigh = openLow; idHigh = idLow; } else if (idHigh < idLow && lastHighOrLow != -1) { flexPointList.Add(new FlexPoint() { isHigh = false, open = openLow, id = idLow }); lastHighOrLow = -1; openLow = openHigh; idLow = idHigh; } } } return(flexPointList); } catch (Exception ex) { logger.Error(ex.Message, ex); return(new List <FlexPoint>()); } }