Пример #1
0
        private static PnFCandleMessage CreateCandle(MarketDataMessage message, PnFArg pnfArg, decimal openPrice, decimal highPrice, decimal lowPrice, decimal closePrice, decimal price, decimal?volume, Sides?side, DateTimeOffset time, decimal?oi)
        {
            var candle = new PnFCandleMessage
            {
                OpenPrice  = openPrice,
                ClosePrice = closePrice,
                HighPrice  = highPrice,
                LowPrice   = lowPrice,
                OpenVolume = volume,
                //CloseVolume = volume,
                HighVolume = volume,
                LowVolume  = volume,
                SecurityId = message.SecurityId,
                OpenTime   = time,
                //CloseTime = time,
                HighTime = time,
                LowTime  = time,
                PnFArg   = pnfArg,
                State    = CandleStates.Active,
            };

            if (message.IsCalcVolumeProfile)
            {
                candle.VolumeProfile = new CandleMessageVolumeProfile();
            }

            UpdateCandle(candle, price, volume, time, side, oi);

            return(candle);
        }
Пример #2
0
 /// <summary>
 /// To create <see cref="CandleSeries"/> for <see cref="PnFCandle"/> candles.
 /// </summary>
 /// <param name="security">Security.</param>
 /// <param name="arg">The value of <see cref="PnFCandle.PnFArg"/>.</param>
 /// <returns>Candles series.</returns>
 public static CandleSeries PnF(this Security security, PnFArg arg)
 {
     return(new CandleSeries(typeof(PnFCandle), security, arg));
 }
Пример #3
0
        private static PnFCandleMessage CreateCandle(ICandleBuilderSubscription subscription, DataType buildFrom, PnFArg pnfArg, decimal openPrice, decimal highPrice, decimal lowPrice, decimal closePrice, decimal price, decimal?volume, Sides?side, DateTimeOffset time, decimal?oi)
        {
            var candle = new PnFCandleMessage
            {
                SecurityId = subscription.Message.SecurityId,
                PnFArg     = pnfArg,
                BuildFrom  = buildFrom,

                OpenPrice  = openPrice,
                ClosePrice = closePrice,
                HighPrice  = highPrice,
                LowPrice   = lowPrice,
                OpenVolume = volume,
                //CloseVolume = volume,
                HighVolume = volume,
                LowVolume  = volume,
                OpenTime   = time,
                //CloseTime = time,
                HighTime = time,
                LowTime  = time,
                State    = CandleStates.Active,
            };

            if (subscription.Message.IsCalcVolumeProfile)
            {
                var levels = new List <CandlePriceLevel>();
                subscription.VolumeProfile = new VolumeProfileBuilder(levels);
                candle.PriceLevels         = levels;
            }

            UpdateCandle(candle, price, volume, time, side, oi, subscription.VolumeProfile);

            return(candle);
        }