Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BatchEmulation"/>.
        /// </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 BatchEmulation(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));
            }

            Strategies = Enumerable.Empty <Strategy>();

            EmulationSettings  = new EmulationSettings();
            EmulationConnector = new HistoryEmulationConnector(securityProvider, portfolios, storageRegistry)
            {
                UpdateSecurityLastQuotes = false,
                UpdateSecurityByLevel1   = false
            };

            //_basketSessionHolder = new HistoryBasketSessionHolder(EmulationConnector.TransactionIdGenerator);

            EmulationConnector.Adapter.InnerAdapters.Add(new BasketEmulationAdapter(EmulationConnector.TransactionIdGenerator, EmulationSettings));

            EmulationConnector.StateChanged      += EmulationConnectorOnStateChanged;
            EmulationConnector.MarketTimeChanged += EmulationConnectorOnMarketTimeChanged;
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BatchEmulation"/>.
        /// </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 BatchEmulation(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));
            }

            Strategies = Enumerable.Empty <Strategy>();

            EmulationSettings  = new EmulationSettings();
            EmulationConnector = new HistoryEmulationConnector(securityProvider, portfolios, storageRegistry)
            {
                UpdateSecurityLastQuotes = false,
                UpdateSecurityByLevel1   = false
            };

            EmulationConnector.StateChanged      += EmulationConnectorOnStateChanged;
            EmulationConnector.MarketTimeChanged += EmulationConnectorOnMarketTimeChanged;
            EmulationConnector.Disconnected      += EmulationConnectorOnDisconnected;
            EmulationConnector.NewSecurities     += EmulationConnectorOnNewSecurities;
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BatchEmulation"/>.
        /// </summary>
        /// <param name="securityProvider">The provider of information about instruments.</param>
        /// <param name="portfolioProvider">The portfolio to be used to register orders. If value is not given, the portfolio with default name Simulator will be created.</param>
        /// <param name="storageRegistry">Market data storage.</param>
        /// <param name="storageFormat">The format of market data. <see cref="StorageFormats.Binary"/> is used by default.</param>
        /// <param name="drive">The storage which is used by default. By default, <see cref="IStorageRegistry.DefaultDrive"/> is used.</param>
        public BatchEmulation(ISecurityProvider securityProvider, IPortfolioProvider portfolioProvider, IStorageRegistry storageRegistry, StorageFormats storageFormat = StorageFormats.Binary, IMarketDataDrive drive = null)
        {
            _securityProvider  = securityProvider ?? throw new ArgumentNullException(nameof(securityProvider));
            _portfolioProvider = portfolioProvider ?? throw new ArgumentNullException(nameof(portfolioProvider));

            EmulationSettings = new EmulationSettings();

            StorageSettings = new StorageCoreSettings
            {
                StorageRegistry = storageRegistry,
                Drive           = drive,
                Format          = storageFormat,
            };
        }
Пример #4
0
        /// <summary>
        /// Создать <see cref="BatchEmulation"/>.
        /// </summary>
        /// <param name="securityProvider">Поставщик информации об инструментах.</param>
        /// <param name="portfolios">Портфели, с которыми будет вестись работа.</param>
        /// <param name="storageRegistry">Хранилище данных.</param>
        public BatchEmulation(ISecurityProvider securityProvider, IEnumerable <Portfolio> portfolios, IStorageRegistry storageRegistry)
        {
            if (securityProvider == null)
            {
                throw new ArgumentNullException("securityProvider");
            }

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

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

            Strategies = Enumerable.Empty <Strategy>().ToEx();

            EmulationSettings  = new EmulationSettings();
            EmulationConnector = new HistoryEmulationConnector(securityProvider, portfolios, storageRegistry)
            {
                UpdateSecurityLastQuotes = false,
                UpdateSecurityByLevel1   = false
            };

            _basketSessionHolder = new HistoryBasketSessionHolder(EmulationConnector.TransactionIdGenerator);

            EmulationConnector.TransactionAdapter = new BasketEmulationAdapter(_basketSessionHolder, EmulationSettings)
            {
                OutMessageProcessor = new NonThreadMessageProcessor()
            };

            EmulationConnector.StateChanged      += EmulationConnectorOnStateChanged;
            EmulationConnector.MarketTimeChanged += EmulationConnectorOnMarketTimeChanged;
        }
Пример #5
0
 public BasketEmulationAdapter(IdGenerator transactionIdGenerator, IPortfolioMessageAdapterProvider adapterProvider, CandleBuilderProvider candleBuilderProvider, EmulationSettings settings)
     : base(transactionIdGenerator, adapterProvider, candleBuilderProvider)
 {
     _settings = settings;
 }
Пример #6
0
 public BasketEmulationAdapter(IdGenerator transactionIdGenerator, IPortfolioMessageAdapterProvider adapterProvider, IExchangeInfoProvider exchangeInfoProvider, EmulationSettings settings)
     : base(transactionIdGenerator, adapterProvider, exchangeInfoProvider)
 {
     _settings = settings;
 }
Пример #7
0
 public BasketEmulationAdapter(IdGenerator transactionIdGenerator, EmulationSettings settings)
     : base(transactionIdGenerator)
 {
     _settings = settings;
 }
Пример #8
0
			public BasketEmulationAdapter(IdGenerator transactionIdGenerator, EmulationSettings settings)
				: base(transactionIdGenerator)
			{
				_settings = settings;
			}
Пример #9
0
		/// <summary>
		/// Initializes a new instance of the <see cref="BatchEmulation"/>.
		/// </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 BatchEmulation(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));

			Strategies = Enumerable.Empty<Strategy>().ToEx();

			EmulationSettings = new EmulationSettings();
			EmulationConnector = new HistoryEmulationConnector(securityProvider, portfolios, storageRegistry)
			{
				UpdateSecurityLastQuotes = false,
				UpdateSecurityByLevel1 = false
			};

			//_basketSessionHolder = new HistoryBasketSessionHolder(EmulationConnector.TransactionIdGenerator);

			EmulationConnector.Adapter.InnerAdapters.Add(new BasketEmulationAdapter(EmulationConnector.TransactionIdGenerator, EmulationSettings));

			EmulationConnector.StateChanged += EmulationConnectorOnStateChanged;
			EmulationConnector.MarketTimeChanged += EmulationConnectorOnMarketTimeChanged;
		}
Пример #10
0
 public BasketEmulationAdapter(BasketSessionHolder sessionHolder, EmulationSettings settings)
     : base(MessageAdapterTypes.Transaction, sessionHolder)
 {
     _settings = settings;
 }