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


C# DateTime.ApplyTimeZone方法代碼示例

本文整理匯總了C#中System.DateTime.ApplyTimeZone方法的典型用法代碼示例。如果您正苦於以下問題:C# DateTime.ApplyTimeZone方法的具體用法?C# DateTime.ApplyTimeZone怎麽用?C# DateTime.ApplyTimeZone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.DateTime的用法示例。


在下文中一共展示了DateTime.ApplyTimeZone方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: StrToTime

		public static DateTimeOffset StrToTime(this string str)
		{
			var parsedDate = new DateTime
			(
				DateTime.Now.Year,
				DateTime.Now.Month,
				DateTime.Now.Day,
				int.Parse(str.Substring(0, 2)),
				int.Parse(str.Substring(2, 2)),
				int.Parse(str.Substring(4, 2))
			);

			return parsedDate.ApplyTimeZone(TimeHelper.Est);
		}
開發者ID:jsonbao,項目名稱:StockSharp,代碼行數:14,代碼來源:Extensions.cs

示例2: IsTradeDate

		/// <summary>
		/// Проверить, является ли дата торгуемой.
		/// </summary>
		/// <param name="security">Инструмент.</param>
		/// <param name="date">Передаваемая дата, которую необходимо проверить.</param>
		/// <returns><see langword="true"/>, если торгуемая дата, иначе, неторгуемая.</returns>
		public static bool IsTradeDate(this HydraTaskSecurity security, DateTime date)
		{
			if (security == null)
				throw new ArgumentNullException(nameof(security));

			return security.Security.Board.IsTradeDate(date.ApplyTimeZone(security.Security.Board.TimeZone), true);
		}
開發者ID:vikewoods,項目名稱:StockSharp,代碼行數:13,代碼來源:Extensions.cs

示例3: StrToDateTime

		public static DateTimeOffset StrToDateTime(this string str)
		{
			var parsedDate = new DateTime
			(
				int.Parse(str.Substring(0, 4)),
				int.Parse(str.Substring(4, 2)),
				int.Parse(str.Substring(6, 2)),
				int.Parse(str.Substring(8, 2)),
				int.Parse(str.Substring(10, 2)),
				int.Parse(str.Substring(12, 2))
			);

			return parsedDate.ApplyTimeZone(TimeHelper.Est);
		}
開發者ID:jsonbao,項目名稱:StockSharp,代碼行數:14,代碼來源:Extensions.cs

示例4: OnNewBar

		private void OnNewBar(int row, int rowCount, string smartId, SmartComTimeFrames timeFrame, DateTime time, decimal open, decimal high, decimal low, decimal close, decimal volume, decimal openInt)
		{
			this.AddDebugLog("OnNewHistoryTrade row = {0} rowCount = {1} securityId = {2} timeFrame = {3} time = {4} open = {5} high = {6} low = {7} close = {8} volume = {9} openInt = {10}",
				row, rowCount, smartId, timeFrame, time, open, high, low, close, volume, openInt);

			var infos = _candleTransactions.TryGetValue(smartId);
			var timeFrameKey = (TimeSpan)timeFrame;

			Tuple<long, List<CandleMessage>> transactionInfo;
			if (infos == null || !infos.TryGetValue(timeFrameKey, out transactionInfo))
			{
				this.AddErrorLog(LocalizedStrings.Str1855Params, smartId, timeFrame);
				return;
			}

			transactionInfo.Item2.Add(new TimeFrameCandleMessage
			{
				SecurityId = new SecurityId { Native = smartId },
				OpenPrice = open,
				HighPrice = high,
				LowPrice = low,
				ClosePrice = close,
				TotalVolume = volume,
				OpenTime = time.ApplyTimeZone(TimeHelper.Moscow) - (TimeSpan)timeFrame,
				CloseTime = time.ApplyTimeZone(TimeHelper.Moscow),
				OpenInterest = openInt,
				OriginalTransactionId = transactionInfo.Item1,
				IsFinished = row == (rowCount - 1),
			});

			if ((row + 1) < rowCount)
				return;

			transactionInfo.Item2.OrderBy(c => c.OpenTime).ForEach(SendOutMessage);

			infos.Remove(timeFrameKey);

			if (infos.IsEmpty())
				_candleTransactions.Remove(smartId);
		}
開發者ID:reddream,項目名稱:StockSharp,代碼行數:40,代碼來源:SmartComMessageAdapter_MarketData.cs

示例5: CreateTrade

		private static ExecutionMessage CreateTrade(string smartId, DateTime time, decimal price, decimal volume, long tradeId, SmartOrderAction action)
		{
			return new ExecutionMessage
			{
				SecurityId = new SecurityId { Native = smartId },
				TradeId = tradeId,
				TradePrice = price,
				Volume = volume,
				OriginSide = action.ToSide(),
				ServerTime = time.ApplyTimeZone(TimeHelper.Moscow),
				ExecutionType = ExecutionTypes.Tick,
			};
		}
