Beispiel #1
0
        public void AddExistsIdNameElementTest_HasArgumentOutOfRangeException()
        {
            var dic = new SynchronizedDictionary<int, string, string>();

            dic.Add(1, "Иванов", "value_1");
            dic.Add(1, "Иванов", "value_2");
        }
Beispiel #2
0
        public void AddCurrentElements_Success()
        {
            var dic = new SynchronizedDictionary<int, string, string>();

            dic.Add(1, "Иванов", "value_1");
            dic.Add(2, "Иванов", "value_2");
            dic.Add(5, "Иванов", "value_3");
            dic.Add(5, "Петров", "value_4");

            Assert.AreEqual(4, dic.Count);
        }
Beispiel #3
0
        /// <summary>
        /// Запустить или остановить сканер инструментов на основе заданных параметров.
        /// Результаты будут приходить через событие <see cref="IBTrader.NewScannerResults"/>.
        /// </summary>
        /// <param name="filter">Фильтр.</param>
        /// <param name="isSubscribe"><see langword="true"/> если необходимо подписаться, иначе <see langword="false"/>.</param>
        public void SubscribeScanner(ScannerFilter filter, bool isSubscribe)
        {
            var transactionId = TransactionIdGenerator.GetNextId();

            _states.Add(transactionId, filter);

            MarketDataAdapter.SendInMessage(new ScannerMarketDataMessage(filter)
            {
                TransactionId = transactionId,
                IsSubscribe   = isSubscribe
            });
        }
Beispiel #4
0
        public void GetByIdElements_Success()
        {
            var dic = new SynchronizedDictionary<int, string, string>();

            dic.Add(1, "Иванов", "value_1");
            dic.Add(2, "Иванов", "value_2");
            dic.Add(5, "Иванов", "value_3");
            dic.Add(5, "Петров", "value_4");

            var elementsById = dic.GetById(5);

            Assert.AreEqual(2, elementsById.Count);
        }
