public JobFactory(IHistoricalDataBroker hdb, string host, int port, string username, string password, string sender, string email, UpdateJobSettings updateJobSettings, QDMS.IDataStorage localStorage, IEconomicReleaseBroker erb, IDividendsBroker divb, IEarningsAnnouncementBroker eab) : base() { _hdb = hdb; _host = host; _port = port; _username = username; _password = password; _sender = sender; _email = email; _updateJobSettings = updateJobSettings; _localStorage = localStorage; _erb = erb; _divb = divb; _eab = eab; }
public JobFactory(IHistoricalDataBroker hdb, string host, int port, string username, string password, string sender, string email, UpdateJobSettings updateJobSettings, QDMS.IDataStorage localStorage, IInstrumentSource instrumentSource, IEconomicReleaseBroker erb) : base() { _hdb = hdb; _host = host; _port = port; _username = username; _password = password; _sender = sender; _email = email; _updateJobSettings = updateJobSettings; _localStorage = localStorage; _instrumentSource = instrumentSource; _erb = erb; }
public void EmailReportSentOnBrokerError() { var settings = new UpdateJobSettings(errors: true, timeout: 1, toEmail: "*****@*****.**", fromEmail: "*****@*****.**"); var job = new DataUpdateJob(_brokerMock.Object, _mailMock.Object, settings, _localStorageMock.Object, _instrumentManagerMock.Object); _brokerMock .Setup(x => x.RequestHistoricalData(It.IsAny<HistoricalDataRequest>())) .Throws(new Exception("TestException123")); Instrument inst = new Instrument() { ID = 1, Symbol = "SPY", Currency = "USD", Type = InstrumentType.Stock }; _instrumentManagerMock .Setup(x => x.FindInstruments(It.IsAny<Expression<Func<Instrument, bool>>>(), It.IsAny<MyDBContext>())) .Returns(new List<Instrument>() { inst }); _localStorageMock .Setup(x => x.GetStorageInfo(It.IsAny<int>())) .Returns(new List<StoredDataInfo>() { new StoredDataInfo() { Frequency = BarSize.OneDay, InstrumentID = inst.ID.Value, LatestDate = DateTime.Now.AddDays(-2) } }); job.Execute(_contextMock.Object); _mailMock.Verify(x => x.Send( It.IsAny<string>(), It.Is<string>(y => y == "*****@*****.**"), It.IsAny<string>(), It.Is<string>(y => y.Contains("TestException123")))); }
public JobFactory(IHistoricalDataBroker hdb, ISettings settings, QDMS.IDataStorage localStorage, IEconomicReleaseBroker erb, IDividendsBroker divb, IEarningsAnnouncementBroker eab) : base() { _hdb = hdb; _host = settings.updateJobEmailHost; _port = settings.updateJobEmailPort; _username = settings.updateJobEmailUsername; _password = settings.updateJobEmailPassword; _sender = settings.updateJobEmailSender; _email = settings.updateJobEmail; _updateJobSettings = new UpdateJobSettings( noDataReceived: settings.updateJobReportNoData, errors: settings.updateJobReportErrors, outliers: settings.updateJobReportOutliers, requestTimeouts: settings.updateJobTimeouts, timeout: settings.updateJobTimeout, toEmail: settings.updateJobEmail, fromEmail: settings.updateJobEmailSender); _localStorage = localStorage; _erb = erb; _divb = divb; _eab = eab; }
public DataUpdateJob(IHistoricalDataBroker broker, IEmailService emailService, UpdateJobSettings settings = null, IDataStorage localStorage = null, IInstrumentSource instrumentManager = null) { _broker = broker; _emailService = emailService; _errors = new List<string>(); _pendingRequests = new List<HistoricalDataRequest>(); _settings = settings ?? GetSettings(); _localStorage = localStorage ?? DataStorageFactory.Get(); _instrumentManager = instrumentManager ?? new InstrumentManager(); }
public DataUpdateJob(IHistoricalDataBroker broker, IEmailService emailService, UpdateJobSettings settings = null, IDataStorage localStorage = null, IInstrumentSource instrumentManager = null) { _broker = broker; _emailService = emailService; _errors = new List <string>(); _pendingRequests = new List <HistoricalDataRequest>(); _settings = settings ?? GetSettings(); _localStorage = localStorage ?? DataStorageFactory.Get(); _instrumentManager = instrumentManager ?? new InstrumentManager(); }
public DataUpdateJob(IHistoricalDataBroker broker, IEmailService emailService, UpdateJobSettings settings, IDataStorage localStorage, IInstrumentSource instrumentManager) { if (settings == null) throw new ArgumentNullException("settings"); if (localStorage == null) throw new ArgumentNullException("localStorage"); if (instrumentManager == null) throw new ArgumentNullException("instrumentManager"); _broker = broker; _emailService = emailService; _errors = new List<string>(); _pendingRequests = new List<HistoricalDataRequest>(); _settings = settings; _localStorage = localStorage; _instrumentManager = instrumentManager; }
public DataUpdateJobFactory(HistoricalDataBroker broker, string host, int port, string username, string password, string sender, string email, UpdateJobSettings updateJobSettings, QDMS.IDataStorage localStorage, IInstrumentSource instrumentSource) : base() { _hdb = broker; _host = host; _port = port; _username = username; _password = password; _sender = sender; _email = email; _updateJobSettings = updateJobSettings; _localStorage = localStorage; _instrumentSource = instrumentSource; }
/// <summary> /// </summary> /// <param name="broker"></param> /// <param name="emailService"></param> /// <param name="settings"></param> /// <param name="localStorage"></param> /// <param name="instrumentManager"></param> /// <exception cref="ArgumentNullException"><paramref name="instrumentManager"/> is <see langword="null" />.</exception> public DataUpdateJob(IHistoricalDataBroker broker, IEmailService emailService, UpdateJobSettings settings, IDataStorage localStorage, IInstrumentSource instrumentManager) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (localStorage == null) { throw new ArgumentNullException(nameof(localStorage)); } if (instrumentManager == null) { throw new ArgumentNullException(nameof(instrumentManager)); } _broker = broker; _emailService = emailService; _errors = new List <string>(); _pendingRequests = new List <HistoricalDataRequest>(); _settings = settings; _localStorage = localStorage; _instrumentManager = instrumentManager; }
public void EmailReportSentOnAbnormalData() { var settings = new UpdateJobSettings(errors: true, timeout: 5, toEmail: "*****@*****.**", fromEmail: "*****@*****.**"); var job = new DataUpdateJob(_brokerMock.Object, _mailMock.Object, settings, _localStorageMock.Object, _instrumentManagerMock.Object); Instrument inst = new Instrument() { ID = 1, Symbol = "SPY", Currency = "USD", Type = InstrumentType.Stock }; _instrumentManagerMock .Setup(x => x.FindInstruments(It.IsAny<Expression<Func<Instrument, bool>>>(), It.IsAny<MyDBContext>())) .Returns(new List<Instrument>() { inst }); _localStorageMock .Setup(x => x.GetStorageInfo(It.IsAny<int>())) .Returns(new List<StoredDataInfo>() { new StoredDataInfo() { Frequency = BarSize.OneDay, InstrumentID = inst.ID.Value, LatestDate = DateTime.Now.AddDays(-2) } }); HistoricalDataRequest req = null; _brokerMock .Setup(x => x.RequestHistoricalData(It.IsAny<HistoricalDataRequest>())) .Callback<HistoricalDataRequest>(y => { req = y; //Return data with an obvious "break" var data = new List<OHLCBar> { new OHLCBar() { Open = 1m, High = 1.5m, Low = 0.9m, Close = 1.1m, DT = req.StartingDate.AddDays(-1)}, new OHLCBar() { Open = 2m, High = 3.5m, Low = 1.9m, Close = 2.1m, DT = req.StartingDate}, }; _localStorageMock .Setup(x => x.GetData(It.IsAny<Instrument>(), It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<BarSize>())) .Returns(data); }); Task.Run(() => job.Execute(_contextMock.Object)); Thread.Sleep(2000); _brokerMock.Raise(x => x.HistoricalDataArrived += null, new HistoricalDataEventArgs(req, new List<OHLCBar>())); Thread.Sleep(100); _mailMock.Verify(x => x.Send( It.IsAny<string>(), It.Is<string>(y => y == "*****@*****.**"), It.IsAny<string>(), It.Is<string>(y => y.Contains("Possible dirty data detected")))); }
public void EmailReportSentOnNoData() { var settings = new UpdateJobSettings(errors: true, timeout: 5, toEmail: "*****@*****.**", fromEmail: "*****@*****.**"); var job = new DataUpdateJob(_brokerMock.Object, _mailMock.Object, settings, _localStorageMock.Object, _instrumentManagerMock.Object); Instrument inst = new Instrument() { ID = 1, Symbol = "SPY", Currency = "USD", Type = InstrumentType.Stock }; _instrumentManagerMock .Setup(x => x.FindInstruments(It.IsAny<Expression<Func<Instrument, bool>>>(), It.IsAny<MyDBContext>())) .Returns(new List<Instrument>() { inst }); _localStorageMock .Setup(x => x.GetStorageInfo(It.IsAny<int>())) .Returns(new List<StoredDataInfo>() { new StoredDataInfo() { Frequency = BarSize.OneDay, InstrumentID = inst.ID.Value, LatestDate = DateTime.Now.AddDays(-2) } }); HistoricalDataRequest req = null; _brokerMock .Setup(x => x.RequestHistoricalData(It.IsAny<HistoricalDataRequest>())) .Callback<HistoricalDataRequest>(y => req = y); Task.Run(() => job.Execute(_contextMock.Object)); Thread.Sleep(2000); _brokerMock.Raise(x => x.HistoricalDataArrived += null, new HistoricalDataEventArgs(req, new List<OHLCBar>())); Thread.Sleep(2000); _mailMock.Verify(x => x.Send( It.IsAny<string>(), It.Is<string>(y => y == "*****@*****.**"), It.IsAny<string>(), It.Is<string>(y => y.Contains("downloaded 0 bars")))); }
public EconomicReleaseUpdateJob(IEconomicReleaseBroker broker, IEmailService emailService, UpdateJobSettings settings) { _broker = broker; _emailService = emailService; _settings = settings; }