開發者ID:reddream,項目名稱:StockSharp,代碼行數:13,代碼來源:SmartComMessageAdapter_MarketData.cs

示例6: OnOrderChanged

		private void OnOrderChanged(string portfolioName, string secSmartId, SmartOrderState state, SmartOrderAction action, SmartOrderType smartType, bool isOneDay,
			decimal? price, int volume, decimal? stop, int balance, DateTime time, string smartOrderId, long orderId, int status, int transactionId)
		{
			this.AddInfoLog(() => "SmartTrader.UpdateOrder: id {0} smartId {1} type {2} direction {3} price {4} volume {5} balance {6} time {7} security {8} state {9}"
				.Put(orderId, smartOrderId, smartType, action, price, volume, balance, time, secSmartId, state));

			var side = action.ToSide();

			if (side == null)
				throw new InvalidOperationException(LocalizedStrings.Str1872Params.Put(action, orderId, transactionId));

			// http://stocksharp.com/forum/yaf_postsm28324_Oshibka-pri-vystavlienii-ili-sniatii-zaiavki.aspx#post28324
			if (transactionId == 0)
				return;

			if (state.IsReject())
			{
				// заявка была ранее зарегистрирована через SmartTrader
				//if (_smartIdOrders.ContainsKey(smartOrderId))
				//{
				// замечены SystemCancel приходящие в процессе Move после которых приходит Active
				if (state != SmartOrderState.SystemCancel)
				{
					//var trId = GetTransactionBySmartId(smartOrderId);

					SendOutMessage(new ExecutionMessage
					{
						ExecutionType = ExecutionTypes.Order,
						OriginalTransactionId = transactionId,
						OrderStringId = smartOrderId,
						ServerTime = time.ApplyTimeZone(TimeHelper.Moscow),
						OrderState = OrderStates.Failed,
						Error = new InvalidOperationException(LocalizedStrings.Str1873Params.Put(transactionId)),
					});
				}
				//}

				return;
			}

			var orderType = smartType.ToOrderType();

			var orderState = OrderStates.Active;
			var orderStatus = OrderStatus.Accepted;

			switch (state)
			{
				case SmartOrderState.ContragentReject:
					orderStatus = OrderStatus.NotAcceptedByManager;
					orderState = OrderStates.Failed;
					break;
				// Принята ТС
				case SmartOrderState.Submited:
					orderStatus = OrderStatus.SentToServer;
					break;
				// Зарегистрирована в ТС
				case SmartOrderState.Pending:
					orderStatus = OrderStatus.ReceiveByServer;

					if (orderType == OrderTypes.Conditional)
						orderState = OrderStates.Active;

					break;
				// Выведена на рынок
				case SmartOrderState.Open:
					orderStatus = OrderStatus.Accepted;

					if (orderType == OrderTypes.Conditional && orderId != 0)
						orderState = OrderStates.Done;
					else
						orderState = OrderStates.Active;
					break;
				// Снята по окончанию торгового дня
				case SmartOrderState.Expired:
					orderState = OrderStates.Done;
					break;
				// Отменёна
				case SmartOrderState.Cancel:
					orderState = OrderStates.Done;
					break;
				// Исполнена
				case SmartOrderState.Filled:
					orderState = OrderStates.Done;
					break;
				// Частично исполнена
				case SmartOrderState.Partial:
					if (orderState == OrderStates.None)
						orderState = OrderStates.Active;
					break;
				// Отклонена биржей
				case SmartOrderState.ContragentCancel:
					orderStatus = OrderStatus.CanceledByManager;
					orderState = OrderStates.Failed;
					break;
				// Отклонена биржей
				case SmartOrderState.SystemReject:
					orderStatus = OrderStatus.NotDone;
					orderState = OrderStates.Failed;
					break;
				// Отклонена биржей
//.........這裏部分代碼省略.........
開發者ID:zjxbetter,項目名稱:StockSharp,代碼行數:101,代碼來源:SmartComMessageAdapter_Transaction.cs

示例7: OnNewMyTrade

		private void OnNewMyTrade(string portfolio, string smartId, long orderId, decimal? price, decimal? volume, DateTime time, long tradeId)
		{
			this.AddInfoLog("SmartTrader.AddTrade: tradeId {0} orderId {1} price {2} volume {3} time {4} security {5}",
				tradeId, orderId, price, volume, time, smartId);

			SendOutMessage(new ExecutionMessage
			{
				ExecutionType = ExecutionTypes.Trade,
				SecurityId = new SecurityId { Native = smartId },
				OrderId = orderId == 0 ? (long?)null : orderId,
				TradeId = tradeId,
				ServerTime = time.ApplyTimeZone(TimeHelper.Moscow),
				Volume = volume,
				TradePrice = price,
			});
		}
開發者ID:zjxbetter,項目名稱:StockSharp,代碼行數:16,代碼來源:SmartComMessageAdapter_Transaction.cs


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