Esempio n. 1
0
        public static List <Candle> ConvertCandleToCandle(List <Candle> candles, CandleType type)
        {
            var      result            = new List <Candle>();
            DateTime currentCandleTime = CandleHelper.GetCandleTime(candles[0].CandleTime, candles[0].TradingDay, type);
            var      currentCandle     = new List <Candle>()
            {
                candles[0]
            };

            for (int i = 1; i < candles.Count; i++)
            {
                Candle   item          = candles[i];
                DateTime newCandleTime = CandleHelper.GetCandleTime(item.CandleTime, item.TradingDay, type);
                if (newCandleTime != currentCandleTime)
                {
                    Candle newCandle = CombineCandle(currentCandle, currentCandleTime);
                    result.Add(newCandle);
                    currentCandleTime = newCandleTime;
                    currentCandle.Clear();
                    currentCandle.Add(item);
                }
                currentCandle.Add(item);
            }
            result.Add(CombineCandle(currentCandle, currentCandleTime));
            return(result);
        }
Esempio n. 2
0
        public bool ProcessQuotation(Quotation quotation, int volume)
        {
            DateTime newCandleTime = CandleHelper.GetCandleTime(quotation.Time, quotation.TradingDay, this.type);

            if (this.LastData == null || this.LastData.CandleTime != newCandleTime)
            {
                this.LastData = new Candle(quotation, newCandleTime, volume);
                return(true);
            }
            else
            {
                this.LastData.UpdateCandle(quotation, volume);
                return(false);
            }
        }