Beispiel #5
0
        private MarketDataMessage ProcessMarketDataRequest(MarketDataMessage message)
        {
            if (message.IsSubscribe)
            {
                if (message.SecurityId == default || !InnerAdapter.IsMarketDataTypeSupported(DataType.OrderLog))
                {
                    return(message);
                }

                var isBuild = message.BuildMode == MarketDataBuildModes.Build && message.BuildFrom == DataType.OrderLog;

                if (message.DataType2 == DataType.MarketDepth)
                {
                    if (isBuild || !InnerAdapter.IsMarketDataTypeSupported(message.DataType2))
                    {
                        var builder = message.DepthBuilder ?? InnerAdapter.CreateOrderLogMarketDepthBuilder(message.SecurityId);

                        _subscriptionIds.Add(message.TransactionId, new SubscriptionInfo(message.TypedClone())
                        {
                            Builder = builder
                        });

                        message           = message.TypedClone();
                        message.DataType2 = DataType.OrderLog;

                        this.AddInfoLog("OL->MD subscribed {0}/{1}.", message.SecurityId, message.TransactionId);
                    }
                }
                else if (message.DataType2 == DataType.Ticks)
                {
                    if (isBuild || !InnerAdapter.IsMarketDataTypeSupported(message.DataType2))
                    {
                        _subscriptionIds.Add(message.TransactionId, new SubscriptionInfo(message.TypedClone()));

                        message           = message.TypedClone();
                        message.DataType2 = DataType.OrderLog;

                        this.AddInfoLog("OL->TICK subscribed {0}/{1}.", message.SecurityId, message.TransactionId);
                    }
                }
            }
            else
            {
                TryRemoveSubscription(message.OriginalTransactionId, out _);
            }

            return(message);
        }
            public void ProcessRequest(Security security, MarketDataMessage message, bool tryAdd)
            {
                if (security == null)
                {
                    throw new ArgumentNullException(nameof(security));
                }

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

                if (message.TransactionId == 0)
                {
                    message.TransactionId = _connector.TransactionIdGenerator.GetNextId();
                }

                message.FillSecurityInfo(_connector, security);

                var value = Tuple.Create((MarketDataMessage)message.Clone(), security);

                if (tryAdd)
                {
                    // if the message was looped back via IsBack=true
                    _pendingSubscriptions.TryAdd(message.TransactionId, value);
                }
                else
                {
                    _pendingSubscriptions.Add(message.TransactionId, value);
                }

                _connector.SendInMessage(message);
            }
        /// <summary>
        /// Parses the XML of the configuration section.
        /// </summary>
        /// <param name="parent">The configuration settings in a corresponding parent configuration section.</param>
        /// <param name="configContext">An HttpConfigurationContext when Create is called from the ASP.NET configuration system. Otherwise, this parameter is reserved and is a null reference.</param>
        /// <param name="section">The XmlNode that contains the configuration information from the configuration file. Provides direct access to the XML contents of the configuration section.</param>
        /// <returns>A configuration object.</returns>
        public object Create(object parent, object configContext, System.Xml.XmlNode section)
        {
            if (section == null)
            {
                throw new ConfigurationErrorsException("The sourceForge/objectFactory section has not been defined.");
            }

            objectDefinitions = new SynchronizedDictionary<string, ObjectDefinition>();

            if (section.HasChildNodes)
            {
                // Register each object's configuration, without the constructor or property information
                foreach (XmlElement element in section.SelectNodes("object"))
                {
                    // In the event of a reference property or constructor argument already being processed, don't process the definition again
                    if (objectDefinitions.ContainsKey(element.GetAttribute("id")) == false)
                    {
                        ObjectDefinition objectDefinition = GetObjectDefinition(section as XmlElement, element, element.GetAttribute("id"));
                        objectDefinitions.Add(objectDefinition.Id, objectDefinition);
                    }
                }
            }

            return this;
        }
        public void TestAddRemoveByKey()
        {
            SynchronizedDictionary <int, string> test = new SynchronizedDictionary <int, string>(new IgnoreLocking());

            for (int i = 0; i < 10; i++)
            {
                test.Add(i, i.ToString());
            }

            for (int i = 0; i < 10; i++)
            {
                Assert.IsTrue(test.ContainsKey(i));
            }

            string cmp;

            for (int i = 0; i < 10; i++)
            {
                Assert.IsTrue(test.TryGetValue(i, out cmp) && cmp == i.ToString());
            }

            for (int i = 0; i < 10; i++)
            {
                Assert.IsTrue(test.Remove(i));
            }
        }
        /// <summary>
        /// To send data request.
        /// </summary>
        /// <param name="series">The candles series for which data receiving should be started.</param>
        /// <param name="from">The initial date from which you need to get data.</param>
        /// <param name="to">The final date by which you need to get data.</param>
        public void Start(CandleSeries series, DateTimeOffset from, DateTimeOffset to)
        {
            if (series == null)
            {
                throw new ArgumentNullException(nameof(series));
            }

            CandleSeriesInfo info;

            lock (_info.SyncRoot)
            {
                info = _info.TryGetValue(series);

                if (info != null)
                {
                    throw new ArgumentException(LocalizedStrings.Str636Params.Put(series), nameof(series));
                }

                info = new CandleSeriesInfo(series, from, to, Sources, OnNewValues, s =>
                {
                    _info.Remove(s);
                    OnStopped(s);
                });

                //Container.Start(series, from, to);

                _info.Add(series, info);
            }

            info.Start();
        }
