public void InitiateWalk_GeneratesSubsequentTicks_AsExpected() { var randomWalkStrategy = new MarkovEquityStrategy(); var randomWalk = new EquitiesMarkovProcess( new NasdaqInitialiser(), randomWalkStrategy, this._heartbeat, this._logger); var stream = new ExchangeStream(new UnsubscriberFactory <EquityIntraDayTimeBarCollection>()); var observer = new RecordingObserver <EquityIntraDayTimeBarCollection>(this._logger, 5); stream.Subscribe(observer); randomWalk.InitiateWalk(stream); var timeOut = DateTime.UtcNow.AddSeconds(5); while (observer.Buffer.Count < 2 && DateTime.UtcNow < timeOut) { // don't sleep the thread } Assert.AreEqual(observer.Buffer.Count, 2); randomWalk.TerminateWalk(); }
public void InitiateWalk_ReceivesTicks_AfterInitiationImmediately() { var randomWalkStrategy = new MarkovEquityStrategy(); var randomWalk = new EquitiesMarkovProcess( this._exchangeTickInitialiser, randomWalkStrategy, this._heartbeat, this._logger); var stream = new ExchangeStream(new UnsubscriberFactory <EquityIntraDayTimeBarCollection>()); var observer = new RecordingObserver <EquityIntraDayTimeBarCollection>(this._logger, 10); stream.Subscribe(observer); randomWalk.InitiateWalk(stream); Assert.AreEqual(observer.Buffer.Count, 1); randomWalk.TerminateWalk(); }
public void InitiateWalk_WaitThenTerminateWalk_EnsuresNoMoreTicksTocked() { var randomWalk = new EquitiesMarkovProcess( new NasdaqInitialiser(), this._strategy, this._heartbeat, this._logger); var stream = new ExchangeStream(new UnsubscriberFactory <EquityIntraDayTimeBarCollection>()); var observer = new RecordingObserver <EquityIntraDayTimeBarCollection>(this._logger, 5); stream.Subscribe(observer); randomWalk.InitiateWalk(stream); var timeOut = DateTime.UtcNow.AddSeconds(5); while (observer.Buffer.Count < 2 && DateTime.UtcNow < timeOut) { // don't sleep the thread } randomWalk.TerminateWalk(); Assert.AreEqual(observer.Buffer.Count, 2); var timerForStragglers = DateTime.UtcNow.AddSeconds(2); while (DateTime.UtcNow < timerForStragglers) { // don't sleep the thread } Assert.AreEqual(observer.Buffer.Count, 2); A.CallTo(() => this._logger.LogInformation("Random walk generator terminating walk")) .MustHaveHappenedOnceExactly(); }