當前位置: 首頁>>代碼示例>>C#>>正文


C# Candle.GetType方法代碼示例

本文整理匯總了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;
			}
開發者ID:vikewoods,項目名稱:StockSharp,代碼行數:28,代碼來源:IndexSeriesBuilder.cs

示例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);
		}
開發者ID:vikewoods,項目名稱:StockSharp,代碼行數:82,代碼來源:IndexSeriesBuilder.cs


注:本文中的StockSharp.Algo.Candles.Candle.GetType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。