예제 #1
0
        public void Clear()
        {
            _securityData.Clear();

            _allOrdersById.Clear();
            _allOrdersByStringId.Clear();
            _allOrdersByTransactionId.Clear();
            _orders.Clear();

            _newsById.Clear();
            _newsWithoutId.Clear();

            _myTrades.Clear();

            _trades.Clear();
            _tradeStat.Clear(true);

            _orderStatusTransactions.Clear();
            _massCancelationTransactions.Clear();

            _exchangeBoards.Clear();
            _securities.Clear();

            _orderCancelFails.Clear();
            _orderRegisterFails.Clear();

            _positions.Clear();
        }
예제 #2
0
            protected override void OnCleared()
            {
                base.OnCleared();

                _items.Clear();
                Write();
            }
예제 #3
0
 public void ClearCache()
 {
     _subscribers.Clear();
     //_continuousSecurities.Clear();
     _registeredFilteredMarketDepths.Clear();
     _registeredPortfolios.Clear();
 }
예제 #4
0
        /// <inheritdoc />
        public void Reset()
        {
            _realizedPnL = 0;
            _securityPnLs.Clear();

            _tradeByStringIdInfos.Clear();
            _tradeByIdInfos.Clear();
        }
예제 #5
0
 /// <summary>
 /// To zero <see cref="PnL"/>.
 /// </summary>
 public void Reset()
 {
     lock (_portfolioManagers.SyncRoot)
     {
         _realizedPnL = 0;
         _portfolioManagers.Clear();
     }
 }
예제 #6
0
        /// <summary>
        /// Clear cache.
        /// </summary>
        public override void ClearCache()
        {
            base.ClearCache();

            _series.Clear();
            _historySourceSubscriptions.Clear();
            _subscribedCandles.Clear();

            IsFinished = false;
        }
예제 #7
0
        /// <summary>
        /// Обнулить позицию.
        /// </summary>
        public virtual void Reset()
        {
            _positions.Clear();

            lock (_syncRoot)
            {
                _byOrderPositions.Clear();
                Position = 0;
            }
        }
        private void OnCandleKindsResponse(CandleKindsResponse response)
        {
            _candlePeriods.Clear();

            foreach (var kind in response.Kinds)
            {
                _candlePeriods.Add(kind.Id, TimeSpan.FromSeconds(kind.Period));
            }

            CandleTimeFramesInitialized.SafeInvoke();
        }
예제 #9
0
 /// <inheritdoc />
 public void Reset()
 {
     lock (_managersByPf.SyncRoot)
     {
         _realizedPnL = 0;
         _managersByPf.Clear();
         _managersByTransId.Clear();
         _managersByOrderId.Clear();
         _managersByOrderStringId.Clear();
     }
 }
예제 #10
0
 /// <inheritdoc />
 public void Reset()
 {
     lock (_managersByPf.SyncRoot)
     {
         _realizedPnL = 0;
         _managersByPf.Clear();
         _managersByTransId.Clear();
         _orderIds.Clear();
         _orderTransactions.Clear();
     }
 }
예제 #11
0
 /// <summary>
 /// Load security state from <paramref name="text"/>.
 /// </summary>
 /// <param name="text">Value, received from <see cref="ToSerializedString"/>.</param>
 public override void FromSerializedString(string text)
 {
     lock (_weights.SyncRoot)
     {
         _weights.Clear();
         _weights.AddRange(text.Split(",").Select(p =>
         {
             var parts = p.Split("=");
             return(new KeyValuePair <SecurityId, decimal>(parts[0].ToSecurityId(), parts[1].To <decimal>()));
         }));
     }
 }
예제 #12
0
        /// <summary>
        /// Освободить занятые ресурсы.
        /// </summary>
        protected override void DisposeManaged()
        {
            foreach (var source in _sources.Values)
            {
                source.Unsubscribe();
            }

            _sources.Clear();
            _indicatorUsages.Clear();

            base.DisposeManaged();
        }
예제 #13
0
        private void ProcessReset(Message message)
        {
            _hearbeatAdapters.Values.ForEach(a =>
            {
                a.SendInMessage(message);
                a.Dispose();
            });

            _connectedAdapters.Clear();
            _hearbeatAdapters.Clear();
            _subscriptionQueue.Clear();
            _subscriptions.Clear();
        }
