Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        public static bool CheckCanSellByAnaylyzeData(AnaylyzeData anaylyzeData, TradeRecord tradeRecord)
        {
            decimal nearHigherOpen = new decimal(0);

            foreach (var item in anaylyzeData.OneKlineData)
            {
                if (Utils.GetDateById(item.id) <= tradeRecord.BuyDate)
                {
                    continue;
                }

                if (item.open > nearHigherOpen)
                {
                    nearHigherOpen = item.open;
                }
            }

            decimal percent = (decimal)1.08;

            if (anaylyzeData.NowPrice < tradeRecord.BuyOrderPrice * percent)
            {
                return(false);
            }

            if (anaylyzeData.NowPrice * (decimal)1.005 < nearHigherOpen && anaylyzeData.NowPrice * (decimal)1.015 > nearHigherOpen)
            {
                return(true);
            }

            return(false);
        }