Beispiel #10
0
        /// <inheritdoc />
        protected override void OnSendInMessage(Message message)
        {
            switch (message.Type)
            {
            case MessageTypes.Reset:
                _states.Clear();
                break;

            case MessageTypes.MarketData:
            {
                var mdMsg = (MarketDataMessage)message;

                if (mdMsg.DataType == MarketDataTypes.MarketDepth)
                {
                    if (mdMsg.IsSubscribe)
                    {
                        if (IsSupportOrderBookIncrements)
                        {
                            _states.Add(mdMsg.TransactionId, RefTuple.Create(new QuotesDict(new BackwardComparer <decimal>()), new QuotesDict(), _none));
                        }
                    }
                    else
                    {
                        _states.Remove(mdMsg.OriginalTransactionId);
                    }
                }

                break;
            }
            }

            base.OnSendInMessage(message);
        }
Beispiel #11
0
            private void TrySubscribe(Security subscriber, MarketDataMessage message)
            {
                //Если уже выполняется поиск данного инструмента, то нет необходимости в повторном вызове OnRegisterXXX.
                //Если на инструмент была подписка ранее, то просто вызываем событие SubscriptionSucceed.
                var subscribersCount = GetSubscribers(message.DataType).ChangeSubscribers(subscriber, true);

                //var securityId = _connector.GetSecurityId(subscriber);

                if (subscribersCount == 1)
                {
                    var lookupMessage = new SecurityLookupMessage
                    {
                        SecurityId    = message.SecurityId,
                        SecurityType  = message.SecurityType,
                        TransactionId = _connector.TransactionIdGenerator.GetNextId()
                    };

                    _lookupMessages.Add(lookupMessage.TransactionId, Tuple.Create(lookupMessage, (MarketDataMessage)message.Clone()));
                    _connector.LookupSecurities(lookupMessage);
                }
                else                // if (subscribed == true)
                {
                    var reply = new MarketDataMessage
                    {
                        OriginalTransactionId = message.TransactionId,
                        IsSubscribe           = true,
                    };
                    _connector.SendOutMessage(reply);
                }
            }
        void ICandleSource <Candle> .Start(CandleSeries series, DateTimeOffset from, DateTimeOffset to)
        {
            if (series == null)
            {
                throw new ArgumentNullException("series");
            }

            var indexSecurity = (IndexSecurity)series.Security;

            var basketInfo = new IndexSeriesInfo(CandleManager,
                                                 indexSecurity
                                                 .InnerSecurities
                                                 .Select(sec => new CandleSeries(series.CandleType, sec, CloneArg(series.Arg, sec))
            {
                WorkingTime = series.WorkingTime.Clone(),
            }).ToArray(),
                                                 from, to, indexSecurity,
                                                 c =>
            {
                if (c.Series == null)
                {
                    c.Series = series;
                    c.Source = this;
                }

                CandleManager.Container.AddCandle(series, c);
                Processing.SafeInvoke(series, c);
            },
                                                 () =>
                                                 Stopped.SafeInvoke(series));

            _info.Add(series, basketInfo);

            basketInfo.Start();
        }
Beispiel #13
0
        private void DepthClick(object sender, RoutedEventArgs e)
        {
            if (Depth.IsChecked == false)
            {
                // create order book window
                var wnd = new QuotesWindow {
                    Title = SelectedSecurity.Id + " " + LocalizedStrings.MarketDepth
                };
                _quotesWindows.Add(SelectedSecurity, wnd);

                // subscribe on order book flow
                Trader.RegisterMarketDepth(SelectedSecurity);

                wnd.Show();
            }
            else
            {
                Trader.UnRegisterMarketDepth(SelectedSecurity);

                var wnd = _quotesWindows[SelectedSecurity];
                _quotesWindows.Remove(SelectedSecurity);

                wnd.Close();
            }

            if (!_initialized)
            {
                TraderOnMarketDepthChanged(Trader.GetMarketDepth(SecurityPicker.SelectedSecurity));
                Trader.MarketDepthChanged += TraderOnMarketDepthChanged;
                _initialized = true;
            }
        }
        private void RealTimeCandlesClick(object sender, RoutedEventArgs e)
        {
            foreach (var security in SecurityPicker.SelectedSecurities)
            {
                var series = new CandleSeries(typeof(TimeFrameCandle), security, InteractiveBrokersTimeFrames.Second5);

                if (_realTimeCandles.Keys.Any(s => s.Security == security))
                {
                    Trader.UnSubscribeCandles(series);
                    _realTimeCandles.GetAndRemove(series).Close();

                    RealTimeCandles.IsChecked = false;
                }
                else
                {
                    var wnd = new CandlesWindow
                    {
                        Title = security.Id + LocalizedStrings.Str2973
                    };
                    _realTimeCandles.Add(series, wnd);
                    Trader.SubscribeCandles(series);
                    wnd.Show();

                    RealTimeCandles.IsChecked = true;
                }
            }
        }
