/// <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(); EntityFactory = new EmulationEntityFactory(securityProvider, portfolios); RiskManager = null; SupportBasketSecurities = true; InMessageChannel = new HistoryEmulationMessageChannel(this); OutMessageChannel = new PassThroughMessageChannel(); Adapter = new HistoryBasketMessageAdapter(this); Adapter.InnerAdapters.Add(EmulationAdapter); Adapter.InnerAdapters.Add(new HistoryMessageAdapter(TransactionIdGenerator, securityProvider) { StorageRegistry = storageRegistry }); Adapter.LatencyManager = null; Adapter.CommissionManager = null; Adapter.PnLManager = null; Adapter.SlippageManager = null; // при тестировании по свечкам, время меняется быстрее и таймаут должен быть больше 30с. //ReConnectionSettings.TimeOutInterval = TimeSpan.MaxValue; //MaxMessageCount = 1000; TradesKeepCount = 0; Adapter.SupportCandlesCompression = false; Adapter.SupportBuildingFromOrderLog = false; Adapter.SupportPartialDownload = false; Adapter.SupportLookupTracking = false; Adapter.SupportOrderBookTruncate = false; Adapter.ConnectDisconnectEventOnFirstAdapter = false; }
/// <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); RiskManager = null; SupportSubscriptionTracking = true; SupportBasketSecurities = true; HistoryMessageAdapter = new HistoryMessageAdapter(TransactionIdGenerator, securityProvider) { StorageRegistry = storageRegistry }; InMessageChannel = new HistoryEmulationMessageChannel(HistoryMessageAdapter, SendOutError); OutMessageChannel = new PassThroughMessageChannel(); Adapter = new HistoryBasketMessageAdapter(this); Adapter.InnerAdapters.Add(EmulationAdapter); Adapter.InnerAdapters.Add(HistoryMessageAdapter); Adapter.LatencyManager = null; Adapter.CommissionManager = null; Adapter.PnLManager = null; Adapter.SlippageManager = null; // при тестировании по свечкам, время меняется быстрее и таймаут должен быть больше 30с. ReConnectionSettings.TimeOutInterval = TimeSpan.MaxValue; //MaxMessageCount = 1000; TradesKeepCount = 0; RaiseConnectedOnFirstAdapter = false; }