internal void CanSerializeAndDeserialize_SubmitBracketOrderCommands_WithNoTakeProfit() { // Arrange var entry = new StubOrderBuilder().BuildMarketOrder(); var stopLoss = new StubOrderBuilder().BuildStopMarketOrder(); var bracketOrder = new BracketOrder(entry, stopLoss); var command = new SubmitBracketOrder( new TraderId("TESTER", "000"), new AccountId("FXCM", "028999999", "SIMULATED"), new StrategyId("EMACross", "001"), new PositionId("P-123456"), bracketOrder, Guid.NewGuid(), StubZonedDateTime.UnixEpoch()); // Act var packed = this.serializer.Serialize(command); var unpacked = (SubmitBracketOrder)this.serializer.Deserialize(packed); // Assert Assert.Equal(command, unpacked); Assert.Equal(bracketOrder, unpacked.BracketOrder); this.Output.WriteLine(Convert.ToBase64String(packed)); this.Output.WriteLine(Encoding.UTF8.GetString(packed)); }
internal void GetSlippage_SellOrderFilledVariousAveragePrices_ReturnsExpectedResult(decimal averagePrice, decimal expectedSlippage) { // Arrange var order = new StubOrderBuilder() .WithOrderSide(OrderSide.Sell) .WithPrice(Price.Create(1.20000m, 5)) .BuildStopMarketOrder(); var event1 = StubEventMessageProvider.OrderSubmittedEvent(order); var event2 = StubEventMessageProvider.OrderAcceptedEvent(order); var event3 = StubEventMessageProvider.OrderWorkingEvent(order, order.Price); var event4 = StubEventMessageProvider.OrderFilledEvent(order, Price.Create(averagePrice, 5)); order.Apply(event1); order.Apply(event2); order.Apply(event3); order.Apply(event4); // Act var result = order.Slippage; // Assert Assert.Equal(OrderState.Filled, order.State); Assert.Equal(expectedSlippage, result); }
internal void OnSubmitOrderCommand_WhenCommandValid_OperatesDatabaseAndSendsToGateway() { // Arrange var order = new StubOrderBuilder().EntryOrder("O-123456").BuildMarketOrder(); var traderId = TraderId.FromString("TESTER-000"); var accountId = AccountId.FromString("NAUTILUS-000-SIMULATED"); var positionId = new PositionId("P-123456"); var strategyId = new StrategyId("SCALPER", "001"); var command = new SubmitOrder( traderId, accountId, strategyId, positionId, order, Guid.NewGuid(), StubZonedDateTime.UnixEpoch()); // Act this.engine.Endpoint.SendAsync(command).Wait(); Task.Delay(100).Wait(); // Buffer to avoid intermittent tests // Assert Assert.Null(this.engine.UnhandledMessages.FirstOrDefault()); Assert.Equal(2, this.engine.ProcessedCount); Assert.Equal(1, this.engine.CommandCount); Assert.Single(this.tradingGateway.CalledMethods); Assert.Single(this.tradingGateway.ReceivedObjects); Assert.Equal("SubmitOrder", this.tradingGateway.CalledMethods[0]); Assert.Equal(order, this.tradingGateway.ReceivedObjects[0]); }
internal void CanSerializeAndDeserialize_OrderWorkingWithExpireTimeEvents() { // Arrange var order = new StubOrderBuilder() .WithTimeInForce(TimeInForce.GTD) .WithExpireTime(StubZonedDateTime.UnixEpoch() + Duration.FromMinutes(1)) .BuildStopMarketOrder(); var working = new OrderWorking( AccountId.FromString("FXCM-02851908-DEMO"), order.Id, new OrderIdBroker("B" + order.Id.Value), order.Symbol, order.OrderSide, order.OrderType, order.Quantity, order.Price, order.TimeInForce, order.ExpireTime, StubZonedDateTime.UnixEpoch(), Guid.NewGuid(), StubZonedDateTime.UnixEpoch()); // Act var packed = this.serializer.Serialize(working); var unpacked = (OrderWorking)this.serializer.Deserialize(packed); // Assert Assert.Equal(working, unpacked); this.Output.WriteLine(Convert.ToBase64String(packed)); }
internal void OnOrderPartiallyFilledEvent_UpdatesOrderSendsToPublisher() { // Arrange var order = new StubOrderBuilder().EntryOrder("O-123456").BuildMarketOrder(); var traderId = TraderId.FromString("TESTER-000"); var accountId = AccountId.FromString("NAUTILUS-000-SIMULATED"); var positionId = new PositionId("P-123456"); var strategyId = new StrategyId("SCALPER", "001"); var submitOrder = new SubmitOrder( traderId, accountId, strategyId, positionId, order, Guid.NewGuid(), StubZonedDateTime.UnixEpoch()); // Act this.engine.Endpoint.SendAsync(submitOrder).Wait(); this.engine.Endpoint.SendAsync(StubEventMessageProvider.OrderAcceptedEvent(order)).Wait(); this.engine.Endpoint.SendAsync(StubEventMessageProvider.OrderPartiallyFilledEvent( order, Quantity.Create(50000), Quantity.Create(50000))).Wait(); Task.Delay(100).Wait(); // Buffer to avoid intermittent tests // Assert Assert.Null(this.engine.UnhandledMessages.FirstOrDefault()); Assert.Equal(4, this.engine.ProcessedCount); Assert.Equal(1, this.engine.CommandCount); Assert.Equal(2, this.engine.EventCount); Assert.Equal(3, this.receiver.Messages.Count); Assert.Equal(OrderState.PartiallyFilled, order.State); }
internal void OnOrderFilledEvent_WithNoPosition_OpensPosition() { // Arrange var order = new StubOrderBuilder().EntryOrder("O-123456").BuildMarketOrder(); var traderId = TraderId.FromString("TESTER-000"); var accountId = AccountId.FromString("NAUTILUS-000-SIMULATED"); var positionId = new PositionId("P-123456"); var strategyId = new StrategyId("SCALPER", "001"); var submitOrder = new SubmitOrder( traderId, accountId, strategyId, positionId, order, Guid.NewGuid(), StubZonedDateTime.UnixEpoch()); // Act this.engine.Endpoint.SendAsync(submitOrder).Wait(); this.engine.Endpoint.SendAsync(StubEventMessageProvider.OrderSubmittedEvent(order)).Wait(); this.engine.Endpoint.SendAsync(StubEventMessageProvider.OrderAcceptedEvent(order)).Wait(); this.engine.Endpoint.SendAsync(StubEventMessageProvider.OrderFilledEvent(order)).Wait(); Task.Delay(100).Wait(); // Buffer to avoid intermittent tests // Assert Assert.Single(this.database.GetPositions()); }
internal void OnModifyOrderCommand_WhenNoOrderExists_DoesNotSendToGateway() { // Arrange var order = new StubOrderBuilder().EntryOrder("O-123456").BuildMarketOrder(); var traderId = TraderId.FromString("TESTER-000"); var accountId = AccountId.FromString("NAUTILUS-000-SIMULATED"); var modify = new ModifyOrder( traderId, accountId, order.Id, order.Quantity, Price.Create(1.00010m, 5), Guid.NewGuid(), StubZonedDateTime.UnixEpoch()); // Act this.engine.Endpoint.SendAsync(modify); Task.Delay(100).Wait(); // Buffer to avoid intermittent tests // Assert Assert.Null(this.engine.UnhandledMessages.FirstOrDefault()); Assert.Equal(2, this.engine.ProcessedCount); Assert.Equal(1, this.engine.CommandCount); Assert.Equal(0, this.engine.EventCount); Assert.Empty(this.tradingGateway.CalledMethods); Assert.Empty(this.tradingGateway.ReceivedObjects); Assert.Empty(this.receiver.Messages); }
internal void CanSerializeAndDeserialize_OrderFilledEvents() { // Arrange var order = new StubOrderBuilder() .WithQuantity(Quantity.Create(100000)) .BuildStopLimitOrder(); var filled = new OrderFilled( AccountId.FromString("FXCM-02851908-DEMO"), order.Id, new ExecutionId("E123456"), new PositionIdBroker("P123456"), order.Symbol, order.OrderSide, order.Quantity, Price.Create(2m, 1), Currency.USD, StubZonedDateTime.UnixEpoch(), Guid.NewGuid(), StubZonedDateTime.UnixEpoch()); // Act var packed = this.serializer.Serialize(filled); var unpacked = (OrderFilled)this.serializer.Deserialize(packed); // Assert Assert.Equal(filled, unpacked); this.Output.WriteLine(Convert.ToBase64String(packed)); }
internal void GetOrdersCompleted_WhenDoesNotExistInCache_ReturnsEmptyDictionary() { // Arrange var order = new StubOrderBuilder().EntryOrder("O-123456").BuildMarketOrder(); var traderId = TraderId.FromString("TESTER-000"); var accountId = AccountId.FromString("NAUTILUS-000-SIMULATED"); var positionId = new PositionId("P-123456"); var strategyId = new StrategyId("SCALPER", "001"); this.database.AddOrder(order, traderId, accountId, strategyId, positionId); order.Apply(StubEventMessageProvider.OrderSubmittedEvent(order)); this.database.UpdateOrder(order); order.Apply(StubEventMessageProvider.OrderRejectedEvent(order)); this.database.UpdateOrder(order); // Act this.database.ClearCaches(); // Assert Assert.Empty(this.database.GetOrders()); Assert.Empty(this.database.GetOrders(traderId)); Assert.Empty(this.database.GetOrders(traderId, strategyId)); Assert.Empty(this.database.GetOrdersWorking()); Assert.Empty(this.database.GetOrdersWorking(traderId)); Assert.Empty(this.database.GetOrdersWorking(traderId, strategyId)); Assert.Empty(this.database.GetOrdersCompleted()); Assert.Empty(this.database.GetOrdersCompleted(traderId)); Assert.Empty(this.database.GetOrdersCompleted(traderId, strategyId)); }
internal void GetPositionsClosed_WhenNotPositionsInCache_ReturnsEmptyDictionary() { // Arrange var order1 = new StubOrderBuilder() .WithOrderId("O-123456-1") .BuildMarketOrder(); var order2 = new StubOrderBuilder() .WithOrderId("O-123456-2") .WithOrderSide(OrderSide.Sell) .BuildMarketOrder(); var traderId = TraderId.FromString("TESTER-000"); var accountId = AccountId.FromString("NAUTILUS-000-SIMULATED"); var strategyId = new StrategyId("SCALPER", "001"); var positionId = new PositionId("P-123456"); this.database.AddOrder(order1, traderId, accountId, strategyId, positionId); this.database.AddOrder(order2, traderId, accountId, strategyId, positionId); var position = new Position(positionId, StubEventMessageProvider.OrderFilledEvent(order1)); this.database.AddPosition(position); position.Apply(StubEventMessageProvider.OrderFilledEvent(order2)); this.database.UpdatePosition(position); // Act this.database.ClearCaches(); // Assert Assert.Empty(this.database.GetPositionsClosed()); Assert.Empty(this.database.GetPositionsClosed(traderId)); Assert.Empty(this.database.GetPositionsClosed(traderId, strategyId)); }
internal void GetPositionsOpen_WhenNotPositionsInCache_ReturnsEmptyDictionary() { // Arrange var order = new StubOrderBuilder().BuildMarketOrder(); var traderId = TraderId.FromString("TESTER-000"); var accountId = AccountId.FromString("NAUTILUS-000-SIMULATED"); var strategyId = new StrategyId("SCALPER", "001"); var positionId = new PositionId("P-123456"); this.database.AddOrder(order, traderId, accountId, strategyId, positionId); var position = new Position(positionId, StubEventMessageProvider.OrderPartiallyFilledEvent( order, Quantity.Create(50000), Quantity.Create(50000))); this.database.AddPosition(position); position.Apply(StubEventMessageProvider.OrderFilledEvent(order)); this.database.UpdatePosition(position); // Act this.database.ClearCaches(); // Assert Assert.Empty(this.database.GetPositionsOpen()); Assert.Empty(this.database.GetPositionsOpen(traderId)); Assert.Empty(this.database.GetPositionsOpen(traderId, strategyId)); }
internal void UpdateOrder_WhenOrderCompleted_CorrectlyUpdatesIndexes() { // Arrange var order = new StubOrderBuilder().EntryOrder("O-123456").BuildMarketOrder(); var traderId = TraderId.FromString("TESTER-000"); var accountId = AccountId.FromString("NAUTILUS-000-SIMULATED"); var positionId = new PositionId("P-123456"); var strategyId = new StrategyId("SCALPER", "001"); this.database.AddOrder(order, traderId, accountId, strategyId, positionId); order.Apply(StubEventMessageProvider.OrderSubmittedEvent(order)); this.database.UpdateOrder(order); order.Apply(StubEventMessageProvider.OrderRejectedEvent(order)); // Act this.database.UpdateOrder(order); // Assert Assert.Contains(order.Id, this.database.GetOrderIds()); Assert.Contains(order.Id, this.database.GetOrderIds(traderId)); Assert.Contains(order.Id, this.database.GetOrderIds(traderId, strategyId)); Assert.Contains(order.Id, this.database.GetOrderCompletedIds()); Assert.Contains(order.Id, this.database.GetOrderCompletedIds(traderId)); Assert.Contains(order.Id, this.database.GetOrderCompletedIds(traderId, strategyId)); Assert.DoesNotContain(order.Id, this.database.GetOrderWorkingIds()); Assert.Contains(order.Id, this.database.GetOrders(traderId)); Assert.Contains(order.Id, this.database.GetOrders(traderId, strategyId)); Assert.Contains(order.Id, this.database.GetOrdersCompleted(traderId)); Assert.Contains(order.Id, this.database.GetOrdersCompleted(traderId, strategyId)); }
internal void AddOrder_WithNoOrdersInDatabase_CorrectlyAddsOrderWithIndexes() { // Arrange var order = new StubOrderBuilder().EntryOrder("O-123456").BuildMarketOrder(); var traderId = TraderId.FromString("TESTER-000"); var accountId = AccountId.FromString("NAUTILUS-000-SIMULATED"); var positionId = new PositionId("P-123456"); var strategyId = new StrategyId("SCALPER", "001"); // Act this.database.AddOrder(order, traderId, accountId, strategyId, positionId); // Assert Assert.Equal(order, this.database.GetOrder(order.Id)); Assert.Equal(positionId, this.database.GetPositionId(order.Id)); Assert.Equal(traderId, this.database.GetTraderId(order.Id)); Assert.Single(this.database.GetOrders()); Assert.Single(this.database.GetOrders(traderId)); Assert.Single(this.database.GetOrders(traderId, strategyId)); Assert.Contains(order.Id, this.database.GetOrders()); Assert.Contains(order.Id, this.database.GetOrders(traderId)); Assert.Contains(order.Id, this.database.GetOrders(traderId, strategyId)); Assert.Contains(traderId, this.database.GetTraderIds()); Assert.Contains(accountId, this.database.GetAccountIds()); Assert.Contains(strategyId, this.database.GetStrategyIds(traderId)); }
internal void IsComplete_OrderPartiallyFilled_ReturnsFalse() { // Arrange var order = new StubOrderBuilder() .WithQuantity(Quantity.Create(100000)) .BuildStopMarketOrder(); var event1 = StubEventMessageProvider.OrderSubmittedEvent(order); var event2 = StubEventMessageProvider.OrderAcceptedEvent(order); var event3 = StubEventMessageProvider.OrderWorkingEvent(order, order.Price); var event4 = StubEventMessageProvider.OrderPartiallyFilledEvent( order, Quantity.Create(50000), Quantity.Create(50000), order.Price); order.Apply(event1); order.Apply(event2); order.Apply(event3); order.Apply(event4); // Act var result = order.IsCompleted; // Assert Assert.True(order.State == OrderState.PartiallyFilled); Assert.False(result); }
internal void UpdatePosition_WhenPositionOpen_CorrectlyUpdatesIndexes() { // Arrange var order = new StubOrderBuilder().BuildMarketOrder(); var traderId = TraderId.FromString("TESTER-000"); var accountId = AccountId.FromString("NAUTILUS-000-SIMULATED"); var strategyId = new StrategyId("SCALPER", "001"); var positionId = new PositionId("P-123456"); this.database.AddOrder(order, traderId, accountId, strategyId, positionId); var position = new Position(positionId, StubEventMessageProvider.OrderPartiallyFilledEvent( order, Quantity.Create(50000), Quantity.Create(50000))); this.database.AddPosition(position); // Act position.Apply(StubEventMessageProvider.OrderFilledEvent(order)); this.database.UpdatePosition(position); // Assert Assert.Equal(position, this.database.GetPosition(positionId)); Assert.Contains(position.Id, this.database.GetPositions()); Assert.Contains(position.Id, this.database.GetPositions(traderId)); Assert.Contains(position.Id, this.database.GetPositions(traderId, strategyId)); Assert.Contains(position.Id, this.database.GetPositionsOpen()); Assert.Contains(position.Id, this.database.GetPositionsOpen(traderId)); Assert.Contains(position.Id, this.database.GetPositionsOpen(traderId, strategyId)); Assert.Contains(position.Id, this.database.GetPositionIds()); Assert.Contains(position.Id, this.database.GetPositionOpenIds()); Assert.DoesNotContain(position.Id, this.database.GetPositionClosedIds()); }
internal void Apply_OrderPartiallyFilled_ReturnsCorrectOrderStatus() { // Arrange var order = new StubOrderBuilder().BuildStopMarketOrder(); var event1 = StubEventMessageProvider.OrderSubmittedEvent(order); var event2 = StubEventMessageProvider.OrderAcceptedEvent(order); var event3 = StubEventMessageProvider.OrderWorkingEvent(order, order.Price); var event4 = StubEventMessageProvider.OrderPartiallyFilledEvent( order, order.Quantity, Quantity.Create(order.Quantity / 2), order.Price); // Act order.Apply(event1); order.Apply(event2); order.Apply(event3); order.Apply(event4); var result = order.State; // Assert Assert.Equal(OrderState.PartiallyFilled, result); }
internal void Build_WithAllParametersModified_ThenReturnsExpectedOrder() { // Arrange // Act var order = new StubOrderBuilder() .WithSymbol(new Symbol("AUD/USD", new Venue("FXCM"))) .WithOrderId("O-678910") .WithOrderSide(OrderSide.Sell) .WithQuantity(Quantity.Create(100000)) .WithPrice(Price.Create(1.00000m, 5)) .WithTimeInForce(TimeInForce.GTD) .WithExpireTime(StubZonedDateTime.UnixEpoch() + Period.FromMinutes(5).ToDuration()) .WithTimestamp(StubZonedDateTime.UnixEpoch() + Period.FromMinutes(1).ToDuration()) .BuildStopMarketOrder(); // Assert Assert.Equal(new Symbol("AUD/USD", new Venue("FXCM")), order.Symbol); Assert.Equal("O-678910", order.Id.Value); Assert.Equal(OrderSide.Sell, order.OrderSide); Assert.Equal(OrderType.Stop, order.OrderType); Assert.Equal(Quantity.Create(100000), order.Quantity); Assert.Equal(Price.Create(1m, 5), order.Price); Assert.Equal(TimeInForce.GTD, order.TimeInForce); Assert.Equal(StubZonedDateTime.UnixEpoch() + Period.FromMinutes(5).ToDuration(), order.ExpireTime); Assert.Equal(StubZonedDateTime.UnixEpoch() + Period.FromMinutes(1).ToDuration(), order.Timestamp); }
internal void BrokerOrderId_ListIsEmpty_ReturnsNullEntityId() { // Arrange // Act var order = new StubOrderBuilder().BuildStopMarketOrder(); // Assert Assert.Null(order.IdBroker); }
internal void ExecutionId_ListIsEmpty_ReturnsNullEntityId() { // Arrange // Act var order = new StubOrderBuilder().BuildStopMarketOrder(); // Assert Assert.Null(order.ExecutionId); }
internal void BuildStopMarket_ThenReturnsExpectedOrder() { // Arrange // Act var order = new StubOrderBuilder().BuildStopMarketOrder(); // Assert Assert.Equal(OrderType.Stop, order.OrderType); }
internal void OnModifyOrderCommand_WhenOrderAlreadyBeingModified_DoesNotSendToGateway() { // Arrange var order = new StubOrderBuilder().EntryOrder("O-123456").BuildStopMarketOrder(); var traderId = TraderId.FromString("TESTER-000"); var accountId = AccountId.FromString("NAUTILUS-000-SIMULATED"); var positionId = new PositionId("P-123456"); var strategyId = new StrategyId("SCALPER", "001"); var submit = new SubmitOrder( traderId, accountId, strategyId, positionId, order, Guid.NewGuid(), StubZonedDateTime.UnixEpoch()); var modify1 = new ModifyOrder( traderId, accountId, order.Id, order.Quantity, Price.Create(1.00010m, 5), Guid.NewGuid(), StubZonedDateTime.UnixEpoch()); var modify2 = new ModifyOrder( traderId, accountId, order.Id, order.Quantity, Price.Create(1.00010m, 5), Guid.NewGuid(), StubZonedDateTime.UnixEpoch()); // Act this.engine.Endpoint.SendAsync(submit).Wait(); this.engine.Endpoint.SendAsync(StubEventMessageProvider.OrderAcceptedEvent(order)).Wait(); this.engine.Endpoint.SendAsync(StubEventMessageProvider.OrderWorkingEvent(order)).Wait(); this.engine.Endpoint.SendAsync(modify1).Wait(); this.engine.Endpoint.SendAsync(modify2).Wait(); Task.Delay(100).Wait(); // Buffer to avoid intermittent tests // Assert Assert.Null(this.engine.UnhandledMessages.FirstOrDefault()); Assert.Equal(6, this.engine.ProcessedCount); Assert.Equal(3, this.engine.CommandCount); Assert.Equal(2, this.engine.EventCount); Assert.Equal(2, this.tradingGateway.CalledMethods.Count); Assert.Equal(2, this.tradingGateway.ReceivedObjects.Count); Assert.Equal("SubmitOrder", this.tradingGateway.CalledMethods[0]); Assert.Equal("ModifyOrder", this.tradingGateway.CalledMethods[1]); Assert.Equal(3, this.receiver.Messages.Count); }
internal void GetSlippage_UnfilledOrder_ReturnsZero() { // Arrange var order = new StubOrderBuilder().BuildStopMarketOrder(); // Act var result = order.Slippage.HasValue; // Assert Assert.False(result); }
internal void IsComplete_OrderInitialized_ReturnsFalse() { // Arrange var order = new StubOrderBuilder().BuildStopMarketOrder(); // Act var result = order.IsCompleted; // Assert Assert.False(result); }
internal void Equals_OrderWithTheSameOrderId_ReturnsFalse() { // Arrange var order1 = new StubOrderBuilder().WithOrderId("O-1234567").BuildStopMarketOrder(); var order2 = new StubOrderBuilder().WithOrderId("O-123456789").BuildStopMarketOrder(); // Act var result = order1.Equals(order2); // Assert Assert.False(result); }
internal void Equals_ObjectSomeOtherType_ReturnsFalse() { // Arrange var order = new StubOrderBuilder().BuildStopMarketOrder(); // Act // ReSharper disable once SuspiciousTypeConversion.Global (this is why the test returns false) var result = order.Equals(string.Empty); // Assert Assert.False(result); }
internal void Equals_OrderWithTheSameOrderId_ReturnsTrue() { // Arrange var order1 = new StubOrderBuilder().WithOrderId("O-123456789").BuildStopMarketOrder(); var order2 = new StubOrderBuilder().WithOrderId("O-123456789").BuildStopMarketOrder(); // Act var result = order1.Equals(order2); this.Output.WriteLine(order1.ToString()); this.Output.WriteLine(order2.ToString()); // Assert Assert.True(result); }
internal void Rejected_ParametersValid_ReturnsExpectedResult() { // Arrange var order = new StubOrderBuilder().BuildStopMarketOrder(); var event1 = StubEventMessageProvider.OrderSubmittedEvent(order); var event2 = StubEventMessageProvider.OrderRejectedEvent(order); // Act order.Apply(event1); order.Apply(event2); // Assert Assert.Equal(3, order.EventCount); Assert.Equal(OrderState.Rejected, order.State); Assert.Equal(StubZonedDateTime.UnixEpoch(), order.LastEvent.Timestamp); }
internal void Build_WithNoParametersModified_ThenReturnsExpectedOrder() { // Arrange // Act var order = new StubOrderBuilder().BuildStopMarketOrder(); // Assert Assert.Equal(new Symbol("AUD/USD", new Venue("FXCM")), order.Symbol); Assert.Equal("O-123456", order.Id.Value); Assert.Equal(OrderSide.Buy, order.OrderSide); Assert.Equal(OrderType.Stop, order.OrderType); Assert.Equal(Quantity.Create(100000), order.Quantity); Assert.Equal(Price.Create(1m, 1), order.Price); Assert.Equal(TimeInForce.DAY, order.TimeInForce); Assert.Null(order.ExpireTime); Assert.Equal(StubZonedDateTime.UnixEpoch(), order.Timestamp); }
internal void ClearCaches_WithOrderInCaches_CorrectlyClearsCache() { // Arrange var order = new StubOrderBuilder().EntryOrder("O-123456").BuildMarketOrder(); var traderId = TraderId.FromString("TESTER-000"); var accountId = AccountId.FromString("NAUTILUS-000-SIMULATED"); var positionId = new PositionId("P-123456"); var strategyId = new StrategyId("SCALPER", "001"); this.database.AddOrder(order, traderId, accountId, strategyId, positionId); // Act this.database.ClearCaches(); // Assert Assert.Null(this.database.GetOrder(order.Id)); }
internal void AddOrder_WhenOrderAlreadyExists_ReturnsFailureResult() { // Arrange var order = new StubOrderBuilder().EntryOrder("O-123456").BuildMarketOrder(); var traderId = TraderId.FromString("TESTER-000"); var accountId = AccountId.FromString("NAUTILUS-000-SIMULATED"); var positionId = new PositionId("P-123456"); var strategyId = new StrategyId("SCALPER", "001"); this.database.AddOrder(order, traderId, accountId, strategyId, positionId); // Act var result = this.database.AddOrder(order, traderId, accountId, strategyId, positionId); // Assert Assert.True(result.IsFailure); }