Beispiel #15
0
        /// <summary>
        /// Подписаться на получение свечек.
        /// </summary>
        /// <param name="series">Серия свечек.</param>
        /// <param name="from">Начальная дата, с которой необходимо получать данные.</param>
        /// <param name="to">Конечная дата, до которой необходимо получать данные.</param>
        public void SubscribeCandles(CandleSeries series, DateTimeOffset from, DateTimeOffset to)
        {
            if (series == null)
            {
                throw new ArgumentNullException("series");
            }

            if (series.CandleType != typeof(TimeFrameCandle))
            {
                throw new ArgumentException(LocalizedStrings.NotSupportCandle.Put("OANDA", series.CandleType), "series");
            }

            if (!(series.Arg is TimeSpan))
            {
                throw new ArgumentException(LocalizedStrings.WrongCandleArg.Put(series.Arg), "series");
            }

            var transactionId = TransactionIdGenerator.GetNextId();

            _series.Add(transactionId, series);

            SendInMessage(new MarketDataMessage
            {
                TransactionId = transactionId,
                DataType      = MarketDataTypes.CandleTimeFrame,
                //SecurityId = GetSecurityId(series.Security),
                Arg         = series.Arg,
                IsSubscribe = true,
                From        = from,
                To          = to,
            }.FillSecurityInfo(this, series.Security));
        }
Beispiel #16
0
        public void OnlyGottenTrackingBeginsWhenTrackGottenConstructorIsCalled()
        {
            // Construct with trackAll enabled
            var sd = new SynchronizedDictionary <string, string>(false, true);

            sd.Add("key1", "value1");
            sd.Add("key2", "value2");

            // Check that Access Tracking is disabled
            Assert.IsFalse(sd.TrackAccessed);
            Assert.IsNull(sd.Accessed);

            // Check that Gotten Tracking is enabled
            Assert.IsTrue(sd.TrackGotten);
            Assert.IsNotNull(sd.Gotten);
        }
        public void TestDisposed()
        {
            SynchronizedDictionary <int, string> test = new SynchronizedDictionary <int, string>(new SimpleReadWriteLocking());

            test.Dispose();
            test.Add(1, "");
        }
Beispiel #18
0
        private void HistoryCandlesClick(object sender, RoutedEventArgs e)
        {
            var series = new CandleSeries
            {
                CandleType = typeof(TimeFrameCandle),
                Security   = SelectedSecurity,
                Arg        = CandlesPeriods.SelectedItem,
            };

            var wnd = new CandlesWindow {
                Title = series.ToString()
            };

            _сandles.Add(series, wnd);
            Trader.SubscribeCandles(series, DateTime.Today.Subtract(TimeSpan.FromTicks(((TimeSpan)series.Arg).Ticks * 30)), DateTime.Now);
            wnd.Show();
        }
        public void Add()
        {
            var dictionary = new SynchronizedDictionary <string, string>();

            dictionary.Add("1", "11");

            Assert.Contains("11", dictionary["1"]);
        }
