コード例 #1
0
        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 = "All", SecurityType = position.bstrInstrument.ToSecurityType()
                    },
                    OriginalTransactionId = message.TransactionId,
                };

                SendOutMessage(m);

                var changeMsg = new PositionChangeMessage
                {
                    PortfolioName = position.bstrAcct,
                    SecurityId    = new SecurityId {
                        SecurityCode = position.bstrSym, BoardCode = "All", 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
            });
        }
コード例 #2
0
        private void SessionOnStiPositionUpdate(ref structSTIPositionUpdate msg)
        {
            var message = new PositionChangeMessage
            {
                PortfolioName = msg.bstrAcct,
                SecurityId    = new SecurityId {
                    SecurityCode = msg.bstrSym, BoardCode = "All"
                },
            };

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

            SendOutMessage(message);
        }
コード例 #3
0
		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 });
		}
コード例 #4
0
		private void SessionOnStiPositionUpdate(ref structSTIPositionUpdate msg)
		{
			var message = new PositionChangeMessage
			{
				PortfolioName = msg.bstrAcct,
				SecurityId = new SecurityId { SecurityCode = msg.bstrSym, BoardCode = AssociatedBoardCode },
			};

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

			SendOutMessage(message);
		}