Exemple #1
0
        /// <summary>
        /// Create a copy of <see cref="PositionMessage"/>.
        /// </summary>
        /// <returns>Copy.</returns>
        public override Message Clone()
        {
            var clone = new PositionMessage
            {
                PortfolioName         = PortfolioName,
                SecurityId            = SecurityId,
                OriginalTransactionId = OriginalTransactionId,
                DepoName    = DepoName,
                LimitType   = LimitType,
                LocalTime   = LocalTime,
                Description = Description
            };

            this.CopyExtensionInfo(clone);

            return(clone);
        }
		private void ProcessPortfolioLookupMessage(PortfolioLookupMessage message)
		{
			var portfolios = _client.GetPortfolios();

			foreach (var portfolio in portfolios)
			{
				SendOutMessage(new PortfolioMessage
				{
					PortfolioName = portfolio.bstrAcct,
					State = PortfolioStates.Active, // ???
					OriginalTransactionId = message.TransactionId,
				});
			}

			var pos = _client.GetPositions();

			foreach (var position in pos)
			{
				var m = new PositionMessage
				{
					PortfolioName = position.bstrAcct,
					SecurityId = new SecurityId { SecurityCode = position.bstrSym, BoardCode = AssociatedBoardCode, SecurityType = position.bstrInstrument.ToSecurityType() },
					OriginalTransactionId = message.TransactionId,
				};

				SendOutMessage(m);

				var changeMsg = new PositionChangeMessage
				{
					PortfolioName = position.bstrAcct,
					SecurityId = new SecurityId { SecurityCode = position.bstrSym, BoardCode = AssociatedBoardCode, SecurityType = position.bstrInstrument.ToSecurityType() },
					ServerTime = CurrentTime
				};

				changeMsg.TryAdd(PositionChangeTypes.RealizedPnL, (decimal)position.fReal);
				changeMsg.TryAdd(PositionChangeTypes.BeginValue, (decimal)position.nOpeningPosition);
				changeMsg.TryAdd(PositionChangeTypes.CurrentValue, (decimal)(position.nOpeningPosition + (position.nSharesBot - position.nSharesSld)));
				changeMsg.TryAdd(PositionChangeTypes.Commission, (decimal)position.fPositionCost);

				SendOutMessage(message);
			}

			SendOutMessage(new PortfolioLookupResultMessage { OriginalTransactionId = message.TransactionId });
		}
Exemple #3
0
		/// <summary>
		/// Create a copy of <see cref="PositionMessage"/>.
		/// </summary>
		/// <returns>Copy.</returns>
		public override Message Clone()
		{
			var clone = new PositionMessage
			{
				PortfolioName = PortfolioName,
				SecurityId = SecurityId,
				OriginalTransactionId = OriginalTransactionId,
				DepoName = DepoName,
				LimitType = LimitType,
				LocalTime = LocalTime,
				Description = Description
			};

			this.CopyExtensionInfo(clone);

			return clone;
		}