Beispiel #20
0
        private void OnChartPanelSubscribeIndicatorElement(ChartIndicatorElement element, CandleSeries candleSeries, IIndicator indicator)
        {
            _drawTimer.Cancel();

            _elements.Add(new RefPair <IChartElement, int>(element, 0));
            _indicators.Add(element, indicator);
            _drawTimer.Activate();
        }
Beispiel #21
0
        /// <summary>
        /// To get historical candles.
        /// </summary>
        /// <param name="security">The instrument for which you need to get candles.</param>
        /// <param name="candleMessageType">The candle message type.</param>
        /// <param name="arg">The candle parameter (for example, time-frame).</param>
        /// <param name="count">Maximum ticks count.</param>
        /// <param name="isSuccess">Whether all data were obtained successfully or the download process has been interrupted.</param>
        /// <returns>Historical candles.</returns>
        public IEnumerable <CandleMessage> GetHistoricalCandles(Security security, Type candleMessageType, object arg, long count, out bool isSuccess)
        {
            if (security == null)
            {
                throw new ArgumentNullException(nameof(security));
            }

            //if (timeFrame <= TimeSpan.Zero)
            //	throw new ArgumentException("Тайм-фрейм должен быть больше 0.");

            var transactionId = TransactionIdGenerator.GetNextId();

            var series = new CandleSeries(candleMessageType.ToCandleType(), security, arg);

            this.AddInfoLog(LocalizedStrings.Str2146Params, series, count);

            var info = RefTuple.Create(new List <CandleMessage>(), new SyncObject(), false, series, false);

            _candleInfo.Add(transactionId, info);

            var mdMsg = new MarketDataMessage
            {
                //SecurityId = GetSecurityId(series.Security),
                DataType      = GetCandleType(series.CandleType),
                TransactionId = transactionId,
                Count         = count,
                Arg           = arg,
                IsSubscribe   = true,
            }.FillSecurityInfo(this, series.Security);

            _candleSeries.Add(transactionId, series);

            SendInMessage(mdMsg);

            lock (info.Second)
            {
                if (!info.Third)
                {
                    info.Second.Wait();
                }
            }

            isSuccess = info.Fifth;

            return(info.First);
        }
        public void Add()
        {
            var dictionary = new SynchronizedDictionary<string, string>();

            dictionary.Add("1", "11");

            Assert.Contains("11", dictionary["1"]);
        }
        /// <summary>
        /// Register candles builder.
        /// </summary>
        /// <param name="builder">Candles builder.</param>
        public void Register(ICandleBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            _builders.Add(builder.CandleType, builder);
        }
Beispiel #24
0
        /// <summary>
        /// Зарегистрировать хранилище свечек.
        /// </summary>
        /// <param name="storage">Хранилище свечек.</param>
        public void RegisterCandleStorage(IMarketDataStorage <CandleMessage> storage)
        {
            if (storage == null)
            {
                throw new ArgumentNullException("storage");
            }

            _candleStorages.Add(Tuple.Create(storage.Security.ToSecurityId(), storage.Drive), storage);
        }
Beispiel #25
0
        public static SynchronizedDictionary <Security, decimal> GetSecuritiesPositions(this IConnector connector, Portfolio portfolio,
                                                                                        List <Security> securities)
        {
            SynchronizedDictionary <Security, decimal> result = new SynchronizedDictionary <Security, decimal>();

            securities.ForEach(s => { result.Add(s, GetSecurityPosition(connector, portfolio, s)); });

            return(result);
        }
Beispiel #26
0
        private SmartComTimeFrames(SmartBarInterval interval, TimeSpan value)
        {
            Interval = interval;

            _value = value;

            _intervals.Add(interval, this);
            _values.Add(value, this);
        }
Beispiel #27
0
            private void SubscribeStrategyEvents(SessionStrategy sessionStrategy)
            {
                if (!sessionStrategy.Strategy.GetIsEmulation())
                {
                    _logManager.Sources.Add(sessionStrategy.Strategy);
                }

                _events.Add(sessionStrategy.Strategy, new StrategyEvents(sessionStrategy, TryStartTimer));
            }
