示例#1
0
        /// <summary>
        /// Converts a list of Trades into candles
        /// </summary>
        /// <param name="trades"></param>
        /// <param name="candlesDurationInMin"></param>
        /// <param name="tradeSource"></param>
        /// <returns></returns>
        private static IList <OHLC> CalculateOHLCFromTrades(IList <BitcoinCharts.Models.Trade> trades, int candlesDurationInMin, TradeSource tradeSource)
        {
            var result = from trade in trades
                         group trade by(long)(trade.Datetime.DateTime.Subtract(DateTime.MinValue).TotalMinutes / candlesDurationInMin) into candleTrades
                         let key = candleTrades.Key
                                   select new OHLC()
            {
                Date        = DateTime.MinValue.AddMinutes(candleTrades.Key * candlesDurationInMin).ChangeTypeToUtc(),
                Open        = candleTrades.First().Price,
                Close       = candleTrades.Last().Price,
                Low         = candleTrades.Min(x => x.Price),
                High        = candleTrades.Max(x => x.Price),
                TradesCount = candleTrades.Count(),
                TradeSource = tradeSource
            };

            return(result.ToList());
        }
示例#2
0
 public TradeReport(TradeSource source)
 {
     this.source = source;
 }
示例#3
0
        /// <summary>
        /// Converts a list of Trades into candles
        /// </summary>
        /// <param name="trades"></param>
        /// <param name="candlesDurationInMin"></param>
        /// <param name="tradeSource"></param>
        /// <returns></returns>
        private static IList<OHLC> CalculateOHLCFromTrades(IList<BitcoinCharts.Models.Trade> trades, int candlesDurationInMin, TradeSource tradeSource)
        {
            var result = from trade in trades
                         group trade by (long)(trade.Datetime.DateTime.Subtract(DateTime.MinValue).TotalMinutes / candlesDurationInMin) into candleTrades
                         let key = candleTrades.Key
                         select new OHLC()
                         {
                             Date = DateTime.MinValue.AddMinutes(candleTrades.Key * candlesDurationInMin).ChangeTypeToUtc(),
                             Open = candleTrades.First().Price,
                             Close = candleTrades.Last().Price,
                             Low = candleTrades.Min(x => x.Price),
                             High = candleTrades.Max(x => x.Price),
                             TradesCount = candleTrades.Count(),
                             TradeSource = tradeSource
                         };

            return result.ToList();
        }
示例#4
0
文件: Main.cs 项目: erdincay/easybot
        public IList<OHLC> CalculateOHLCFromTrades(IList<BitcoinCharts.Models.Trade> trades, double interval, TradeSource tradeSource)
        {
            var result = from trade in trades
                         group trade by (long)(trade.Datetime.DateTime.Subtract(DateTime.MinValue).TotalMinutes / interval) into candleTrades
                         let key = candleTrades.Key
                         select new OHLC()
                         {
                             Date = DateTime.MinValue.AddMinutes(candleTrades.Key * interval),
                             Open = candleTrades.First().Price,
                             Close = candleTrades.Last().Price,
                             Low = candleTrades.Min(x => x.Price),
                             High = candleTrades.Max(x => x.Price),
                             TradesCount = candleTrades.Count(),
                             TradeSource = tradeSource
                         };

            return result.ToList();
        }