Class CandleHelper
- Namespace
- StockSharp.Algo.Candles
- Assembly
- StockSharp.Algo.dll
Extension class for candles.
public static class CandleHelper
- Inheritance
-
CandleHelper
- Inherited Members
Methods
BuyVolAbovePoC(VolumeProfileBuilder)
The total volume of bids which was above PoC(VolumeProfileBuilder).
public static decimal BuyVolAbovePoC(this VolumeProfileBuilder volumeProfile)
Parameters
volumeProfile
VolumeProfileBuilderVolume profile.
Returns
- decimal
The total volume of bids.
BuyVolBelowPoC(VolumeProfileBuilder)
The total volume of bids which was below PoC(VolumeProfileBuilder).
public static decimal BuyVolBelowPoC(this VolumeProfileBuilder volumeProfile)
Parameters
volumeProfile
VolumeProfileBuilderVolume profile.
Returns
- decimal
The total volume of bids.
Compress(IEnumerable<CandleMessage>, BiggerTimeFrameCandleCompressor, bool)
Compress candles to bigger time-frame candles.
public static IEnumerable<CandleMessage> Compress(this IEnumerable<CandleMessage> source, BiggerTimeFrameCandleCompressor compressor, bool includeLastCandle)
Parameters
source
IEnumerable<CandleMessage>Smaller time-frame candles.
compressor
BiggerTimeFrameCandleCompressorCompressor of candles from smaller time-frames to bigger.
includeLastCandle
boolOutput last active candle as finished.
Returns
- IEnumerable<CandleMessage>
Bigger time-frame candles.
ConvertToTrades(ICandleMessage, decimal, int, (Sides? side, decimal price, decimal volume, DateTimeOffset time)[])
To create tick trades from candle.
public static void ConvertToTrades(this ICandleMessage candleMsg, decimal volumeStep, int decimals, (Sides? side, decimal price, decimal volume, DateTimeOffset time)[] ticks)
Parameters
candleMsg
ICandleMessageCandle.
volumeStep
decimalVolume step.
decimals
intThe number of decimal places for the volume.
ticks
(Sides? side, decimal price, decimal volume, DateTimeOffset time)[]Array to tick trades.
Delta(VolumeProfileBuilder)
The difference between TotalBuyVolume(VolumeProfileBuilder) and TotalSellVolume(VolumeProfileBuilder).
public static decimal Delta(this VolumeProfileBuilder volumeProfile)
Parameters
volumeProfile
VolumeProfileBuilderVolume profile.
Returns
- decimal
Delta.
DeltaAbovePoC(VolumeProfileBuilder)
The total Delta which was above PoC(VolumeProfileBuilder).
public static decimal DeltaAbovePoC(this VolumeProfileBuilder volumeProfile)
Parameters
volumeProfile
VolumeProfileBuilderVolume profile.
Returns
- decimal
Delta.
DeltaBelowPoC(VolumeProfileBuilder)
The total Delta which was below PoC(VolumeProfileBuilder).
public static decimal DeltaBelowPoC(this VolumeProfileBuilder volumeProfile)
Parameters
volumeProfile
VolumeProfileBuilderVolume profile.
Returns
- decimal
Delta.
FilterSmallerTimeFrames(IEnumerable<TimeSpan>, TimeSpan)
Filter time-frames to find multiple smaller time-frames.
public static IEnumerable<TimeSpan> FilterSmallerTimeFrames(this IEnumerable<TimeSpan> timeFrames, TimeSpan original)
Parameters
timeFrames
IEnumerable<TimeSpan>All time-frames.
original
TimeSpanOriginal time-frame.
Returns
- IEnumerable<TimeSpan>
Multiple smaller time-frames.
GetBody(ICandleMessage)
To get the candle body.
public static decimal GetBody(this ICandleMessage candle)
Parameters
candle
ICandleMessageThe candle for which you need to get the body.
Returns
- decimal
The candle body.
GetBottomShadow(ICandleMessage)
To get the candle lower shadow length.
public static decimal GetBottomShadow(this ICandleMessage candle)
Parameters
candle
ICandleMessageThe candle for which you need to get the lower shadow length.
Returns
- decimal
The candle lower shadow length. If 0, there is no shadow.
GetCandleBounds(TimeSpan, DateTimeOffset, ExchangeBoard)
To get candle time frames relatively to the exchange working hours.
public static Range<DateTimeOffset> GetCandleBounds(this TimeSpan timeFrame, DateTimeOffset currentTime, ExchangeBoard board)
Parameters
timeFrame
TimeSpanThe time frame for which you need to get time range.
currentTime
DateTimeOffsetThe current time within the range of time frames.
board
ExchangeBoardThe information about the board from which WorkingTime working hours will be taken.
Returns
- Range<DateTimeOffset>
The candle time frames.
GetCandleBounds(TimeSpan, DateTimeOffset, BoardMessage)
To get candle time frames relatively to the exchange working hours.
public static Range<DateTimeOffset> GetCandleBounds(this TimeSpan timeFrame, DateTimeOffset currentTime, BoardMessage board)
Parameters
timeFrame
TimeSpanThe time frame for which you need to get time range.
currentTime
DateTimeOffsetThe current time within the range of time frames.
board
BoardMessageThe information about the board from which WorkingTime working hours will be taken.
Returns
- Range<DateTimeOffset>
The candle time frames.
GetLength(ICandleMessage)
To get the candle length.
public static decimal GetLength(this ICandleMessage candle)
Parameters
candle
ICandleMessageThe candle for which you need to get a length.
Returns
- decimal
The candle length.
GetMiddlePrice(ICandleMessage, decimal?)
To get the candle middle price.
public static decimal GetMiddlePrice(this ICandleMessage candle, decimal? priceStep)
Parameters
candle
ICandleMessageThe candle for which you need to get a length.
priceStep
decimal?
Returns
- decimal
The candle length.
GetSeries<TCandle>(ISubscriptionProvider, Security, object)
To get a candles series by the specified parameters.
public static CandleSeries GetSeries<TCandle>(this ISubscriptionProvider subscriptionProvider, Security security, object arg) where TCandle : ICandleMessage
Parameters
subscriptionProvider
ISubscriptionProviderThe subscription provider.
security
SecurityThe instrument by which trades should be filtered for the candles creation.
arg
objectCandle arg.
Returns
- CandleSeries
The candles series. null if this series is not registered.
Type Parameters
TCandle
Candles type.
GetTimeFrameCount(Range<DateTimeOffset>, TimeSpan, ExchangeBoard)
To get the number of time frames within the specified time range.
public static long GetTimeFrameCount(this Range<DateTimeOffset> range, TimeSpan timeFrame, ExchangeBoard board)
Parameters
range
Range<DateTimeOffset>The specified time range for which you need to get the number of time frames.
timeFrame
TimeSpanThe time frame size.
board
ExchangeBoard
Returns
- long
The received number of time frames.
GetTimeFrameCount(Range<DateTimeOffset>, TimeSpan, BoardMessage)
To get the number of time frames within the specified time range.
public static long GetTimeFrameCount(this Range<DateTimeOffset> range, TimeSpan timeFrame, BoardMessage board)
Parameters
range
Range<DateTimeOffset>The specified time range for which you need to get the number of time frames.
timeFrame
TimeSpanThe time frame size.
board
BoardMessage
Returns
- long
The received number of time frames.
GetTopShadow(ICandleMessage)
To get the candle upper shadow length.
public static decimal GetTopShadow(this ICandleMessage candle)
Parameters
candle
ICandleMessageThe candle for which you need to get the upper shadow length.
Returns
- decimal
The candle upper shadow length. If 0, there is no shadow.
GetValueArea<TCandle>(IEnumerable<TCandle>)
To calculate the area for the candles group.
public static VolumeProfileBuilder GetValueArea<TCandle>(this IEnumerable<TCandle> candles) where TCandle : ICandleMessage
Parameters
candles
IEnumerable<TCandle>Candles.
Returns
- VolumeProfileBuilder
The area.
Type Parameters
TCandle
IsCandlesRegistered<TCandle>(ISubscriptionProvider, Security, object)
Whether the grouping of candles by the specified attribute is registered.
public static bool IsCandlesRegistered<TCandle>(this ISubscriptionProvider subscriptionProvider, Security security, object arg) where TCandle : ICandleMessage
Parameters
subscriptionProvider
ISubscriptionProviderThe subscription provider.
security
SecurityThe instrument for which the grouping is registered.
arg
objectCandle arg.
Returns
Type Parameters
TCandle
Candles type.
IsSame<TCandle>(TCandle, TCandle)
Determines the specified candles are same.
public static bool IsSame<TCandle>(this TCandle candle1, TCandle candle2) where TCandle : ICandleMessage
Parameters
candle1
TCandleFirst.
candle2
TCandleSecond.
Returns
- bool
Check result.
Type Parameters
TCandle
MaxPriceLevel(ICandleMessage)
PriceLevels with maximum TotalVolume.
public static CandlePriceLevel? MaxPriceLevel(this ICandleMessage candle)
Parameters
candle
ICandleMessage
Returns
- CandlePriceLevel?
PriceLevels with maximum TotalVolume.
MinPriceLevel(ICandleMessage)
PriceLevels with minimum TotalVolume.
public static CandlePriceLevel? MinPriceLevel(this ICandleMessage candle)
Parameters
candle
ICandleMessage
Returns
- CandlePriceLevel?
PriceLevels with minimum TotalVolume.
PoC(VolumeProfileBuilder)
POC (Point Of Control) returns CandlePriceLevel which had the maximum volume.
public static CandlePriceLevel PoC(this VolumeProfileBuilder volumeProfile)
Parameters
volumeProfile
VolumeProfileBuilderVolume profile.
Returns
- CandlePriceLevel
The CandlePriceLevel which had the maximum volume.
PriceLevelOfMaxDelta(VolumeProfileBuilder)
It returns the price level at which the maximum Delta(VolumeProfileBuilder) is passed.
public static CandlePriceLevel PriceLevelOfMaxDelta(this VolumeProfileBuilder volumeProfile)
Parameters
volumeProfile
VolumeProfileBuilderVolume profile.
Returns
PriceLevelOfMinDelta(VolumeProfileBuilder)
It returns the price level at which the minimum Delta(VolumeProfileBuilder) is passed.
public static CandlePriceLevel PriceLevelOfMinDelta(this VolumeProfileBuilder volumeProfile)
Parameters
volumeProfile
VolumeProfileBuilderVolume profile.
Returns
- CandlePriceLevel
The price level.
SellVolAbovePoC(VolumeProfileBuilder)
The total volume of asks which was above PoC(VolumeProfileBuilder).
public static decimal SellVolAbovePoC(this VolumeProfileBuilder volumeProfile)
Parameters
volumeProfile
VolumeProfileBuilderVolume profile.
Returns
- decimal
The total volume of asks.
SellVolBelowPoC(VolumeProfileBuilder)
The total volume of asks which was below PoC(VolumeProfileBuilder).
public static decimal SellVolBelowPoC(this VolumeProfileBuilder volumeProfile)
Parameters
volumeProfile
VolumeProfileBuilderVolume profile.
Returns
- decimal
The total volume of asks.
Start<TCandle>(ISubscriptionProvider, CandleSeries)
To start candles getting.
public static void Start<TCandle>(this ISubscriptionProvider subscriptionProvider, CandleSeries series) where TCandle : ICandleMessage
Parameters
subscriptionProvider
ISubscriptionProviderThe subscription provider.
series
CandleSeriesCandles series.
Type Parameters
TCandle
ToCandles(IEnumerable<MarketDepth>, CandleSeries, Level1Fields, CandleBuilderProvider)
To create candles from the order books collection.
[Obsolete("Use IOrderBookMessage.")]
public static IEnumerable<Candle> ToCandles(this IEnumerable<MarketDepth> depths, CandleSeries series, Level1Fields type = Level1Fields.SpreadMiddle, CandleBuilderProvider candleBuilderProvider = null)
Parameters
depths
IEnumerable<MarketDepth>Market depths.
series
CandleSeriesCandles series.
type
Level1FieldsType of candle depth based data.
candleBuilderProvider
CandleBuilderProviderCandle builders provider.
Returns
- IEnumerable<Candle>
Candles.
ToCandles(IEnumerable<Trade>, CandleSeries)
To create candles from the tick trades collection.
[Obsolete("Use ITickTradeMessage.")]
public static IEnumerable<Candle> ToCandles(this IEnumerable<Trade> trades, CandleSeries series)
Parameters
trades
IEnumerable<Trade>Tick trades.
series
CandleSeriesCandles series.
Returns
- IEnumerable<Candle>
Candles.
ToCandles(IEnumerable<ExecutionMessage>, CandleSeries, CandleBuilderProvider)
To create candles from the tick trades collection.
public static IEnumerable<CandleMessage> ToCandles(this IEnumerable<ExecutionMessage> trades, CandleSeries series, CandleBuilderProvider candleBuilderProvider = null)
Parameters
trades
IEnumerable<ExecutionMessage>Tick trades.
series
CandleSeriesCandles series.
candleBuilderProvider
CandleBuilderProviderCandle builders provider.
Returns
- IEnumerable<CandleMessage>
Candles.
ToCandles(IEnumerable<ExecutionMessage>, MarketDataMessage, CandleBuilderProvider)
To create candles from the tick trades collection.
public static IEnumerable<CandleMessage> ToCandles(this IEnumerable<ExecutionMessage> executions, MarketDataMessage mdMsg, CandleBuilderProvider candleBuilderProvider = null)
Parameters
executions
IEnumerable<ExecutionMessage>Tick data.
mdMsg
MarketDataMessageMarket data subscription.
candleBuilderProvider
CandleBuilderProviderCandle builders provider.
Returns
- IEnumerable<CandleMessage>
Candles.
ToCandles(IEnumerable<QuoteChangeMessage>, CandleSeries, Level1Fields, CandleBuilderProvider)
To create candles from the order books collection.
public static IEnumerable<CandleMessage> ToCandles(this IEnumerable<QuoteChangeMessage> depths, CandleSeries series, Level1Fields type = Level1Fields.SpreadMiddle, CandleBuilderProvider candleBuilderProvider = null)
Parameters
depths
IEnumerable<QuoteChangeMessage>Market depths.
series
CandleSeriesCandles series.
type
Level1FieldsType of candle depth based data.
candleBuilderProvider
CandleBuilderProviderCandle builders provider.
Returns
- IEnumerable<CandleMessage>
Candles.
ToCandles(IEnumerable<QuoteChangeMessage>, MarketDataMessage, Level1Fields, CandleBuilderProvider)
To create candles from the order books collection.
public static IEnumerable<CandleMessage> ToCandles(this IEnumerable<QuoteChangeMessage> depths, MarketDataMessage mdMsg, Level1Fields type = Level1Fields.SpreadMiddle, CandleBuilderProvider candleBuilderProvider = null)
Parameters
depths
IEnumerable<QuoteChangeMessage>Market depths.
mdMsg
MarketDataMessageMarket data subscription.
type
Level1FieldsType of candle depth based data.
candleBuilderProvider
CandleBuilderProviderCandle builders provider.
Returns
- IEnumerable<CandleMessage>
Candles.
ToCandles<TCandle>(IEnumerable<Trade>, object, bool)
To create candles from the tick trades collection.
[Obsolete("Use ITickTradeMessage.")]
public static IEnumerable<TCandle> ToCandles<TCandle>(this IEnumerable<Trade> trades, object arg, bool onlyFormed = true) where TCandle : Candle
Parameters
trades
IEnumerable<Trade>Tick trades.
arg
objectCandle arg.
onlyFormed
boolSend only formed candles.
Returns
- IEnumerable<TCandle>
Candles.
Type Parameters
TCandle
Candles type.
ToTickMessage((Sides? side, decimal price, decimal volume, DateTimeOffset time), SecurityId, DateTimeOffset)
Convert tick info into ExecutionMessage.
public static ExecutionMessage ToTickMessage(this (Sides? side, decimal price, decimal volume, DateTimeOffset time) tick, SecurityId securityId, DateTimeOffset localTime)
Parameters
tick
(Sides? side, decimal price, decimal volume, DateTimeOffset time)Tick info.
securityId
SecurityIdlocalTime
DateTimeOffset
Returns
ToTrades<TCandle>(IEnumerable<TCandle>, decimal)
To create tick trades from candles.
public static IEnumerable<ExecutionMessage> ToTrades<TCandle>(this IEnumerable<TCandle> candles, decimal volumeStep) where TCandle : ICandleMessage
Parameters
candles
IEnumerable<TCandle>Candles.
volumeStep
decimalVolume step.
Returns
- IEnumerable<ExecutionMessage>
Tick trades.
Type Parameters
TCandle
TotalBuyCount(VolumeProfileBuilder)
The total number of bids in the VolumeProfileBuilder.
public static decimal TotalBuyCount(this VolumeProfileBuilder volumeProfile)
Parameters
volumeProfile
VolumeProfileBuilderVolume profile.
Returns
- decimal
The total number of bids.
TotalBuyVolume(VolumeProfileBuilder)
The total volume of bids in the VolumeProfileBuilder.
public static decimal TotalBuyVolume(this VolumeProfileBuilder volumeProfile)
Parameters
volumeProfile
VolumeProfileBuilderVolume profile.
Returns
- decimal
The total volume of bids.
TotalSellCount(VolumeProfileBuilder)
The total number of asks in the VolumeProfileBuilder.
public static decimal TotalSellCount(this VolumeProfileBuilder volumeProfile)
Parameters
volumeProfile
VolumeProfileBuilderVolume profile.
Returns
- decimal
The total number of asks.
TotalSellVolume(VolumeProfileBuilder)
The total volume of asks in the VolumeProfileBuilder.
public static decimal TotalSellVolume(this VolumeProfileBuilder volumeProfile)
Parameters
volumeProfile
VolumeProfileBuilderVolume profile.
Returns
- decimal
The total volume of asks.
TryGetCandlesBuildFrom(IMessageAdapter, MarketDataMessage, CandleBuilderProvider)
Try get suitable market-data type for candles compression.
public static DataType TryGetCandlesBuildFrom(this IMessageAdapter adapter, MarketDataMessage subscription, CandleBuilderProvider provider)
Parameters
adapter
IMessageAdapterAdapter.
subscription
MarketDataMessageSubscription.
provider
CandleBuilderProviderCandle builders provider.
Returns
Update(VolumeProfileBuilder, ICandleBuilderValueTransform)
To update the profile with new value.
public static void Update(this VolumeProfileBuilder volumeProfile, ICandleBuilderValueTransform transform)
Parameters
volumeProfile
VolumeProfileBuilderVolume profile.
transform
ICandleBuilderValueTransformThe data source transformation.
VolumeAbovePoC(VolumeProfileBuilder)
The total volume which was above PoC(VolumeProfileBuilder).
public static decimal VolumeAbovePoC(this VolumeProfileBuilder volumeProfile)
Parameters
volumeProfile
VolumeProfileBuilderVolume profile.
Returns
- decimal
Total volume.
VolumeBelowPoC(VolumeProfileBuilder)
The total volume which was below PoC(VolumeProfileBuilder).
public static decimal VolumeBelowPoC(this VolumeProfileBuilder volumeProfile)
Parameters
volumeProfile
VolumeProfileBuilderVolume profile.
Returns
- decimal
Total volume.