Beispiel #28
0
                public SnapshotStorageDate(string fileName, ISnapshotSerializer <TKey, TMessage> serializer)
                {
                    if (fileName.IsEmpty())
                    {
                        throw new ArgumentNullException(nameof(fileName));
                    }

                    _fileName   = fileName;
                    _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer));

                    if (File.Exists(_fileName))
                    {
                        Debug.WriteLine($"Snapshot (Load): {_fileName}");

                        using (var stream = File.OpenRead(_fileName))
                        {
                            _version = new Version(stream.ReadByte(), stream.ReadByte());

                            while (stream.Position < stream.Length)
                            {
                                var size = stream.Read <int>();

                                var buffer = new byte[size];
                                stream.ReadBytes(buffer, buffer.Length);

                                var offset = stream.Position;

                                var message = _serializer.Deserialize(_version, buffer);
                                var key     = _serializer.GetKey(message);

                                _snapshots.Add(key, message);
                                _offsets.Add(key, offset);
                            }

                            _currOffset = stream.Length;
                        }
                    }
                    else
                    {
                        _version = _serializer.Version;

                        _currOffset = _versionLen;
                    }
                }
Beispiel #29
0
        public void AddingKeysDoesNotAffectTrackingStatusOrCollectionsWhenInitiallyDisabled()
        {
            var sd = new SynchronizedDictionary <string, string>();

            sd.Add("key1", "value1");
            sd.Add("key2", "value2");

            // First ensure that items are available
            Assert.IsTrue(sd.ContainsKey("key1"));
            Assert.IsTrue(sd.ContainsKey("key2"));

            // Now ensure that tracking is disabled by default
            Assert.IsFalse(sd.TrackAccessed);
            Assert.IsFalse(sd.TrackGotten);

            // Now ensure that tracking collections are null
            Assert.IsNull(sd.Accessed);
            Assert.IsNull(sd.Gotten);
        }
Beispiel #30
0
            public void SubscribeUnSubscribe(Security security, MarketDataMessage message)
            {
                if (security == null)
                {
                    throw new ArgumentNullException(nameof(security));
                }

                _pendingSubscriptions.Add(message.TransactionId, Tuple.Create((MarketDataMessage)message.Clone(), security));
                _connector.SendInMessage(message);
            }
Beispiel #31
0
        public static void set_SessionID_Login_OK(string sessionid)
        {
            long    d   = long.Parse(DateTime.Now.ToString("yyMMddHHmm00"));
            decimal sid = 0;

            if (decimal.TryParse(sessionid, out sid))
            {
                dicSessionID_Login_OK.Add(sid, d);
            }
        }
        public void TestLock()
        {
            LockCounterFactory <SimpleReadWriteLocking> factory = new LockCounterFactory <SimpleReadWriteLocking>();
            ILockStrategy lck = factory.Create();
            SynchronizedDictionary <int, string> test = new SynchronizedDictionary <int, string>(lck);

            Assert.IsTrue(ReferenceEquals(lck, test.Lock));
            test.Add(42, "42");
            Assert.AreEqual(1, factory.TotalWriterCount);
            Assert.AreEqual(0, factory.TotalReaderCount);

            test[42] = "51";
            Assert.AreEqual(2, factory.TotalWriterCount);

            test.Add(1, "52");
            Assert.AreEqual(3, factory.TotalWriterCount);

            test.Remove(-1);
            Assert.AreEqual(4, factory.TotalWriterCount);

            test.Remove(1);
            Assert.AreEqual(5, factory.TotalWriterCount);

            Assert.AreEqual("51", test[42]);
            Assert.AreEqual(1, factory.TotalReaderCount);

            foreach (KeyValuePair <int, string> i in test)
            {
                GC.KeepAlive(i);
            }
            Assert.AreEqual(2, factory.TotalReaderCount);

            Assert.AreEqual(false, test.ContainsKey(-1));
            Assert.AreEqual(3, factory.TotalReaderCount);

            Assert.AreEqual(1, test.Count);
            Assert.AreEqual(4, factory.TotalReaderCount);

            string cmp;

            Assert.IsTrue(test.TryGetValue(42, out cmp) && cmp == "51");
            Assert.AreEqual(5, factory.TotalReaderCount);
        }
