예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Connector"/>.
        /// </summary>
        /// <param name="initAdapter">Initialize basket adapter.</param>
        /// <param name="initChannels">Initialize channels.</param>
        /// <param name="storageRegistry">The storage of market data.</param>
        /// <param name="snapshotRegistry">Snapshot storage registry.</param>
        /// <param name="initManagers">Initialize managers.</param>
        protected Connector(bool initAdapter, bool initChannels = true,
                            IStorageRegistry storageRegistry    = null, SnapshotRegistry snapshotRegistry = null,
                            bool initManagers = true)
        {
            _entityCache = new EntityCache(this)
            {
                ExchangeInfoProvider = new InMemoryExchangeInfoProvider()
            };

            _subscriptionManager = new SubscriptionManager(this);

            UpdateSecurityLastQuotes = UpdateSecurityByLevel1 = UpdateSecurityByDefinition = true;

            SupportLevel1DepthBuilder  = true;
            SupportFilteredMarketDepth = true;

            if (initManagers)
            {
                //PnLManager = new PnLManager();
                RiskManager = new RiskManager();
            }

            _connectorStat.Add(this);

            if (initChannels)
            {
                InMessageChannel  = new InMemoryMessageChannel($"Connector In ({Name})", RaiseError);
                OutMessageChannel = new InMemoryMessageChannel($"Connector Out ({Name})", RaiseError);
            }

            if (initAdapter)
            {
                InitAdapter(storageRegistry, snapshotRegistry);
            }
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HistoryEmulationConnector"/>.
        /// </summary>
        /// <param name="securityProvider">The provider of information about instruments.</param>
        /// <param name="portfolios">Portfolios, the operation will be performed with.</param>
        /// <param name="storageRegistry">Market data storage.</param>
        public HistoryEmulationConnector(ISecurityProvider securityProvider, IEnumerable <Portfolio> portfolios, IStorageRegistry storageRegistry)
        {
            if (securityProvider == null)
            {
                throw new ArgumentNullException(nameof(securityProvider));
            }

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

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

            // чтобы каждый раз при повторной эмуляции получать одинаковые номера транзакций
            TransactionIdGenerator = new IncrementalIdGenerator();

            _initialMoney = portfolios.ToDictionary(pf => pf, pf => pf.BeginValue);
            EntityFactory = new EmulationEntityFactory(securityProvider, _initialMoney.Keys);

            InMessageChannel  = new PassThroughMessageChannel();
            OutMessageChannel = new PassThroughMessageChannel();

            LatencyManager    = null;
            RiskManager       = null;
            CommissionManager = null;
            PnLManager        = null;
            SlippageManager   = null;

            HistoryMessageAdapter = new HistoryMessageAdapter(TransactionIdGenerator, securityProvider)
            {
                StorageRegistry = storageRegistry
            };
            _historyChannel = new InMemoryMessageChannel("History Out", SendOutError);

            Adapter = new HistoryBasketMessageAdapter(this);
            Adapter.InnerAdapters.Add(EmulationAdapter);
            Adapter.InnerAdapters.Add(new ChannelMessageAdapter(HistoryMessageAdapter, new InMemoryMessageChannel("History In", SendOutError), _historyChannel));

            // при тестировании по свечкам, время меняется быстрее и таймаут должен быть больше 30с.
            ReConnectionSettings.TimeOutInterval = TimeSpan.MaxValue;

            MaxMessageCount = 1000;

            TradesKeepCount = 0;
        }
예제 #3
0
 protected override void Given()
 {
     messageChannel = new InMemoryMessageChannel();
     bus = new CoreBus(messageChannel, messageChannel, messageRouting);
 }
		/// <summary>
		/// Initializes a new instance of the <see cref="HistoryEmulationConnector"/>.
		/// </summary>
		/// <param name="securityProvider">The provider of information about instruments.</param>
		/// <param name="portfolios">Portfolios, the operation will be performed with.</param>
		/// <param name="storageRegistry">Market data storage.</param>
		public HistoryEmulationConnector(ISecurityProvider securityProvider, IEnumerable<Portfolio> portfolios, IStorageRegistry storageRegistry)
		{
			if (securityProvider == null)
				throw new ArgumentNullException(nameof(securityProvider));

			if (portfolios == null)
				throw new ArgumentNullException(nameof(portfolios));

			if (storageRegistry == null)
				throw new ArgumentNullException(nameof(storageRegistry));

			// чтобы каждый раз при повторной эмуляции получать одинаковые номера транзакций
			TransactionIdGenerator = new IncrementalIdGenerator();

			_initialMoney = portfolios.ToDictionary(pf => pf, pf => pf.BeginValue);
			EntityFactory = new EmulationEntityFactory(securityProvider, _initialMoney.Keys);

			InMessageChannel = new PassThroughMessageChannel();
			OutMessageChannel = new PassThroughMessageChannel();

			LatencyManager = null;
			RiskManager = null;
			CommissionManager = null;
			PnLManager = null;
			SlippageManager = null;

			HistoryMessageAdapter = new HistoryMessageAdapter(TransactionIdGenerator, securityProvider) { StorageRegistry = storageRegistry };
			_historyChannel = new InMemoryMessageChannel("History Out", SendOutError);

			Adapter = new HistoryBasketMessageAdapter(this);
			Adapter.InnerAdapters.Add(EmulationAdapter);
			Adapter.InnerAdapters.Add(new ChannelMessageAdapter(HistoryMessageAdapter, new InMemoryMessageChannel("History In", SendOutError), _historyChannel));

			// при тестировании по свечкам, время меняется быстрее и таймаут должен быть больше 30с.
			ReConnectionSettings.TimeOutInterval = TimeSpan.MaxValue;

			MaxMessageCount = 1000;

			TradesKeepCount = 0;
		}