public void WhenPriceGoesDownAndIsNotSustainedForLongerThan7SecondsThenDoesntTriggerStopLoss() { var positionAcquired = new PositionAcquired(1.0M); stopLossManager.Consume(positionAcquired); var priceUpdated = new PriceUpdated { Price = 0.89M }; stopLossManager.Consume(priceUpdated); var priceUpdated2 = new PriceUpdated { Price = 0.91M }; stopLossManager.Consume(priceUpdated2); var sendToMeInX = new SendToMeInX <PriceUpdated>(7.0M, priceUpdated); stopLossManager.Consume(sendToMeInX); var stopLossTriggered = bus.GetLastMessage <StopLossTriggered>(); Assert.Null(stopLossTriggered); }
public void WhenPriceNotSustainedForLongerThan10SecondsThenTargetNotUpdated() { var positionAcquired = new PositionAcquired(1.0M); stopLossManager.Consume(positionAcquired); var priceUpdated = new PriceUpdated { Price = 0.8M }; stopLossManager.Consume(priceUpdated); bus.Clear(); priceUpdated = new PriceUpdated { Price = 1.5M }; var sendToMeInX = new SendToMeInX <PriceUpdated>(10.0M, priceUpdated); stopLossManager.Consume(sendToMeInX); var targetUpdated = bus.GetLastMessage <TargetUpdated>(); Assert.Null(targetUpdated); }
public void WhenPriceGoesUpAndThenDownThenTakesTheMinimumSustainedIncrease() { var positionAcquired = new PositionAcquired(1.0M); stopLossManager.Consume(positionAcquired); var priceUpdated = new PriceUpdated { Price = 1.5M }; stopLossManager.Consume(priceUpdated); priceUpdated = new PriceUpdated { Price = 1.2M }; stopLossManager.Consume(priceUpdated); bus.Clear(); priceUpdated = new PriceUpdated { Price = 1.5M }; var sendToMeInX = new SendToMeInX <PriceUpdated>(10.0M, priceUpdated); stopLossManager.Consume(sendToMeInX); var targetUpdated = bus.GetLastMessage <TargetUpdated>(); Assert.NotNull(targetUpdated); Assert.Equal(targetUpdated.TargetPrice, 1.1M); }
public void WhenPriceSustainedForLongerThan10SecondsThenTargetUpdated() { var positionAcquired = new PositionAcquired(1.0M); stopLossManager.Consume(positionAcquired); var priceUpdated = new PriceUpdated { Price = 1.5M }; stopLossManager.Consume(priceUpdated); var sendToMeInX = new SendToMeInX<PriceUpdated>(10.0M, priceUpdated); stopLossManager.Consume(sendToMeInX); var targetUpdated = bus.GetLastMessage<TargetUpdated>(); Assert.That(targetUpdated, Is.Not.Null); Assert.That(targetUpdated.TargetPrice, Is.EqualTo(1.4M)); }
public void WhenPriceSustainedForLongerThan10SecondsThenTargetUpdated() { var positionAcquired = new PositionAcquired(1.0M); stopLossManager.Consume(positionAcquired); var priceUpdated = new PriceUpdated { Price = 1.5M }; stopLossManager.Consume(priceUpdated); var sendToMeInX = new SendToMeInX <PriceUpdated>(10.0M, priceUpdated); stopLossManager.Consume(sendToMeInX); var targetUpdated = bus.GetLastMessage <TargetUpdated>(); Assert.That(targetUpdated, Is.Not.Null); Assert.That(targetUpdated.TargetPrice, Is.EqualTo(1.4M)); }
public void WhenPriceGoesUpAndThenDownThenTakesTheMinimumSustainedIncrease() { var positionAcquired = new PositionAcquired(1.0M); stopLossManager.Consume(positionAcquired); var priceUpdated = new PriceUpdated { Price = 1.5M }; stopLossManager.Consume(priceUpdated); priceUpdated = new PriceUpdated { Price = 1.2M }; stopLossManager.Consume(priceUpdated); bus.Clear(); priceUpdated = new PriceUpdated { Price = 1.5M }; var sendToMeInX = new SendToMeInX<PriceUpdated>(10.0M, priceUpdated); stopLossManager.Consume(sendToMeInX); var targetUpdated = bus.GetLastMessage<TargetUpdated>(); Assert.That(targetUpdated, Is.Not.Null); Assert.That(targetUpdated.TargetPrice, Is.EqualTo(1.1M)); }
public void WhenPriceGoesDownAndIsNotSustainedForLongerThan7SecondsThenDoesntTriggerStopLoss() { var positionAcquired = new PositionAcquired(1.0M); stopLossManager.Consume(positionAcquired); var priceUpdated = new PriceUpdated { Price = 0.89M }; stopLossManager.Consume(priceUpdated); var priceUpdated2 = new PriceUpdated { Price = 0.91M }; stopLossManager.Consume(priceUpdated2); var sendToMeInX = new SendToMeInX<PriceUpdated>(7.0M, priceUpdated); stopLossManager.Consume(sendToMeInX); var stopLossTriggered = bus.GetLastMessage<StopLossTriggered>(); Assert.That(stopLossTriggered, Is.Null); }