Beispiel #33
0
        /// <inheritdoc />
        protected override bool OnSendInMessage(Message message)
        {
            switch (message.Type)
            {
            case MessageTypes.Reset:
                _depths.Clear();
                break;

            case MessageTypes.MarketData:
            {
                var mdMsg = (MarketDataMessage)message;

                if (mdMsg.SecurityId == default)
                {
                    break;
                }

                if (mdMsg.DataType2 == DataType.MarketDepth)
                {
                    if (mdMsg.IsSubscribe)
                    {
                        if (mdMsg.PassThroughOrderBookInrement)
                        {
                            break;
                        }

                        if (mdMsg.MaxDepth != null)
                        {
                            var actualDepth = mdMsg.MaxDepth.Value;

                            var supportedDepth = InnerAdapter.NearestSupportedDepth(actualDepth);

                            if (supportedDepth != actualDepth)
                            {
                                mdMsg          = mdMsg.TypedClone();
                                mdMsg.MaxDepth = supportedDepth;

                                _depths.Add(mdMsg.TransactionId, actualDepth);

                                this.AddInfoLog("MD truncate {0}/{1} ({2}->{3}).", mdMsg.SecurityId, mdMsg.TransactionId, actualDepth, supportedDepth);
                            }
                        }
                    }
                    else
                    {
                        RemoveSubscription(mdMsg.OriginalTransactionId);
                    }
                }

                break;
            }
            }

            return(base.OnSendInMessage(message));
        }
            public void Subscribe(Security security, MarketDataMessage message)
            {
                if (security == null)
                {
                    throw new ArgumentNullException(nameof(security));
                }

                //var indexSecurity = security as IndexSecurity;

                //if (indexSecurity != null)
                //	indexSecurity.InnerSecurities.ForEach(s => _connector.SubscribeMarketData(s, message));
                //else if (security is ContinuousSecurity)
                //	SubscribeContinuous((ContinuousSecurity)security, message);
                //else
                //{
                //TrySubscribe(security, message);
                _pendingSubscriptions.Add(message.TransactionId, Tuple.Create((MarketDataMessage)message.Clone(), security));
                _connector.SendInMessage(message);
                //}
            }
Beispiel #35
0
        public void SynchronizedDictionaryUnitTest()
        {
            SynchronizedDictionary<int, string> dictionary = new SynchronizedDictionary<int, string>();

            dictionary.Add(1, "one");
            dictionary.Add(2, "two");
            Assert.IsTrue(dictionary.Count == 2);

            foreach (KeyValuePair<int, string> keyValuePair in dictionary)
            {
                Assert.IsTrue(dictionary.ContainsKey(keyValuePair.Key));
                Assert.IsTrue(dictionary.ContainsValue(keyValuePair.Value));
            }

            dictionary.Remove(1);
            Assert.IsTrue(dictionary.Count == 1);

            dictionary.Clear();
            Assert.IsTrue(dictionary.Count == 0);
        }
Beispiel #36
0
 /// <summary>
 /// 设置扩展属性
 /// 若指定属性不存在,则添加该属性,若指定属性已存在,则修改该属性
 /// </summary>
 /// <param name="name"></param>
 /// <param name="value"></param>
 public virtual void SetValue(string name, object value)
 {
     if (extendProperties.ContainsKey(name))
     {
         extendProperties[name] = value;
     }
     else
     {
         extendProperties.Add(name, value);
     }
 }