예제 #14
0
 /// <summary>
 /// Clear state.
 /// </summary>
 public void Clear() => _holders.Clear();
예제 #15
0
 /// <summary>
 /// To zero <see cref="PortfolioPnLManager.PnL"/>.
 /// </summary>
 public void Reset()
 {
     _realizedPnL = 0;
     _securityPnLs.Clear();
 }
예제 #16
0
        /// <summary>
        /// Отправить сообщение.
        /// </summary>
        /// <param name="message">Сообщение.</param>
        protected override void OnSendInMessage(Message message)
        {
            switch (message.Type)
            {
            case MessageTypes.Reset:
                _hearbeatAdapters.Values.ForEach(a => a.SendInMessage(message));

                _connectedAdapters.Clear();
                _hearbeatAdapters.Clear();
                _subscriptionQueue.Clear();
                _subscriptions.Clear();
                break;

            case MessageTypes.Connect:
                _hearbeatAdapters.AddRange(GetSortedAdapters().ToDictionary(a => a, a =>
                {
                    var hearbeatAdapter            = (IMessageAdapter) new HeartbeatAdapter(a);
                    hearbeatAdapter.Parent         = this;
                    hearbeatAdapter.NewOutMessage += m => OnInnerAdapterNewMessage(a, m);
                    return(hearbeatAdapter);
                }));

                if (_hearbeatAdapters.Count == 0)
                {
                    throw new InvalidOperationException(LocalizedStrings.Str3650);
                }

                _hearbeatAdapters.Values.ForEach(a => a.SendInMessage(message));
                break;

            case MessageTypes.Disconnect:
                _connectedAdapters.CachedValues.ForEach(с => с.Cache.ForEach(a => a.SendInMessage(message)));
                break;

            case MessageTypes.Portfolio:
            {
                var pfMsg = (PortfolioMessage)message;
                ProcessPortfolioMessage(pfMsg.PortfolioName, pfMsg);
                break;
            }

            case MessageTypes.OrderRegister:
            case MessageTypes.OrderReplace:
            case MessageTypes.OrderCancel:
            case MessageTypes.OrderGroupCancel:
            {
                var ordMsg = (OrderMessage)message;
                ProcessPortfolioMessage(ordMsg.PortfolioName, ordMsg);
                break;
            }

            case MessageTypes.OrderPairReplace:
            {
                var ordMsg = (OrderPairReplaceMessage)message;
                ProcessPortfolioMessage(ordMsg.Message1.PortfolioName, ordMsg);
                break;
            }

            case MessageTypes.MarketData:
            {
                var adapters = _connectedAdapters.TryGetValue(message.Type);

                if (adapters == null)
                {
                    throw new InvalidOperationException(LocalizedStrings.Str629Params.Put(message.Type));
                }

                var mdMsg = (MarketDataMessage)message;

                switch (mdMsg.DataType)
                {
                case MarketDataTypes.News:
                    adapters.Cache.ForEach(a => a.SendInMessage(mdMsg));
                    break;

                default:
                {
                    var key = Tuple.Create(mdMsg.SecurityId, mdMsg.DataType);

                    if (mdMsg.IsSubscribe)
                    {
                        if (_subscriptionQueue.ContainsKey(key))
                        {
                            return;
                        }

                        var enumerator = adapters.Cache.Cast <IMessageAdapter>().GetEnumerator();

                        _subscriptionQueue.Add(key, enumerator);

                        ProcessSubscriptionAction(enumerator, mdMsg);
                    }
                    else
                    {
                        var adapter = _subscriptions.TryGetValue(key);

                        if (adapter != null)
                        {
                            _subscriptions.Remove(key);
                            adapter.SendInMessage(message);
                        }
                    }

                    break;
                }
                }

                break;
            }

            default:
            {
                var adapters = _connectedAdapters.TryGetValue(message.Type);

                if (adapters == null)
                {
                    throw new InvalidOperationException(LocalizedStrings.Str629Params.Put(message.Type));
                }

                adapters.Cache.ForEach(a => a.SendInMessage(message));
                break;
            }
            }
        }