示例#1
0
        /// <summary>
        /// The total volume of bids which was below <see cref="PoC"/>.
        /// </summary>
        /// <param name="volumeProfile">Volume profile.</param>
        /// <returns>The total volume of bids.</returns>
        public static decimal BuyVolBelowPoC(this VolumeProfile volumeProfile)
        {
            var poc = volumeProfile.PoC();

            return(volumeProfile.PriceLevels.Where(p => p.Price < poc.Price).Select(p => p.BuyVolume).Sum());
        }
示例#2
0
        /// <summary>
        /// The total volume of asks which was above <see cref="PoC"/>.
        /// </summary>
        /// <param name="volumeProfile">Volume profile.</param>
        /// <returns>The total volume of asks.</returns>
        public static decimal SellVolAbovePoC(this VolumeProfile volumeProfile)
        {
            var poc = volumeProfile.PoC();

            return(volumeProfile.PriceLevels.Where(p => p.Price > poc.Price).Select(p => p.SellVolume).Sum());
        }
示例#3
0
 /// <summary>
 /// The total number of asks in the <see cref="VolumeProfile"/>.
 /// </summary>
 /// <param name="volumeProfile">Volume profile.</param>
 /// <returns>The total number of asks.</returns>
 public static decimal TotalSellCount(this VolumeProfile volumeProfile)
 {
     return(volumeProfile.PriceLevels.Select(p => p.SellCount).Sum());
 }
示例#4
0
        /// <summary>
        /// POC (Point Of Control) returns <see cref="CandlePriceLevel"/> which had the maximum volume.
        /// </summary>
        /// <param name="volumeProfile">Volume profile.</param>
        /// <returns>The <see cref="CandlePriceLevel"/> which had the maximum volume.</returns>
        public static CandlePriceLevel PoC(this VolumeProfile volumeProfile)
        {
            var max = volumeProfile.PriceLevels.Select(p => (p.BuyVolume + p.SellVolume)).Max();

            return(volumeProfile.PriceLevels.FirstOrDefault(p => p.BuyVolume + p.SellVolume == max));
        }
示例#5
0
 /// <summary>
 /// The total volume of bids in the <see cref="VolumeProfile"/>.
 /// </summary>
 /// <param name="volumeProfile">Volume profile.</param>
 /// <returns>The total volume of bids.</returns>
 public static decimal TotalBuyVolume(this VolumeProfile volumeProfile)
 {
     return(volumeProfile.PriceLevels.Select(p => p.BuyVolume).Sum());
 }
示例#6
0
 /// <summary>
 /// The total Delta which was below <see cref="PoC"/>.
 /// </summary>
 /// <param name="volumeProfile">Volume profile.</param>
 /// <returns>Delta.</returns>
 public static decimal DeltaBelowPoC(this VolumeProfile volumeProfile)
 {
     return(volumeProfile.BuyVolBelowPoC() - volumeProfile.SellVolBelowPoC());
 }
示例#7
0
        /// <summary>
        /// It returns the price level at which the minimum <see cref="Delta"/> is passed.
        /// </summary>
        /// <param name="volumeProfile">Volume profile.</param>
        /// <returns>The price level.</returns>
        public static CandlePriceLevel PriceLevelOfMinDelta(this VolumeProfile volumeProfile)
        {
            var delta = volumeProfile.PriceLevels.Select(p => p.BuyVolume - p.SellVolume).Min();

            return(volumeProfile.PriceLevels.FirstOrDefault(p => p.BuyVolume - p.SellVolume == delta));
        }
示例#8
0
 /// <summary>
 /// The difference between <see cref="TotalBuyVolume"/> and <see cref="TotalSellVolume"/>.
 /// </summary>
 /// <param name="volumeProfile">Volume profile.</param>
 /// <returns>Delta.</returns>
 public static decimal Delta(this VolumeProfile volumeProfile)
 {
     return(volumeProfile.TotalBuyVolume() - volumeProfile.TotalSellVolume());
 }
示例#9
0
 /// <summary>
 /// The total volume which was above <see cref="PoC"/>.
 /// </summary>
 /// <param name="volumeProfile">Volume profile.</param>
 /// <returns>Total volume.</returns>
 public static decimal VolumeAbovePoC(this VolumeProfile volumeProfile)
 {
     return(volumeProfile.BuyVolAbovePoC() + volumeProfile.SellVolAbovePoC());
 }
示例#10
0
		private TimeFrameCandle GetCandle(ExecutionMessage tick)
		{
			var time = tick.ServerTime;
			var price = tick.TradePrice.Value;

			if (_candle == null || time >= _candle.CloseTime)
			{
				//var t = TimeframeSegmentDataSeries.GetTimeframePeriod(time.DateTime, _timeframe);
				var tf = TimeSpan.FromMinutes(_timeframe);
				var bounds = tf.GetCandleBounds(time, _security.Board);
				_candle = new TimeFrameCandle
				{
					TimeFrame = tf,
					OpenTime = bounds.Min,
					CloseTime = bounds.Max,
				};
				_volumeProfile = new VolumeProfile();

                _candle.OpenPrice = _candle.HighPrice = _candle.LowPrice = _candle.ClosePrice = price;
				_volumeProfile.Update(new TickCandleBuilderSourceValue(_security, tick));

				_allCandles.Add(_candle);

				return _candle;
			}

			if (time < _candle.OpenTime)
				throw new InvalidOperationException("invalid time");

			if (price > _candle.HighPrice)
				_candle.HighPrice = price;

			if (price < _candle.LowPrice)
				_candle.LowPrice = price;

			_candle.ClosePrice = price;

			_candle.TotalVolume += tick.Volume.Value;

			_volumeProfile.Update(new TickCandleBuilderSourceValue(_security, tick));

			return _candle;
		}
示例#11
0
		private void AppendTick(Security security, ExecutionMessage tick)
		{
			var time = tick.ServerTime;
			var price = tick.TradePrice.Value;

			if (_candle == null || time >= _candle.CloseTime)
			{
				if (_candle != null)
				{
					var candle = (TimeFrameCandle)_candle.Clone();
					_updatedCandles[candle.OpenTime] = candle;
					_lastPrice = candle.ClosePrice;
				}

				//var t = TimeframeSegmentDataSeries.GetTimeframePeriod(time.DateTime, _timeframe);
				var tf = TimeSpan.FromMinutes(_timeframe);
				var bounds = tf.GetCandleBounds(time, _security.Board);
				_candle = new TimeFrameCandle
				{
					TimeFrame = tf,
					OpenTime = bounds.Min,
					CloseTime = bounds.Max,
				};
				_volumeProfile = new VolumeProfile();
				_candle.PriceLevels = _volumeProfile.PriceLevels;

				_candle.OpenPrice = _candle.HighPrice = _candle.LowPrice = _candle.ClosePrice = price;
				_volumeProfile.Update(new TickCandleBuilderSourceValue(security, tick));
			}

			if (time < _candle.OpenTime)
				throw new InvalidOperationException("invalid time");

			if (price > _candle.HighPrice)
				_candle.HighPrice = price;

			if (price < _candle.LowPrice)
				_candle.LowPrice = price;

			_candle.ClosePrice = price;

			_candle.TotalVolume += tick.TradeVolume.Value;

			_volumeProfile.Update(new TickCandleBuilderSourceValue(security, tick));
		}