/// <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()); }
public TradeReport(TradeSource source) { this.source = source; }
/// <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(); }
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(); }