本文整理汇总了C#中StockSharp.Algo.Candles.Candle.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Candle.GetType方法的具体用法?C# Candle.GetType怎么用?C# Candle.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StockSharp.Algo.Candles.Candle
的用法示例。
在下文中一共展示了Candle.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateFilledCandle
private Candle CreateFilledCandle(Candle candle)
{
if (candle == null)
throw new ArgumentNullException(nameof(candle));
var filledCandle = candle.GetType().CreateInstance<Candle>();
//filledCandle.Series = candle.Series;
filledCandle.Security = candle.Security;
filledCandle.Arg = CloneArg(candle.Arg, candle.Security);
filledCandle.OpenTime = candle.OpenTime;
filledCandle.CloseTime = candle.CloseTime;
//filledCandle.TotalVolume = candle.TotalVolume;
//filledCandle.TotalPrice = candle.TotalPrice;
filledCandle.OpenPrice = candle.ClosePrice;
//filledCandle.OpenVolume = candle.CloseVolume;
filledCandle.ClosePrice = candle.ClosePrice;
//filledCandle.CloseVolume = candle.CloseVolume;
filledCandle.HighPrice = candle.ClosePrice;
//filledCandle.HighVolume = candle.CloseVolume;
filledCandle.LowPrice = candle.ClosePrice;
//filledCandle.LowVolume = candle.CloseVolume;
filledCandle.State = CandleStates.Finished;
return filledCandle;
}
示例2: ProcessCandle
public IEnumerable<Candle> ProcessCandle(Candle candle)
{
return GetFormedBuffers(candle)
.Select(buffer =>
{
var openPrice = TryCalculate(buffer, c => c.OpenPrice);
if (openPrice == null)
return null;
var indexCandle = candle.GetType().CreateInstance<Candle>();
indexCandle.Security = _security;
indexCandle.Arg = CloneArg(candle.Arg, _security);
indexCandle.OpenTime = buffer.OpenTime;
indexCandle.CloseTime = buffer.CloseTime;
indexCandle.TotalVolume = Calculate(buffer, c => c.TotalVolume);
indexCandle.TotalPrice = Calculate(buffer, c => c.TotalPrice);
indexCandle.OpenPrice = (decimal)openPrice;
indexCandle.OpenVolume = Calculate(buffer, c => c.OpenVolume ?? 0);
indexCandle.ClosePrice = Calculate(buffer, c => c.ClosePrice);
indexCandle.CloseVolume = Calculate(buffer, c => c.CloseVolume ?? 0);
indexCandle.HighPrice = Calculate(buffer, c => c.HighPrice);
indexCandle.HighVolume = Calculate(buffer, c => c.HighVolume ?? 0);
indexCandle.LowPrice = Calculate(buffer, c => c.LowPrice);
indexCandle.LowVolume = Calculate(buffer, c => c.LowVolume ?? 0);
// если некоторые свечи имеют неполные данные, то и индекс будет таким же неполным
if (indexCandle.OpenPrice == 0 || indexCandle.HighPrice == 0 || indexCandle.LowPrice == 0 || indexCandle.ClosePrice == 0)
{
var nonZeroPrice = indexCandle.OpenPrice;
if (nonZeroPrice == 0)
nonZeroPrice = indexCandle.HighPrice;
if (nonZeroPrice == 0)
nonZeroPrice = indexCandle.LowPrice;
if (nonZeroPrice == 0)
nonZeroPrice = indexCandle.LowPrice;
if (nonZeroPrice != 0)
{
if (indexCandle.OpenPrice == 0)
indexCandle.OpenPrice = nonZeroPrice;
if (indexCandle.HighPrice == 0)
indexCandle.HighPrice = nonZeroPrice;
if (indexCandle.LowPrice == 0)
indexCandle.LowPrice = nonZeroPrice;
if (indexCandle.ClosePrice == 0)
indexCandle.ClosePrice = nonZeroPrice;
}
}
if (indexCandle.HighPrice < indexCandle.LowPrice)
{
var high = indexCandle.HighPrice;
indexCandle.HighPrice = indexCandle.LowPrice;
indexCandle.LowPrice = high;
}
if (indexCandle.OpenPrice > indexCandle.HighPrice)
indexCandle.HighPrice = indexCandle.OpenPrice;
else if (indexCandle.OpenPrice < indexCandle.LowPrice)
indexCandle.LowPrice = indexCandle.OpenPrice;
if (indexCandle.ClosePrice > indexCandle.HighPrice)
indexCandle.HighPrice = indexCandle.ClosePrice;
else if (indexCandle.ClosePrice < indexCandle.LowPrice)
indexCandle.LowPrice = indexCandle.ClosePrice;
indexCandle.State = CandleStates.Finished;
return indexCandle;
})
.Where(c => c != null);
}