Beispiel #1
0
            public Subscription ProcessResponse(PortfolioMessage response)
            {
                var originId = response.OriginalTransactionId;

                Subscription subscription;

                lock (_syncObject)
                {
                    if (response.Error != null)
                    {
                        subscription = TryGetSubscription(originId, true);

                        if (subscription != null)
                        {
                            ChangeState(subscription, SubscriptionStates.Error);
                        }
                    }
                    else
                    {
                        if (originId == 0)
                        {
                            return(null);
                        }

                        subscription = TryGetSubscription(originId, false);

                        if (subscription?.Portfolio != null && subscription.State != SubscriptionStates.Active)
                        {
                            ChangeState(subscription, SubscriptionStates.Active);
                        }
                    }
                }

                return(subscription);
            }
		private void ProcessPortfolioMessage(PortfolioMessage message)
		{
			GetPortfolio(message.PortfolioName, p =>
			{
				message.ToPortfolio(p);
				return true;
			});
		}
Beispiel #3
0
		private void ProcessPortfolioMessage(PortfolioMessage message)
		{
			GetPortfolio(message.PortfolioName, p =>
			{
				message.ToPortfolio(p, _entityCache.ExchangeInfoProvider);
				return true;
			});
		}
Beispiel #4
0
 private void ProcessPortfolioMessage(PortfolioMessage pfMsg)
 {
     if (pfMsg.IsSubscribe)
     {
         _wrapper.SubscribePortfolio(pfMsg.PortfolioName);
     }
     else
     {
         _wrapper.UnSubscribePortfolio(pfMsg.PortfolioName);
     }
 }
 private void ProcessPortfolioMessage(PortfolioMessage pfMsg)
 {
     if (pfMsg.IsSubscribe)
     {
         Session.SubscribePortfolio(pfMsg.PortfolioName);
     }
     else
     {
         Session.UnSubscribePortfolio(pfMsg.PortfolioName);
     }
 }
        private void ProcessInPortfolioMessage(PortfolioMessage message)
        {
            var sendIn = false;
            var pfName = message.PortfolioName;

            SubscriptionInfo <PortfolioMessage> info;

            lock (_sync)
            {
                PortfolioMessage clone = null;
                info = _pfSubscribers.TryGetValue(pfName) ?? new SubscriptionInfo <PortfolioMessage>(clone = (PortfolioMessage)message.Clone());

                var subscribersCount = info.Subscribers;

                if (message.IsSubscribe)
                {
                    subscribersCount++;
                    sendIn = subscribersCount == 1;
                }
                else
                {
                    if (subscribersCount > 0)
                    {
                        subscribersCount--;
                        sendIn = subscribersCount == 0;
                    }
                    //else
                    //	sendOutMsg = NonExist(message);
                }

                info.Subscriptions.Add(clone ?? (PortfolioMessage)message.Clone());

                if (subscribersCount > 0)
                {
                    info.Subscribers       = subscribersCount;
                    _pfSubscribers[pfName] = info;
                }
                else
                {
                    _pfSubscribers.Remove(pfName);
                }
            }

            if (sendIn)
            {
                if (!message.IsSubscribe && message.OriginalTransactionId == 0)
                {
                    message.OriginalTransactionId = info.Message.TransactionId;
                }

                base.SendInMessage(message);
            }
        }
Beispiel #7
0
        private void ProcessPortfolioMessage(PortfolioMessage message)
        {
            var accountId = GetAccountId(message.PortfolioName);

            if (message.IsSubscribe)
            {
                _streamigClient.SubscribeEventsStreaming(accountId);
            }
            else
            {
                _streamigClient.UnSubscribeEventsStreaming(accountId);
            }
        }
Beispiel #8
0
        private void ProcessInPortfolioMessage(PortfolioMessage message)
        {
            var sendIn = false;
            var pfName = message.PortfolioName;

            RefPair <PortfolioMessage, int> pair;

            lock (_sync)
            {
                pair = _pfSubscribers.TryGetValue(pfName) ?? RefTuple.Create((PortfolioMessage)message.Clone(), 0);

                var subscribersCount = pair.Second;

                if (message.IsSubscribe)
                {
                    subscribersCount++;
                    sendIn = subscribersCount == 1;
                }
                else
                {
                    if (subscribersCount > 0)
                    {
                        subscribersCount--;
                        sendIn = subscribersCount == 0;
                    }
                    //else
                    //	sendOutMsg = NonExist(message);
                }

                if (subscribersCount > 0)
                {
                    pair.Second            = subscribersCount;
                    _pfSubscribers[pfName] = pair;
                }
                else
                {
                    _pfSubscribers.Remove(pfName);
                }
            }

            if (sendIn)
            {
                if (!message.IsSubscribe && message.OriginalTransactionId == 0)
                {
                    message.OriginalTransactionId = pair.First.TransactionId;
                }

                base.SendInMessage(message);
            }
        }
Beispiel #9
0
            public void UnSubscribe(Subscription subscription)
            {
                if (subscription == null)
                {
                    throw new ArgumentNullException(nameof(subscription));
                }

                ISubscriptionMessage unsubscribe;

                if (subscription.DataType.IsMarketData)
                {
                    unsubscribe = new MarketDataMessage();
                }
                else if (subscription.DataType == DataType.Transactions)
                {
                    unsubscribe = new OrderStatusMessage();
                }
                else if (subscription.DataType == DataType.PositionChanges)
                {
                    unsubscribe = new PortfolioLookupMessage();
                }
                else if (subscription.DataType.IsPortfolio)
                {
                    unsubscribe = new PortfolioMessage();
                }
                else
                {
                    throw new ArgumentOutOfRangeException(nameof(subscription), subscription.DataType, LocalizedStrings.Str1219);
                }

                //// "immediate" unsubscribe
                //if (unsubscribe == null)
                //{
                //	lock (_syncObject)
                //	{
                //		_subscriptions.Remove(subscription.TransactionId);
                //	}

                //	return;
                //}

                unsubscribe.TransactionId         = _connector.TransactionIdGenerator.GetNextId();
                unsubscribe.OriginalTransactionId = subscription.TransactionId;
                unsubscribe.IsSubscribe           = false;

                SendRequest(unsubscribe, subscription);
            }
Beispiel #10
0
        private void ProcessPortfolioMessage(PortfolioMessage pfMsg)
        {
            var account = _accounts[pfMsg.PortfolioName];

            if (pfMsg.IsSubscribe)
            {
                _client.Session.replayPnl(account, pfMsg.TransactionId);
                _client.Session.replayOpenOrders(account, pfMsg.TransactionId);
                _client.Session.replayExecutions(account, 0, 0, pfMsg.TransactionId);

                _client.Session.subscribeOrder(account);
                _client.Session.subscribePnl(account);
            }
            else
            {
                _client.Session.unsubscribeOrder(account);
                _client.Session.unsubscribePnl(account);
            }
        }
 private void ProcessInPortfolioMessage(PortfolioMessage message)
 {
     ProcessInSubscriptionMessage(message, DataType.Portfolio(message.PortfolioName));
 }
Beispiel #12
0
 private void RefreshCollection(PortfolioMessage obj)
 {
     //_portfolio = _portfolioManagementService.GetPortfolio();
 }
 private void ProcessInPortfolioMessage(PortfolioMessage message)
 {
     ProcessInSubscriptionMessage(message, message.PortfolioName, _pfSubscribers, null, null, null);
 }