当前位置: 首页>>代码示例>>C#>>正文


C# Transaction.SetSide方法代码示例

本文整理汇总了C#中Transaction.SetSide方法的典型用法代码示例。如果您正苦于以下问题:C# Transaction.SetSide方法的具体用法?C# Transaction.SetSide怎么用?C# Transaction.SetSide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Transaction的用法示例。


在下文中一共展示了Transaction.SetSide方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateRegisterTransaction

		public static Transaction CreateRegisterTransaction(this OrderRegisterMessage message, string orderAccount, IDictionary<string, RefPair<SecurityTypes, string>> securityClassInfo, bool singleSlash)
		{
			if (securityClassInfo == null)
				throw new ArgumentNullException(nameof(securityClassInfo));

			if (message == null)
				throw new ArgumentNullException(nameof(message));

			var board = ExchangeBoard.GetOrCreateBoard(message.SecurityId.BoardCode);
			var needDepoAccount = board.IsMicex || board.IsUxStock;

			if (needDepoAccount)
			{
				if (orderAccount.IsEmpty())
					throw new ArgumentException(LocalizedStrings.Str1848Params.Put(message.PortfolioName));
			}
			else
				orderAccount = message.PortfolioName;

			var transaction = new Transaction(TransactionTypes.Register, message);

			transaction
				.SetAccount(orderAccount)
				.SetSecurity(message, securityClassInfo)
				.SetVolume((int)message.Volume);

			//20-ти символьное составное поле, может содержать код клиента и текстовый комментарий с тем же разделителем, что и при вводе заявки вручную.
			//для ртс код клиента не обязателен
			var clientCode = needDepoAccount ? message.PortfolioName : string.Empty;
			if (!message.Comment.IsEmpty())
			{
				// http://www.quik.ru/forum/import/24383
				//var splitter = message.PortfolioName.Contains("/") ? "//" : "/";

				// https://forum.quik.ru/forum10/topic1218/
				var splitter = singleSlash ? "/" : "//";

				clientCode = clientCode.IsEmpty() ? message.Comment : "{0}{1}{2}".Put(clientCode, splitter, message.Comment);

				if (clientCode.Length > 20)
					clientCode = clientCode.Remove(20);
			}

			if (!clientCode.IsEmpty())
				transaction.SetClientCode(clientCode);

			transaction.SetExpiryDate(message.TillDate);

			if (message.VisibleVolume != null && message.VisibleVolume != message.Volume)
			{
				return transaction
						.SetAction(TransactionActions.Iceberg)
						.SetVisibleVolume((int)message.VisibleVolume)

						.SetInstruction("Цена", transaction.GetInstruction(Transaction.Price))
						.SetInstruction("К/П", message.Side == Sides.Buy ? "Купля" : "Продажа")
						.SetInstruction("Тип", "Лимитная")
						.SetInstruction("Тип по цене", "по разным ценам")
						.SetInstruction("Тип по остатку", "поставить в очередь")
						.SetInstruction("Тип ввода значения цены", "По цене")

						.SetInstruction("Торговый счет", transaction.GetInstruction(Transaction.Account))
						.RemoveInstruction(Transaction.Account)

						.SetInstruction("Инструмент", transaction.GetInstruction(Transaction.SecurityCode))
						.RemoveInstruction(Transaction.SecurityCode)

						.SetInstruction("Лоты", transaction.GetInstruction(Transaction.Volume))
						.RemoveInstruction(Transaction.Volume)

						.SetInstruction("Примечание", transaction.GetInstruction(Transaction.ClientCode))
						.RemoveInstruction(Transaction.ClientCode);
			}

			switch (message.OrderType)
			{
				case OrderTypes.Market:
				case OrderTypes.Limit:
					transaction
						.SetSide(message.Side)
						.SetType(message.OrderType.Value)
						.SetAction(TransactionActions.NewOrder)
						.SetPrice(message.Price);

					var tif = message.TimeInForce ?? TimeInForce.PutInQueue;

					if (!(message.SecurityId.SecurityType == SecurityTypes.Future && tif == TimeInForce.PutInQueue))
						transaction.SetTimeInForce(tif);

					break;
				case OrderTypes.Conditional:
				{
					var condition = (QuikOrderCondition)message.Condition;

					if (condition.ConditionOrderId != null && condition.ConditionOrderSide != null)
						message.Side = condition.ConditionOrderSide.Value.Invert();

					transaction
						.SetSide(message.Side)
						.SetAction(TransactionActions.NewStopOrder)
//.........这里部分代码省略.........
开发者ID:RakotVT,项目名称:StockSharp,代码行数:101,代码来源:TransactionHelper.cs

示例2: CreateCancelFuturesTransaction

		public static Transaction CreateCancelFuturesTransaction(this OrderGroupCancelMessage message, IDictionary<string, RefPair<SecurityTypes, string>> securityClassInfo)
		{
			if (message == null) 
				throw new ArgumentNullException(nameof(message));

			if (message.PortfolioName.IsEmpty())
				throw new ArgumentException("message");

			if (message.SecurityId.SecurityCode.IsEmpty())
				throw new ArgumentException("message");

			var underlyingSecurityCode = message.GetValue<string>("UnderlyingSecurityCode");

			if (underlyingSecurityCode.IsEmpty())
				throw new ArgumentException(LocalizedStrings.Str1850, nameof(message));

			var secType = message.SecurityId.SecurityType;

			if (secType != SecurityTypes.Future)
				throw new ArgumentException(LocalizedStrings.Str1851Params.Put(secType), nameof(message));

			var transaction = new Transaction(TransactionTypes.CancelGroup, message);

			transaction
				.SetAccount(message.PortfolioName)
				.SetBaseContract(underlyingSecurityCode)
				.SetAction(TransactionActions.KillAllFuturesOrders)
				.SetClassCode(securityClassInfo.GetSecurityClass(message.SecurityId));

			if (message.Side != null)
				transaction.SetSide(message.Side.Value);

			return transaction;
		}
开发者ID:RakotVT,项目名称:StockSharp,代码行数:34,代码来源:TransactionHelper.cs


注:本文中的Transaction.SetSide方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。